clang 19.0.0git
Public Attributes | List of all members
clang::format::FormatStyle::BraceWrappingFlags Struct Reference

Precise control over the wrapping of braces. More...

#include "clang/Format/Format.h"

Public Attributes

bool AfterCaseLabel
 Wrap case labels.
 
bool AfterClass
 Wrap class definitions.
 
BraceWrappingAfterControlStatementStyle AfterControlStatement
 Wrap control statements (if/for/while/switch/..).
 
bool AfterEnum
 Wrap enum definitions.
 
bool AfterFunction
 Wrap function definitions.
 
bool AfterNamespace
 Wrap namespace definitions.
 
bool AfterObjCDeclaration
 Wrap ObjC definitions (interfaces, implementations...).
 
bool AfterStruct
 Wrap struct definitions.
 
bool AfterUnion
 Wrap union definitions.
 
bool AfterExternBlock
 Wrap extern blocks.
 
bool BeforeCatch
 Wrap before catch.
 
bool BeforeElse
 Wrap before else.
 
bool BeforeLambdaBody
 Wrap lambda block.
 
bool BeforeWhile
 Wrap before while.
 
bool IndentBraces
 Indent the wrapped braces themselves.
 
bool SplitEmptyFunction
 If false, empty function body can be put on a single line.
 
bool SplitEmptyRecord
 If false, empty record (e.g.
 
bool SplitEmptyNamespace
 If false, empty namespace body can be put on a single line.
 

Detailed Description

Precise control over the wrapping of braces.

# Should be declared this way:
AfterClass: true
bool AfterClass
Wrap class definitions.
Definition: Format.h:1333
BraceBreakingStyle BreakBeforeBraces
The brace breaking style to use.
Definition: Format.h:2158
BraceWrappingFlags BraceWrapping
Control of individual brace wrapping cases.
Definition: Format.h:1545

Definition at line 1307 of file Format.h.

Member Data Documentation

◆ AfterCaseLabel

bool clang::format::FormatStyle::BraceWrappingFlags::AfterCaseLabel

Wrap case labels.

false: true:
switch (foo) { vs. switch (foo) {
case 1: { case 1:
bar(); {
break; bar();
} break;
default: { }
plop(); default:
} {
} plop();
}
}

Definition at line 1323 of file Format.h.

Referenced by clang::format::expandPresetsBraceWrapping().

◆ AfterClass

bool clang::format::FormatStyle::BraceWrappingFlags::AfterClass

Wrap class definitions.

true:
class foo
{};
false:
class foo {};

Definition at line 1333 of file Format.h.

Referenced by clang::format::expandPresetsBraceWrapping(), clang::format::getMicrosoftStyle(), and clang::format::ShouldBreakBeforeBrace().

◆ AfterControlStatement

BraceWrappingAfterControlStatementStyle clang::format::FormatStyle::BraceWrappingFlags::AfterControlStatement

Wrap control statements (if/for/while/switch/..).

Definition at line 1336 of file Format.h.

Referenced by clang::format::expandPresetsBraceWrapping(), and clang::format::getMicrosoftStyle().

◆ AfterEnum

bool clang::format::FormatStyle::BraceWrappingFlags::AfterEnum

Wrap enum definitions.

true:
enum X : int
{
B
};
false:
enum X : int { B };
#define X(type, name)
Definition: Value.h:143

Definition at line 1348 of file Format.h.

Referenced by clang::format::expandPresetsBraceWrapping(), clang::format::getMicrosoftStyle(), and clang::format::ShouldBreakBeforeBrace().

◆ AfterExternBlock

bool clang::format::FormatStyle::BraceWrappingFlags::AfterExternBlock

Wrap extern blocks.

true:
extern "C"
{
int foo();
}
false:
extern "C" {
int foo();
}

Definition at line 1428 of file Format.h.

Referenced by clang::format::expandPresetsBraceWrapping(), and clang::format::getMicrosoftStyle().

◆ AfterFunction

bool clang::format::FormatStyle::BraceWrappingFlags::AfterFunction

Wrap function definitions.

true:
void foo()
{
bar();
bar2();
}
false:
void foo() {
bar();
bar2();
}

Definition at line 1364 of file Format.h.

Referenced by clang::format::expandPresetsBraceWrapping(), and clang::format::getMicrosoftStyle().

◆ AfterNamespace

bool clang::format::FormatStyle::BraceWrappingFlags::AfterNamespace

Wrap namespace definitions.

true:
namespace
{
int foo();
int bar();
}
false:
namespace {
int foo();
int bar();
}

Definition at line 1380 of file Format.h.

Referenced by clang::format::expandPresetsBraceWrapping(), clang::format::getMicrosoftStyle(), and clang::format::ShouldBreakBeforeBrace().

◆ AfterObjCDeclaration

bool clang::format::FormatStyle::BraceWrappingFlags::AfterObjCDeclaration

Wrap ObjC definitions (interfaces, implementations...).

Note
@autoreleasepool and @synchronized blocks are wrapped according to AfterControlStatement flag. \endnote

Definition at line 1386 of file Format.h.

Referenced by clang::format::expandPresetsBraceWrapping(), and clang::format::getMicrosoftStyle().

◆ AfterStruct

bool clang::format::FormatStyle::BraceWrappingFlags::AfterStruct

Wrap struct definitions.

true:
struct foo
{
int x;
};
false:
struct foo {
int x;
};

Definition at line 1400 of file Format.h.

Referenced by clang::format::expandPresetsBraceWrapping(), clang::format::getMicrosoftStyle(), and clang::format::ShouldBreakBeforeBrace().

◆ AfterUnion

bool clang::format::FormatStyle::BraceWrappingFlags::AfterUnion

Wrap union definitions.

true:
union foo
{
int x;
}
false:
union foo {
int x;
}

Definition at line 1414 of file Format.h.

Referenced by clang::format::expandPresetsBraceWrapping(), and clang::format::ShouldBreakBeforeBrace().

◆ BeforeCatch

bool clang::format::FormatStyle::BraceWrappingFlags::BeforeCatch

Wrap before catch.

true:
try {
foo();
}
catch () {
}
false:
try {
foo();
} catch () {
}

Definition at line 1444 of file Format.h.

Referenced by clang::format::expandPresetsBraceWrapping(), and clang::format::getMicrosoftStyle().

◆ BeforeElse

bool clang::format::FormatStyle::BraceWrappingFlags::BeforeElse

Wrap before else.

true:
if (foo()) {
}
else {
}
false:
if (foo()) {
} else {
}

Definition at line 1458 of file Format.h.

Referenced by clang::format::expandPresetsBraceWrapping(), and clang::format::getMicrosoftStyle().

◆ BeforeLambdaBody

bool clang::format::FormatStyle::BraceWrappingFlags::BeforeLambdaBody

Wrap lambda block.

true:
connect(
[]()
{
foo();
bar();
});
false:
connect([]() {
foo();
bar();
});

Definition at line 1475 of file Format.h.

Referenced by clang::format::ContinuationIndenter::canBreak(), clang::format::expandPresetsBraceWrapping(), clang::format::hasNestedBlockInlined(), and clang::format::ContinuationIndenter::mustBreak().

◆ BeforeWhile

bool clang::format::FormatStyle::BraceWrappingFlags::BeforeWhile

Wrap before while.

true:
do {
foo();
}
while (1);
false:
do {
foo();
} while (1);

Definition at line 1489 of file Format.h.

Referenced by clang::format::getMicrosoftStyle().

◆ IndentBraces

bool clang::format::FormatStyle::BraceWrappingFlags::IndentBraces

Indent the wrapped braces themselves.

Definition at line 1491 of file Format.h.

◆ SplitEmptyFunction

bool clang::format::FormatStyle::BraceWrappingFlags::SplitEmptyFunction

If false, empty function body can be put on a single line.

This option is used only if the opening brace of the function has already been wrapped, i.e. the AfterFunction brace wrapping mode is set, and the function could/should not be put on a single line (as per AllowShortFunctionsOnASingleLine and constructor formatting options).

false: true:
int f() vs. int f()
{} {
}

Definition at line 1505 of file Format.h.

Referenced by clang::format::expandPresetsBraceWrapping().

◆ SplitEmptyNamespace

bool clang::format::FormatStyle::BraceWrappingFlags::SplitEmptyNamespace

If false, empty namespace body can be put on a single line.

This option is used only if the opening brace of the namespace has already been wrapped, i.e. the AfterNamespace brace wrapping mode is set.

false: true:
namespace Foo vs. namespace Foo
{} {
}

Definition at line 1529 of file Format.h.

◆ SplitEmptyRecord

bool clang::format::FormatStyle::BraceWrappingFlags::SplitEmptyRecord

If false, empty record (e.g.

class, struct or union) body can be put on a single line. This option is used only if the opening brace of the record has already been wrapped, i.e. the AfterClass (for classes) brace wrapping mode is set.

false: true:
class Foo vs. class Foo
{} {
}

Definition at line 1517 of file Format.h.

Referenced by clang::format::expandPresetsBraceWrapping().


The documentation for this struct was generated from the following file: