The FormatStyle
is used to configure the formatting to follow specific guidelines. More...
#include "clang/Format/Format.h"
:
in bitfield definitions. More...
&
, &&
and *
alignment style. More...
&
and &&
alignment style. More...
<
and before >
in template argument lists. More...
true
, horizontally aligns arguments after an open bracket.
None
, when using initialization for an array of structs aligns the fields into columns.
true
, horizontally align operands of binary and ternary expressions.
BinPackArguments
is false
.
noexcept
specifier.
while (true) { continue; }
can be put on a single line.
true
, short case labels will be contracted to a single line.
int f() { return 0; }
can be put on a single line.
if (a) return;
can be put on a single line.
auto lambda []() { return 0; }
can be put on a single line.
true
, while (true) continue;
can be put on a single line.
true
, namespace a { class b; }
can be put on a single line.
BreakAfterReturnType
.
BreakTemplateDeclarations
.
false
, a function call's arguments will either be all on the same line or will have one line each.
true
, clang-format will always break after a Json array [
otherwise it will scan until the closing ]
to determine if it should add newlines between elements (prettier compatible).
true
, ternary operators will be placed after line breaks.
true
, clang-format will always break before function definition parameters.
true
, consecutive namespace declarations will be on the same line.
true
, format braced lists as best suited for C++11 braced lists.
true
, clang-format detects whether function calls and definitions are formatted with one parameter per line.
true
, clang-format adds missing namespace end comments for namespaces and fixes invalid existing ones.
true
, clang-format will indent the body of an export { ... }
block.
if
, else
, for
, do
, and while
) in C++ unless the control statements are inside macro definitions or the braces would enclose preprocessor directives.
TCS_Wrapped
will insert trailing commas in container literals (arrays and objects) that wrap across multiple lines.
'
for C++ and _
for C#, Java, and JavaScript).
\n
or \r\n
) to use.
<definition>=<expansion> .
ColumnLimit
.
@property
in Objective-C, i.e.
call(
.
.
<<
.
(
.
::
.
PointerAlignment
for references).
if
, else
, for
, and while
) in C++ according to the LLVM coding style.
requires
clause.
#includes
.
true
, a space is inserted after C style casts.
true
, a space is inserted after the logical not operator (!
).
true
, a space will be inserted after the template
keyword.
false
, spaces will be removed before assignment operators.
false
, spaces will be removed before case colon.
true
, a space will be inserted before a C++11 braced list used to initialize an object (after the preceding identifier or type).
false
, spaces will be removed before constructor initializer colon.
false
, spaces will be removed before inheritance colon.
true
, a space will be added before a JSON colon.
true
, spaces will be before [
.
false
, spaces will be removed before range-based for loop colon.
true
, spaces will be inserted into {}
.
true
, spaces may be inserted into ()
.
true
, spaces will be inserted around if/for/switch/while conditions.
true
, spaces will be inserted after (
and before )
.
true
, spaces will be inserted after [
and before ]
.
The FormatStyle
is used to configure the formatting to follow specific guidelines.
Definition at line 55 of file Format.h.
◆ ArrayInitializerAlignmentStyleDifferent style for aligning array initializers.
Enumerator AIAS_LeftAlign array column and left justify the columns e.g.:
struct test demo[] =
{
{56, 23, "hello"},
{-1, 93463, "world"},
{7, 5, "!!" }
};
AIAS_RightAlign array column and right justify the columns e.g.:
struct test demo[] =
{
{56, 23, "hello"},
{-1, 93463, "world"},
{ 7, 5, "!!"}
};
AIAS_NoneDon't align array initializer columns.
Definition at line 110 of file Format.h.
◆ AttributeBreakingStyleDifferent ways to break after attributes.
Enumerator ABS_AlwaysAlways break after attributes.
[[maybe_unused]]
const int i;
[[gnu::const]] [[maybe_unused]]
int j;
[[nodiscard]]
inline int f();
[[gnu::const]] [[nodiscard]]
int g();
[[likely]]
if (a)
f();
else
g();
switch(
b) {
[[unlikely]]
case 1:
++
b;
break;
[[likely]]
default:
return;
}
b__device__ __2f16 b
Definition: __clang_hip_libdevice_declares.h:303 ABS_LeaveLeave the line breaking after attributes as is.
[[maybe_unused]] const int i;
[[gnu::const]] [[maybe_unused]]
int j;
[[nodiscard]] inline int f();
[[gnu::const]] [[nodiscard]]
int g();
[[likely]] if (a)
f();
else
g();
switch(
b) {
[[unlikely]] case 1:
++
b;
break;
[[likely]]
default:
return;
}
ABS_NeverNever break after attributes.
[[maybe_unused]] const int i;
[[gnu::const]] [[maybe_unused]] int j;
[[nodiscard]] inline int f();
[[gnu::const]] [[nodiscard]] int g();
[[likely]] if (a)
f();
else
g();
switch(
b) {
[[unlikely]] case 1:
++
b;
break;
[[likely]] default:
return;
}
Definition at line 1603 of file Format.h.
◆ BinaryOperatorStyleThe style of breaking before or after binary operators.
Enumerator BOS_NoneBreak after operators.
LooooooooooongType loooooooooooooooooooooongVariable =
someLooooooooooooooooongFunction();
bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ==
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &&
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa >
ccccccccccccccccccccccccccccccccccccccccc;
BOS_NonAssignmentBreak before operators that aren't assignments.
LooooooooooongType loooooooooooooooooooooongVariable =
someLooooooooooooooooongFunction();
bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
== aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
&& aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
> ccccccccccccccccccccccccccccccccccccccccc;
BOS_AllBreak before operators.
LooooooooooongType loooooooooooooooooooooongVariable
= someLooooooooooooooooongFunction();
bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
== aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
&& aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
> ccccccccccccccccccccccccccccccccccccccccc;
Definition at line 1724 of file Format.h.
◆ BinPackParametersStyleDifferent way to try to fit all parameters on a line.
Enumerator BPPS_BinPackBin-pack parameters.
void f(int a, int bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
int ccccccccccccccccccccccccccccccccccccccccccc);
BPPS_OnePerLinePut all parameters on the current line if they fit.
Otherwise, put each one on its own line.
voidf(
inta,
int b,
int c);
void f(int a,
int b,
int ccccccccccccccccccccccccccccccccccccc);
c__device__ __2f16 float c
Definition: __clang_hip_libdevice_declares.h:304 BPPS_AlwaysOnePerLineAlways put each parameter on its own line.
void f(int a,
int b,
int c);
Definition at line 1216 of file Format.h.
◆ BinPackStyleThe style of wrapping parameters on the same line (bin-packed) or on one line each.
Enumerator BPS_AutoAutomatically determine parameter bin-packing behavior.
BPS_AlwaysAlways bin-pack parameters.
BPS_NeverNever bin-pack parameters.
Definition at line 1714 of file Format.h.
◆ BitFieldColonSpacingStyleStyles for adding spacing around :
in bitfield definitions.
Add one space on each side of the :
unsigned bf : 2;
BFCS_NoneAdd no space around the :
(except when needed for AlignConsecutiveBitFields
).
unsigned bf:2;
BFCS_BeforeAdd space before the :
only.
unsigned bf :2;
BFCS_AfterAdd space after the :
only (space may be added before if needed for AlignConsecutiveBitFields
).
unsigned bf: 2;
Definition at line 1247 of file Format.h.
◆ BraceBreakingStyleDifferent ways to attach braces to their surrounding context.
Enumerator BS_AttachAlways attach braces to surrounding context.
namespace N {
enum E{
E1,
E2,
};
class C {
public:
C();
};
bool baz(int i) {
try {
do {
switch (i) {
case 1: {
foobar();
break;
}
default: {
break;
}
}
} while (--i);
return true;
} catch (...) {
handleError();
return false;
}
}
voidfoo(
bool b) {
if(
b) {
baz(2);
} else {
baz(5);
}
}
void bar() { foo(true); }
}
EExpr * E
Definition: CheckExprLifetime.cpp:210 BS_LinuxLike Attach
, but break before braces on function, namespace and class definitions.
namespace N
{
enum E{
E1,
E2,
};
class C
{
public:
C();
};
bool baz(int i)
{
try {
do {
switch (i) {
case 1: {
foobar();
break;
}
default: {
break;
}
}
} while (--i);
return true;
} catch (...) {
handleError();
return false;
}
}
voidfoo(
bool b)
{
if(
b) {
baz(2);
} else {
baz(5);
}
}
void bar() { foo(true); }
}
BS_MozillaLike Attach
, but break before braces on enum, function, and record definitions.
namespace N {
enum E{
E1,
E2,
};
class C
{
public:
C();
};
bool baz(int i)
{
try {
do {
switch (i) {
case 1: {
foobar();
break;
}
default: {
break;
}
}
} while (--i);
return true;
} catch (...) {
handleError();
return false;
}
}
voidfoo(
bool b)
{
if(
b) {
baz(2);
} else {
baz(5);
}
}
void bar() { foo(true); }
}
BS_StroustrupLike Attach
, but break before function definitions, catch
, and else
.
namespace N {
enum E{
E1,
E2,
};
class C {
public:
C();
};
bool baz(int i)
{
try {
do {
switch (i) {
case 1: {
foobar();
break;
}
default: {
break;
}
}
} while (--i);
return true;
}
catch (...) {
handleError();
return false;
}
}
voidfoo(
bool b)
{
if(
b) {
baz(2);
}
else {
baz(5);
}
}
void bar() { foo(true); }
}
BS_AllmanAlways break before braces.
namespace N
{
enum E{
E1,
E2,
};
class C
{
public:
C();
};
bool baz(int i)
{
try
{
do
{
switch (i)
{
case 1:
{
foobar();
break;
}
default:
{
break;
}
}
} while (--i);
return true;
}
catch (...)
{
handleError();
return false;
}
}
voidfoo(
bool b)
{
if(
b)
{
baz(2);
}
else
{
baz(5);
}
}
void bar() { foo(true); }
}
BS_WhitesmithsLike Allman
but always indent braces and line up code with braces.
namespace N
{
enum E{
E1,
E2,
};
class C
{
public:
C();
};
bool baz(int i)
{
try
{
do
{
switch (i)
{
case 1:
{
foobar();
break;
}
default:
{
break;
}
}
} while (--i);
return true;
}
catch (...)
{
handleError();
return false;
}
}
voidfoo(
bool b)
{
if(
b)
{
baz(2);
}
else
{
baz(5);
}
}
void bar() { foo(true); }
}
BS_GNUAlways break before braces and add an extra level of indentation to braces of control statements, not to those of class, function or other definitions.
namespace N
{
enum E{
E1,
E2,
};
class C
{
public:
C();
};
bool baz(int i)
{
try
{
do
{
switch (i)
{
case 1:
{
foobar();
break;
}
default:
{
break;
}
}
}
while (--i);
return true;
}
catch (...)
{
handleError();
return false;
}
}
voidfoo(
bool b)
{
if(
b)
{
baz(2);
}
else
{
baz(5);
}
}
void bar() { foo(true); }
}
BS_WebKitLike Attach
, but break before functions.
namespace N {
enum E{
E1,
E2,
};
class C {
public:
C();
};
bool baz(int i)
{
try {
do {
switch (i) {
case 1: {
foobar();
break;
}
default: {
break;
}
}
} while (--i);
return true;
} catch (...) {
handleError();
return false;
}
}
voidfoo(
bool b)
{
if(
b) {
baz(2);
} else {
baz(5);
}
}
void bar() { foo(true); }
}
BS_CustomConfigure each individual brace in BraceWrapping
.
Definition at line 1768 of file Format.h.
◆ BraceWrappingAfterControlStatementStyleDifferent ways to wrap braces after control statements.
Enumerator BWACS_NeverNever wrap braces after a control statement.
if (foo()) {
} else {
}
for (int i = 0; i < 10; ++i) {
}
BWACS_MultiLineOnly wrap braces after a multi-line control statement.
if (foo && bar &&
baz)
{
quux();
}
while (foo || bar) {
}
BWACS_AlwaysAlways wrap braces after a control statement.
if (foo())
{
} else
{}
for (int i = 0; i < 10; ++i)
{}
Definition at line 1309 of file Format.h.
◆ BracketAlignmentStyleDifferent styles for aligning after open brackets.
Enumerator BAS_AlignAlign parameters on the open bracket, e.g.:
someLongFunction(argument1,
argument2);
BAS_DontAlignDon't align, instead use ContinuationIndentWidth
, e.g.:
someLongFunction(argument1,
argument2);
BAS_AlwaysBreakAlways break after an open bracket, if the parameters don't fit on a single line, e.g.:
someLongFunction(
argument1, argument2);
BAS_BlockIndentAlways break after an open bracket, if the parameters don't fit on a single line.
Closing brackets will be placed on a new line. E.g.:
someLongFunction(
argument1, argument2
)
Cpp11BracedListStyle
is true
) and parentheses. \endnote
Definition at line 66 of file Format.h.
◆ BreakBeforeConceptDeclarationsStyleDifferent ways to break before concept declarations.
Enumerator BBCDS_NeverKeep the template declaration line together with concept
.
<
typenameT>
concept C= ...;
clang::LinkageSpecLanguageIDs::C@ C
BBCDS_AllowedBreaking between template declaration and concept
is allowed.
The actual behavior depends on the content and line breaking rules and penalties.
BBCDS_AlwaysAlways break before concept
, putting it in the line after the template declaration.
template <typename T>
concept C= ...;
Definition at line 2203 of file Format.h.
◆ BreakBeforeInlineASMColonStyleDifferent ways to break ASM parameters.
Enumerator BBIAS_NeverNo break before inline ASM colon.
asm volatile("string", : : val);
BBIAS_OnlyMultilineBreak before inline ASM colon if the line length is longer than column limit.
asm volatile("string", : : val);
asm("cmoveq %1, %2, %[result]"
: [result] "=r"(result)
: "r"(test), "r"(new), "[result]"(old));
BBIAS_AlwaysAlways break before inline ASM colon.
asm volatile("string",
:
: val);
Definition at line 2227 of file Format.h.
◆ BreakBeforeNoexceptSpecifierStyleDifferent ways to break before a noexcept specifier.
Enumerator BBNSS_NeverNo line break allowed.
void foo(int arg1,
double arg2) noexcept;
void bar(int arg1, double arg2) noexcept(
noexcept(baz(arg1)) &&
noexcept(baz(arg2)));
BBNSS_OnlyWithParenFor a simple noexcept
there is no line break allowed, but when we have a condition it is.
void foo(int arg1,
double arg2) noexcept;
void bar(int arg1, double arg2)
noexcept(noexcept(baz(arg1)) &&
noexcept(baz(arg2)));
BBNSS_AlwaysLine breaks are allowed.
But note that because of the associated penalties clang-format
often prefers not to break before the noexcept
.
void foo(int arg1,
double arg2) noexcept;
void bar(int arg1, double arg2)
noexcept(noexcept(baz(arg1)) &&
noexcept(baz(arg2)));
Definition at line 695 of file Format.h.
◆ BreakBinaryOperationsStyleDifferent ways to break binary operations.
Enumerator BBO_NeverDon't break binary operations.
aaa + bbbb * ccccc - ddddd +
eeeeeeeeeeeeeeee;
BBO_OnePerLineBinary operations will either be all on the same line, or each operation will have one line each.
aaa +
bbbb *
ccccc -
ddddd +
eeeeeeeeeeeeeeee;
BBO_RespectPrecedenceBinary operations of a particular precedence that exceed the column limit will have one line each.
aaa +
bbbb * ccccc -
ddddd +
eeeeeeeeeeeeeeee;
Definition at line 2271 of file Format.h.
◆ BreakConstructorInitializersStyleDifferent ways to break initializers.
Enumerator BCIS_BeforeColonBreak constructor initializers before the colon and after the commas.
Constructor()
: initializer1(),
initializer2()
BCIS_BeforeCommaBreak constructor initializers before the colon and commas, and align the commas with the colon.
Constructor()
: initializer1()
, initializer2()
BCIS_AfterColonBreak constructor initializers after the colon and commas.
Constructor() :
initializer1(),
initializer2()
Definition at line 2306 of file Format.h.
◆ BreakInheritanceListStyleDifferent ways to break inheritance list.
Enumerator BILS_BeforeColonBreak inheritance list before the colon and after the commas.
class Foo
: Base1,
Base2
{};
BILS_BeforeCommaBreak inheritance list before the colon and commas, and align the commas with the colon.
class Foo
: Base1
, Base2
{};
BILS_AfterColonBreak inheritance list after the colon and commas.
class Foo :
Base1,
Base2
{};
BILS_AfterCommaBreak inheritance list only after the commas.
class Foo : Base1,
Base2
{};
Definition at line 2421 of file Format.h.
◆ BreakTemplateDeclarationsStyleDifferent ways to break after the template declaration.
Enumerator BTDS_LeaveDo not change the line breaking before the declaration.
template <typename T>
Tfoo() {
}
template<
typenameT>
Tfoo(
intaaaaaaaaaaaaaaaaaaaaa,
int bbbbbbbbbbbbbbbbbbbbb) {
}
clang::Tconst FunctionProtoType * T
Definition: RecursiveASTVisitor.h:1365 BTDS_NoDo not force break before declaration.
PenaltyBreakTemplateDeclaration
is taken into account.
<
typenameT>
Tfoo() {
}
template<
typenameT>
Tfoo(
intaaaaaaaaaaaaaaaaaaaaa,
int bbbbbbbbbbbbbbbbbbbbb) {
}
BTDS_MultiLineForce break after template declaration only when the following declaration spans multiple lines.
template<
typenameT>
Tfoo() {
}
template <typename T>
Tfoo(
intaaaaaaaaaaaaaaaaaaaaa,
int bbbbbbbbbbbbbbbbbbbbb) {
}
BTDS_YesAlways break after template declaration.
template <typename T>
Tfoo() {
}
template <typename T>
Tfoo(
intaaaaaaaaaaaaaaaaaaaaa,
int bbbbbbbbbbbbbbbbbbbbb) {
}
Definition at line 1127 of file Format.h.
◆ DAGArgStyleDifferent ways to control the format inside TableGen DAGArg.
Enumerator DAS_DontBreakNever break inside DAGArg.
let DAGArgIns = (ins i32:$src1, i32:$src2);
DAS_BreakElementsBreak inside DAGArg after each list element but for the last.
This aligns to the first element.
let DAGArgIns = (ins i32:$src1,
i32:$src2);
DAS_BreakAllBreak inside DAGArg after the operator and the all elements.
let DAGArgIns = (ins
i32:$src1,
i32:$src2
);
Definition at line 5033 of file Format.h.
◆ DefinitionReturnTypeBreakingStyleDifferent ways to break after the function definition return type.
This option is deprecated and is retained for backwards compatibility.
Enumerator DRTBS_NoneBreak after return type automatically.
PenaltyReturnTypeOnItsOwnLine
is taken into account.
Always break after the return type.
DRTBS_TopLevelAlways break after the return types of top-level functions.
Definition at line 997 of file Format.h.
◆ EmptyLineAfterAccessModifierStyleDifferent styles for empty line after access modifiers.
EmptyLineBeforeAccessModifier
configuration handles the number of empty lines between two access modifiers.
Remove all empty lines after access modifiers.
struct foo {
private:
int i;
protected:
int j;
public:
foo() {}
private:
protected:
};
ELAAMS_LeaveKeep existing empty lines after access modifiers.
MaxEmptyLinesToKeep is applied instead.
ELAAMS_AlwaysAlways add empty line after access modifiers if there are none.
MaxEmptyLinesToKeep is applied also.
struct foo {
private:
int i;
protected:
int j;
public:
foo() {}
private:
protected:
};
Definition at line 2553 of file Format.h.
◆ EmptyLineBeforeAccessModifierStyleDifferent styles for empty line before access modifiers.
Enumerator ELBAMS_NeverRemove all empty lines before access modifiers.
struct foo {
private:
int i;
protected:
int j;
public:
foo() {}
private:
protected:
};
ELBAMS_LeaveKeep existing empty lines before access modifiers.
ELBAMS_LogicalBlockAdd empty line only when access modifier starts a new logical block.
Logical block is a group of one or more member fields or functions.
struct foo {
private:
int i;
protected:
int j;
public:
foo() {}
private:
protected:
};
ELBAMS_AlwaysAlways add empty line before access modifiers unless access modifier is at the start of struct or class definition.
struct foo {
private:
int i;
protected:
int j;
public:
foo() {}
private:
protected:
};
Definition at line 2602 of file Format.h.
◆ EscapedNewlineAlignmentStyleDifferent styles for aligning escaped newlines.
Enumerator ENAS_DontAlignDon't align escaped newlines.
#define A \
int aaaa; \
int b; \
int dddddddddd;
ENAS_LeftAlign escaped newlines as far left as possible.
#define A \
int aaaa; \
int b; \
int dddddddddd;
ENAS_LeftWithLastLineAlign escaped newlines as far left as possible, using the last line of the preprocessor directive as the reference if it's the longest.
#define A \
int aaaa; \
int b; \
int dddddddddd;
ENAS_RightAlign escaped newlines in the right-most column.
#define A \
int aaaa; \
int b; \
int dddddddddd;
Definition at line 488 of file Format.h.
◆ IndentExternBlockStyleIndents extern blocks.
Definition at line 2819 of file Format.h.
◆ JavaScriptQuoteStyleQuotation styles for JavaScript strings.
Does not affect template strings.
Enumerator JSQS_LeaveLeave string quotes as they are.
string1 = "foo";
string2 = 'bar';
JSQS_SingleAlways use single quotes.
string1 = 'foo';
string2 = 'bar';
JSQS_DoubleAlways use double quotes.
string1 = "foo";
string2 = "bar";
Definition at line 3142 of file Format.h.
◆ LambdaBodyIndentationKindIndentation logic for lambda bodies.
Enumerator LBI_SignatureAlign lambda body relative to the lambda signature.
This is the default.
someMethod(
[](SomeReallyLongLambdaSignatureArgument foo) {
return;
});
LBI_OuterScopeFor statements within block scope, align lambda body relative to the indentation level of the outer scope the lambda signature resides in.
someMethod(
[](SomeReallyLongLambdaSignatureArgument foo) {
return;
});
someMethod(someOtherMethod(
[](SomeReallyLongLambdaSignatureArgument foo) {
return;
}));
Definition at line 3237 of file Format.h.
◆ LanguageKindSupported languages.
When stored in a configuration file, specifies the language, that the configuration targets. When passed to the reformat()
function, enables syntax features specific to the language.
Definition at line 3275 of file Format.h.
◆ LanguageStandardSupported language standards for parsing and formatting C++ constructs.
Latest: vector<set<int>>
c++03 vs. vector<set<int> >
The correct way to spell a specific language version is e.g. c++11
. The historical aliases Cpp03
and Cpp11
are deprecated.
Parse and format as C++03.
Cpp03
is a deprecated alias for c++03
Parse and format as C++11.
LS_Cpp14Parse and format as C++14.
LS_Cpp17Parse and format as C++17.
LS_Cpp20Parse and format as C++20.
LS_LatestParse and format using the latest supported language version.
Cpp11
is a deprecated alias for Latest
Automatic detection based on the input.
Definition at line 4952 of file Format.h.
◆ LineEndingStyleLine ending style.
Enumerator LE_LFUse \n
.
Use \r\n
.
Use \n
unless the input has more lines ending in \r\n
.
Use \r\n
unless the input has more lines ending in \n
.
Definition at line 3318 of file Format.h.
◆ NamespaceIndentationKindDifferent ways to indent namespace contents.
Enumerator NI_NoneDon't indent in namespaces.
namespace out {
int i;
namespace in {
int i;
}
}
NI_InnerIndent only in inner namespaces (nested in other namespaces).
namespace out {
int i;
namespace in {
int i;
}
}
NI_AllIndent in all namespaces.
namespace out {
int i;
namespace in {
int i;
}
}
Definition at line 3421 of file Format.h.
◆ OperandAlignmentStyleDifferent styles for aligning operands.
Enumerator OAS_DontAlignDo not align operands of binary and ternary expressions.
The wrapped lines are indented ContinuationIndentWidth
spaces from the start of the line.
Horizontally align operands of binary and ternary expressions.
Specifically, this aligns operands of a single expression that needs to be split over multiple lines, e.g.: \code int aaa = bbbbbbbbbbbbbbb + ccccccccccccccc; \endcode When ``BreakBeforeBinaryOperators`` is set, the wrapped operator is aligned with the operand on the first line. \code int aaa = bbbbbbbbbbbbbbb + ccccccccccccccc; \endcodeOAS_AlignAfterOperator
Horizontally align operands of binary and ternary expressions.
This is similar to ``OAS_Align``, except when ``BreakBeforeBinaryOperators`` is set, the operator is un-indented so that the wrapped operand is aligned with the operand on the first line. \code int aaa = bbbbbbbbbbbbbbb + ccccccccccccccc; \endcode
Definition at line 529 of file Format.h.
◆ PackConstructorInitializersStyleDifferent ways to try to fit all constructor initializers on a line.
Enumerator PCIS_NeverAlways put each constructor initializer on its own line.
Constructor()
: a(),
b()
PCIS_BinPackBin-pack constructor initializers.
Constructor()
: aaaaaaaaaaaaaaaaaaaa(), bbbbbbbbbbbbbbbbbbbb(),
cccccccccccccccccccc()
PCIS_CurrentLinePut all constructor initializers on the current line if they fit.
Otherwise, put each one on its own line.
Constructor() : a(),
b()
Constructor()
: aaaaaaaaaaaaaaaaaaaa(),
bbbbbbbbbbbbbbbbbbbb(),
ddddddddddddd()
PCIS_NextLineSame as PCIS_CurrentLine
except that if all constructor initializers do not fit on the current line, try to fit them on the next line.
Constructor() : a(),
b()
Constructor()
: aaaaaaaaaaaaaaaaaaaa(), bbbbbbbbbbbbbbbbbbbb(), ddddddddddddd()
Constructor()
: aaaaaaaaaaaaaaaaaaaa(),
bbbbbbbbbbbbbbbbbbbb(),
cccccccccccccccccccc()
PCIS_NextLineOnlyPut all constructor initializers on the next line if they fit.
Otherwise, put each one on its own line.
Constructor()
: a(),
b()
Constructor()
: aaaaaaaaaaaaaaaaaaaa(), bbbbbbbbbbbbbbbbbbbb(), ddddddddddddd()
Constructor()
: aaaaaaaaaaaaaaaaaaaa(),
bbbbbbbbbbbbbbbbbbbb(),
cccccccccccccccccccc()
Definition at line 3573 of file Format.h.
◆ PointerAlignmentStyleThe &
, &&
and *
alignment style.
Align pointer to the left.
int* a;
PAS_RightAlign pointer to the right.
int *a;
PAS_MiddleAlign pointer in the middle.
int * a;
Definition at line 3684 of file Format.h.
◆ PPDirectiveIndentStyleOptions for indenting preprocessor directives.
Enumerator PPDIS_NoneDoes not indent any directives.
#if FOO
#if BAR
#include <foo>
#endif
#endif
PPDIS_AfterHashIndents directives after the hash.
#if FOO
# if BAR
# include <foo>
# endif
#endif
PPDIS_BeforeHashIndents directives before the hash.
#if FOO
#if BAR
#include <foo>
#endif
#endif
Definition at line 2876 of file Format.h.
◆ QualifierAlignmentStyleDifferent specifiers and qualifiers alignment styles.
Enumerator QAS_LeaveDon't change specifiers/qualifiers to either Left or Right alignment (default).
int const a;
const int *a;
QAS_LeftChange specifiers/qualifiers to be left-aligned.
const int a;
const int *a;
QAS_RightChange specifiers/qualifiers to be right-aligned.
int const a;
int const *a;
QAS_CustomChange specifiers/qualifiers to be aligned based on QualifierOrder
.
With:
QualifierOrder: [inline, static, type, const]
int const a;
int const *a;
Definition at line 3722 of file Format.h.
◆ ReferenceAlignmentStyleThe &
and &&
alignment style.
Align reference like PointerAlignment
.
Align reference to the left.
int& a;
RAS_RightAlign reference to the right.
int &a;
RAS_MiddleAlign reference in the middle.
int & a;
Definition at line 3854 of file Format.h.
◆ ReflowCommentsStyleTypes of comment reflow style.
Enumerator RCS_NeverLeave comments untouched.
RCS_IndentOnlyOnly apply indentation rules, moving comments left or right, without changing formatting inside the comments.
RCS_AlwaysApply indentation rules and reflow long comments into new lines, trying to obey the ColumnLimit
.
Definition at line 3881 of file Format.h.
◆ RemoveParenthesesStyleTypes of redundant parentheses to remove.
Enumerator RPS_LeaveDo not remove parentheses.
class__declspec((dllimport))
X{};
co_return (((0)));
return((a +
b) - ((
c+ d)));
X#define X(type, name)
Definition: Value.h:144 RPS_MultipleParenthesesReplace multiple parentheses with single parentheses.
class __declspec(dllimport) X{};
co_return (0);
return((a +
b) - (
c+ d));
RPS_ReturnStatementAlso remove parentheses enclosing the expression in a return
/co_return
statement.
{};
co_return 0;
return(a +
b) - (
c+ d);
Definition at line 3995 of file Format.h.
◆ RequiresClausePositionStyleThe possible positions for the requires clause.
The IndentRequires
option is only used if the requires
is put on the start of a line.
Always put the requires
clause on its own line (possibly followed by a semicolon).
template <typename T>
requires C<T>
struct Foo {...
template <
typename T>
void bar(T t)
requires C<T>;
template <typename T>
requires C<T>
void bar(T t) {...
template <
typename T>
void baz(T t)
requires C<T>
{...
RCPS_OwnLineWithBraceAs with OwnLine
, except, unless otherwise prohibited, place a following open brace (of a function definition) to follow on the same line.
bar(
Tt)
requires C<T> {
return;
}
voidbar(
Tt)
requires C<T> {}
template <typename T>
requires C<T>
voidbaz(
Tt) {
...
RCPS_WithPrecedingTry to put the clause together with the preceding part of a declaration.
For class templates: stick to the template declaration. For function templates: stick to the template declaration. For function declaration followed by a requires clause: stick to the parameter list.
template <typename T> requires C<T>
struct Foo {...
template <
typename T>
requiresC<T>
void bar(T t) {...
template <
typename T>
void baz(T t) requires C<T>
{...
RCPS_WithFollowingTry to put the requires
clause together with the class or function declaration.
template <typename T>
requires C<T> struct Foo {...
template <
typename T>
requires C<T> void bar(T t) {...
template <
typename T>
void baz(T t)
requires C<T> {...
RCPS_SingleLineTry to put everything in the same line if possible.
Otherwise normal line breaking rules take over.
template <typename T> requires C<T> struct Foo {...
template <
typename T>
requiresC<T>
voidbar(T t) {...
template <
typename T>
voidbar(T t)
requiresC<T> {...
template <typename LongName>
requires C<LongName>
struct Foo {...
template <typename LongName>
requires C<LongName>
void bar(LongName ln) {
template <typename LongName>
void bar(LongName ln)
requires C<LongName> {
Definition at line 4051 of file Format.h.
◆ RequiresExpressionIndentationKindIndentation logic for requires expression bodies.
Enumerator REI_OuterScopeAlign requires expression body relative to the indentation level of the outer scope the requires expression resides in.
This is the default.
template <typename T>
concept C=
requires(
Tt) {
...
}
REI_KeywordAlign requires expression body relative to the requires
keyword.
template <typename T>
concept C=
requires(
Tt) {
...
}
Definition at line 4153 of file Format.h.
◆ ReturnTypeBreakingStyleDifferent ways to break after the function definition or declaration return type.
Enumerator RTBS_NoneThis is deprecated. See Automatic
below.
Break after return type based on PenaltyReturnTypeOnItsOwnLine
.
class A {
int f() { return 0; };
};
int f();
int f() { return 1; }
int
LongName::AnotherLongName();
RTBS_ExceptShortTypeSame as Automatic
above, except that there is no break after short return types.
class A {
int f() { return 0; };
};
int f();
int f() { return 1; }
int LongName::
AnotherLongName();
RTBS_AllAlways break after the return type.
class A {
int
f() {
return 0;
};
};
int
f();
int
f() {
return 1;
}
int
LongName::AnotherLongName();
RTBS_TopLevelAlways break after the return types of top-level functions.
class A {
int f() { return 0; };
};
int
f();
int
f() {
return 1;
}
int
LongName::AnotherLongName();
RTBS_AllDefinitionsAlways break after the return type of function definitions.
class A {
int
f() {
return 0;
};
};
int f();
int
f() {
return 1;
}
int
LongName::AnotherLongName();
RTBS_TopLevelDefinitionsAlways break after the return type of top-level definitions.
class A {
int f() { return 0; };
};
int f();
int
f() {
return 1;
}
int
LongName::AnotherLongName();
Definition at line 1009 of file Format.h.
◆ SeparateDefinitionStyleThe style if definition blocks should be separated.
Enumerator SDS_LeaveLeave definition blocks as they are.
SDS_AlwaysInsert an empty line between definition blocks.
SDS_NeverRemove any empty line between definition blocks.
Definition at line 4179 of file Format.h.
◆ ShortBlockStyleDifferent styles for merging short blocks containing at most one statement.
Enumerator SBS_NeverNever merge blocks into a single line.
while (true) {
}
while (true) {
continue;
}
SBS_EmptyOnly merge empty blocks.
while (true) {}
while (true) {
continue;
}
SBS_AlwaysAlways merge short blocks into a single line.
while (true) {}
while (true) { continue; }
Definition at line 737 of file Format.h.
◆ ShortFunctionStyleDifferent styles for merging short functions containing at most one statement.
Enumerator SFS_NoneNever merge functions into a single line.
SFS_InlineOnlyOnly merge functions defined inside a class.
Same as inline
, except it does not implies empty
: i.e. top level empty functions are not merged either.
class Foo {
void f() { foo(); }
};
void f() {
foo();
}
void f() {
}
SFS_EmptyOnly merge empty functions.
void f() {}
void f2() {
bar2();
}
SFS_InlineOnly merge functions defined inside a class.
Implies empty
.
class Foo {
void f() { foo(); }
};
void f() {
foo();
}
void f() {}
SFS_AllMerge all functions fitting on a single line.
class Foo {
void f() { foo(); }
};
void f() { bar(); }
Definition at line 830 of file Format.h.
◆ ShortIfStyleDifferent styles for handling short if statements.
Enumerator SIS_NeverNever put short ifs on the same line.
if (a)
return;
if(
b)
return;
else
return;
if(
c)
return;
else {
return;
}
SIS_WithoutElsePut short ifs on the same line only if there is no else statement.
if (a) return;
if(
b)
return;
else
return;
if(
c)
return;
else {
return;
}
SIS_OnlyFirstIfPut short ifs, but not else ifs nor else statements, on the same line.
if (a) return;
if(
b)
return;
else if(
b)
return;
else
return;
if(
c)
return;
else {
return;
}
SIS_AllIfsAndElseAlways put short ifs, else ifs and else statements on the same line.
if (a) return;
if(
b)
return;
else return;
if(
c)
return;
else {
return;
}
Definition at line 882 of file Format.h.
◆ ShortLambdaStyleDifferent styles for merging short lambdas containing at most one statement.
Enumerator SLS_NoneNever merge lambdas into a single line.
SLS_EmptyOnly merge empty lambdas.
auto lambda = [](int a) {};
auto lambda2 = [](int a) {
return a;
};
SLS_InlineMerge lambda into a single line if the lambda is argument of a function.
auto lambda = [](int x, int y) {
return x < y;
};
sort(a.begin(), a.end(), [](int x, int y) { return x < y; });
SLS_AllMerge all lambdas fitting on a single line.
auto lambda = [](int a) {};
auto lambda2 = [](int a) { return a; };
Definition at line 954 of file Format.h.
◆ SortIncludesOptionsInclude sorting options.
Enumerator SI_NeverIncludes are never sorted.
#include "B/A.h"
#include "A/B.h"
#include "a/b.h"
#include "A/b.h"
#include "B/a.h"
SI_CaseSensitiveIncludes are sorted in an ASCIIbetical or case sensitive fashion.
#include "A/B.h"
#include "A/b.h"
#include "B/A.h"
#include "B/a.h"
#include "a/b.h"
SI_CaseInsensitiveIncludes are sorted in an alphabetical or case insensitive fashion.
#include "A/B.h"
#include "A/b.h"
#include "a/b.h"
#include "B/A.h"
#include "B/a.h"
Definition at line 4263 of file Format.h.
◆ SortJavaStaticImportOptionsPosition for Java Static imports.
Enumerator SJSIO_BeforeStatic imports are placed before non-static imports.
import static org.example.function1;
import org.example.ClassA;
SJSIO_AfterStatic imports are placed after non-static imports.
import org.example.ClassA;
import static org.example.function1;
Definition at line 4298 of file Format.h.
◆ SortUsingDeclarationsOptionsUsing declaration sorting options.
Enumerator SUD_NeverUsing declarations are never sorted.
using std::chrono::duration_cast;
using std::move;
using boost::regex;
using boost::regex_constants::icase;
using std::string;
SUD_LexicographicUsing declarations are sorted in the order defined as follows: Split the strings by ::
and discard any initial empty strings.
Sort the lists of names lexicographically, and within those groups, names are in case-insensitive lexicographic order.
using boost::regex;
using boost::regex_constants::icase;
using std::chrono::duration_cast;
using std::move;
using std::string;
SUD_LexicographicNumericUsing declarations are sorted in the order defined as follows: Split the strings by ::
and discard any initial empty strings.
The last element of each list is a non-namespace name; all others are namespace names. Sort the lists of names lexicographically, where the sort order of individual names is that all non-namespace names come before all namespace names, and within those groups, names are in case-insensitive lexicographic order.
using boost::regex;
using boost::regex_constants::icase;
using std::move;
using std::string;
using std::chrono::duration_cast;
Definition at line 4322 of file Format.h.
◆ SpaceAroundPointerQualifiersStyleDifferent ways to put a space before opening parentheses.
Definition at line 4390 of file Format.h.
◆ SpaceBeforeParensStyleDifferent ways to put a space before opening parentheses.
Enumerator SBPO_NeverThis is deprecated and replaced by Custom
below, with all SpaceBeforeParensOptions
but AfterPlacementOperator
set to false
.
Put a space before opening parentheses only after control statement keywords (for/if/while...
).
void f() {
if (true) {
f();
}
}
SBPO_ControlStatementsExceptControlMacrosSame as SBPO_ControlStatements
except this option doesn't apply to ForEach and If macros.
This is useful in projects where ForEach/If macros are treated as function calls instead of control statements. SBPO_ControlStatementsExceptForEachMacros
remains an alias for backward compatibility.
void f() {
Q_FOREACH(...) {
f();
}
}
SBPO_NonEmptyParenthesesPut a space before opening parentheses only if the parentheses are not empty.
void() {
if (true) {
f();
g (x, y, z);
}
}
SBPO_AlwaysAlways put a space before opening parentheses, except when it's prohibited by the syntax rules (in function-like macro definitions) or when determined by other style rules (after unary operators, opening parentheses, etc.)
void f () {
if (true) {
f ();
}
}
SBPO_CustomConfigure each individual space before parentheses in SpaceBeforeParensOptions
.
Definition at line 4482 of file Format.h.
◆ SpacesInAnglesStyleStyles for adding spacing after <
and before >
in template argument lists.
Remove spaces after <
and before >
.
static_cast<int>(arg);
std::function<void(int)> fct;
SIAS_AlwaysAdd spaces after <
and before >
.
static_cast< int >(arg);
std::function< void(int) > fct;
SIAS_LeaveKeep a single space after <
and before >
if any spaces were present.
Option Standard: Cpp03
takes precedence.
Definition at line 4724 of file Format.h.
◆ SpacesInParensStyleDifferent ways to put a space before opening and closing parentheses.
Enumerator SIPO_NeverNever put a space in parentheses.
void f() {
if(true) {
f();
}
}
SIPO_CustomConfigure each individual space in parentheses in SpacesInParensOptions
.
Definition at line 4812 of file Format.h.
◆ TrailingCommaStyleThe style of inserting trailing commas into container literals.
Enumerator TCS_NoneDo not insert trailing commas.
TCS_WrappedInsert trailing commas in container literals that were wrapped over multiple lines.
Note that this is conceptually incompatible with bin-packing, because the trailing comma is used as an indicator that a container should be formatted one-per-line (i.e. not bin-packed). So inserting a trailing comma counteracts bin-packing.
Definition at line 2998 of file Format.h.
◆ TrailingCommentsAlignmentKindsEnums for AlignTrailingComments.
Enumerator TCAS_LeaveLeave trailing comments as they are.
int a;
int ab;
int abc;
int abcd;
TCAS_AlwaysAlign trailing comments.
int a;
int ab;
int abc;
int abcd;
TCAS_NeverDon't align trailing comments but other formatter applies.
int a;
int ab;
int abc;
int abcd;
Definition at line 568 of file Format.h.
◆ UseTabStyleThis option is deprecated.
See LF
and CRLF
of LineEnding
.
Never use tab.
UT_ForIndentationUse tabs only for indentation.
UT_ForContinuationAndIndentationFill all leading whitespace with tabs, and use spaces for alignment that appears within a line (e.g.
consecutive assignments and declarations).
UT_AlignWithSpacesUse tabs for line continuation and indentation, and spaces for alignment.
UT_AlwaysUse tabs whenever we need to fill whitespace that spans at least from one tab stop to the next one.
Definition at line 5105 of file Format.h.
◆ WrapNamespaceBodyWithEmptyLinesStyleDifferent styles for wrapping namespace body with empty lines.
Enumerator WNBWELS_NeverRemove all empty lines at the beginning and the end of namespace body.
namespace N1 {
namespace N2
function();
}
}
WNBWELS_AlwaysAlways have at least one empty line at the beginning and the end of namespace body except that the number of empty lines between consecutive nested namespace definitions is not increased.
namespace N1 {
namespace N2 {
function();
}
}
WNBWELS_LeaveKeep existing newlines at the beginning and the end of namespace body.
MaxEmptyLinesToKeep
still applies.
Definition at line 5166 of file Format.h.
◆ BuildStyleSetFromConfiguration() ◆ GetLanguageStyle() ◆ isCpp() bool clang::format::FormatStyle::isCpp ( ) const inline ◆ isCSharp() bool clang::format::FormatStyle::isCSharp ( ) const inline ◆ isJavaScript() bool clang::format::FormatStyle::isJavaScript ( ) const inline ◆ isJson() bool clang::format::FormatStyle::isJson ( ) const inline ◆ isProto() bool clang::format::FormatStyle::isProto ( ) const inline ◆ isTableGen() bool clang::format::FormatStyle::isTableGen ( ) const inline ◆ isVerilog() bool clang::format::FormatStyle::isVerilog ( ) const inline ◆ operator==() bool clang::format::FormatStyle::operator== ( const FormatStyle & R ) const inlineDefinition at line 5198 of file Format.h.
References AccessModifierOffset, AlignAfterOpenBracket, AlignArrayOfStructures, AlignConsecutiveAssignments, AlignConsecutiveBitFields, AlignConsecutiveDeclarations, AlignConsecutiveMacros, AlignConsecutiveShortCaseStatements, AlignConsecutiveTableGenBreakingDAGArgColons, AlignConsecutiveTableGenCondOperatorColons, AlignConsecutiveTableGenDefinitionColons, AlignEscapedNewlines, AlignOperands, AlignTrailingComments, AllowAllArgumentsOnNextLine, AllowAllParametersOfDeclarationOnNextLine, AllowBreakBeforeNoexceptSpecifier, AllowShortBlocksOnASingleLine, AllowShortCaseExpressionOnASingleLine, AllowShortCaseLabelsOnASingleLine, AllowShortCompoundRequirementOnASingleLine, AllowShortEnumsOnASingleLine, AllowShortFunctionsOnASingleLine, AllowShortIfStatementsOnASingleLine, AllowShortLambdasOnASingleLine, AllowShortLoopsOnASingleLine, AllowShortNamespacesOnASingleLine, AlwaysBreakBeforeMultilineStrings, AttributeMacros, BinPackArguments, BinPackParameters, BitFieldColonSpacing, BracedInitializerIndentWidth, BreakAdjacentStringLiterals, BreakAfterAttributes, BreakAfterJavaFieldAnnotations, BreakAfterReturnType, BreakArrays, BreakBeforeBinaryOperators, BreakBeforeBraces, BreakBeforeConceptDeclarations, BreakBeforeInlineASMColon, BreakBeforeTernaryOperators, BreakBinaryOperations, BreakConstructorInitializers, BreakFunctionDefinitionParameters, BreakInheritanceList, BreakStringLiterals, BreakTemplateDeclarations, ColumnLimit, CommentPragmas, CompactNamespaces, ConstructorInitializerIndentWidth, ContinuationIndentWidth, Cpp11BracedListStyle, DerivePointerAlignment, DisableFormat, EmptyLineAfterAccessModifier, EmptyLineBeforeAccessModifier, ExperimentalAutoDetectBinPacking, FixNamespaceComments, ForEachMacros, clang::tooling::IncludeStyle::IncludeBlocks, clang::tooling::IncludeStyle::IncludeCategories, clang::tooling::IncludeStyle::IncludeIsMainRegex, clang::tooling::IncludeStyle::IncludeIsMainSourceRegex, IncludeStyle, IndentAccessModifiers, IndentCaseBlocks, IndentCaseLabels, IndentExportBlock, IndentExternBlock, IndentGotoLabels, IndentPPDirectives, IndentRequiresClause, IndentWidth, IndentWrappedFunctionNames, InsertBraces, InsertNewlineAtEOF, IntegerLiteralSeparator, JavaImportGroups, JavaScriptQuotes, JavaScriptWrapImports, KeepEmptyLines, KeepFormFeed, LambdaBodyIndentation, Language, LineEnding, MacroBlockBegin, MacroBlockEnd, Macros, clang::tooling::IncludeStyle::MainIncludeChar, MaxEmptyLinesToKeep, clang::format::FormatStyle::SpacesInLineComment::Maximum, clang::format::FormatStyle::SpacesInLineComment::Minimum, NamespaceIndentation, NamespaceMacros, ObjCBinPackProtocolList, ObjCBlockIndentWidth, ObjCBreakBeforeNestedBlockParam, ObjCPropertyAttributeOrder, ObjCSpaceAfterProperty, ObjCSpaceBeforeProtocolList, PackConstructorInitializers, PenaltyBreakAssignment, PenaltyBreakBeforeFirstCallParameter, PenaltyBreakBeforeMemberAccess, PenaltyBreakComment, PenaltyBreakFirstLessLess, PenaltyBreakOpenParenthesis, PenaltyBreakScopeResolution, PenaltyBreakString, PenaltyBreakTemplateDeclaration, PenaltyExcessCharacter, PenaltyReturnTypeOnItsOwnLine, PointerAlignment, QualifierAlignment, QualifierOrder, RawStringFormats, ReferenceAlignment, RemoveBracesLLVM, RemoveEmptyLinesInUnwrappedLines, RemoveParentheses, RemoveSemicolon, RequiresClausePosition, RequiresExpressionIndentation, SeparateDefinitionBlocks, ShortNamespaceLines, SkipMacroDefinitionBody, SortIncludes, SortJavaStaticImport, SpaceAfterCStyleCast, SpaceAfterLogicalNot, SpaceAfterTemplateKeyword, SpaceAroundPointerQualifiers, SpaceBeforeAssignmentOperators, SpaceBeforeCaseColon, SpaceBeforeCpp11BracedList, SpaceBeforeCtorInitializerColon, SpaceBeforeInheritanceColon, SpaceBeforeJsonColon, SpaceBeforeParens, SpaceBeforeParensOptions, SpaceBeforeRangeBasedForLoopColon, SpaceBeforeSquareBrackets, SpaceInEmptyBlock, SpacesBeforeTrailingComments, SpacesInAngles, SpacesInContainerLiterals, SpacesInLineCommentPrefix, SpacesInParens, SpacesInParensOptions, SpacesInSquareBrackets, Standard, StatementAttributeLikeMacros, StatementMacros, TableGenBreakingDAGArgOperators, TableGenBreakInsideDAGArg, TabWidth, TemplateNames, TypenameMacros, TypeNames, UseTab, VariableTemplates, VerilogBreakBetweenInstancePorts, WhitespaceSensitiveMacros, and WrapNamespaceBodyWithEmptyLines.
◆ parseConfiguration std::error_code parseConfiguration ( llvm::MemoryBufferRef Config, FormatStyle * Style, bool AllowUnknownOptions =false
, llvm::SourceMgr::DiagHandlerTy DiagHandler = nullptr
, void * DiagHandlerCtxt = nullptr
) friend
Parse configuration from YAML-formatted text.
Style->Language is used to get the base style, if the BasedOnStyle
option is present.
The FormatStyleSet of Style is reset.
When BasedOnStyle
is not present, options not present in the YAML document, are retained in Style
.
If AllowUnknownOptions is true, no errors are emitted if unknown format options are occurred.
If set all diagnostics are emitted through the DiagHandler.
Definition at line 2073 of file Format.cpp.
Referenced by clang::format::getStyle(), and clang::format::loadAndParseConfigFile().
◆ AccessModifierOffset int clang::format::FormatStyle::AccessModifierOffset ◆ AlignAfterOpenBracket ◆ AlignArrayOfStructures ◆ AlignConsecutiveAssignments ◆ AlignConsecutiveBitFields ◆ AlignConsecutiveDeclarations ◆ AlignConsecutiveMacros ◆ AlignConsecutiveShortCaseStatements ◆ AlignConsecutiveTableGenBreakingDAGArgColons ◆ AlignConsecutiveTableGenCondOperatorColons ◆ AlignConsecutiveTableGenDefinitionColons ◆ AlignEscapedNewlines ◆ AlignOperands ◆ AlignTrailingComments ◆ AllowAllArgumentsOnNextLine bool clang::format::FormatStyle::AllowAllArgumentsOnNextLine ◆ AllowAllParametersOfDeclarationOnNextLine bool clang::format::FormatStyle::AllowAllParametersOfDeclarationOnNextLineThis option is deprecated.
See NextLine
of PackConstructorInitializers
.
BinPackParameters
is OnePerLine
.
true:
void myFunction(
inta,
int b,
int c,
intd,
inte);
false:
void myFunction(int a,
int d,
int e);
Definition at line 692 of file Format.h.
Referenced by clang::format::getChromiumStyle(), clang::format::getLLVMStyle(), clang::format::getMozillaStyle(), llvm::yaml::MappingTraits< FormatStyle >::mapping(), and operator==().
◆ AllowBreakBeforeNoexceptSpecifier ◆ AllowShortBlocksOnASingleLine ◆ AllowShortCaseExpressionOnASingleLine bool clang::format::FormatStyle::AllowShortCaseExpressionOnASingleLine ◆ AllowShortCaseLabelsOnASingleLine bool clang::format::FormatStyle::AllowShortCaseLabelsOnASingleLine ◆ AllowShortCompoundRequirementOnASingleLine bool clang::format::FormatStyle::AllowShortCompoundRequirementOnASingleLine ◆ AllowShortEnumsOnASingleLine bool clang::format::FormatStyle::AllowShortEnumsOnASingleLine ◆ AllowShortFunctionsOnASingleLine ◆ AllowShortIfStatementsOnASingleLine ShortIfStyle clang::format::FormatStyle::AllowShortIfStatementsOnASingleLine ◆ AllowShortLambdasOnASingleLine ◆ AllowShortLoopsOnASingleLine bool clang::format::FormatStyle::AllowShortLoopsOnASingleLine ◆ AllowShortNamespacesOnASingleLine bool clang::format::FormatStyle::AllowShortNamespacesOnASingleLine ◆ AlwaysBreakAfterDefinitionReturnType ◆ AlwaysBreakBeforeMultilineStrings bool clang::format::FormatStyle::AlwaysBreakBeforeMultilineStrings ◆ AttributeMacros std::vector<std::string> clang::format::FormatStyle::AttributeMacrosThis option is renamed to BreakTemplateDeclarations
.
A vector of strings that should be interpreted as attributes/qualifiers instead of identifiers. This can be useful for language extensions or static analyzer annotations.
For example:
x = (char *__capability)&y;
int function(void) __unused;
void only_writes_to_buffer(char *__output buffer);
In the .clang-format configuration file, this can be configured like:
AttributeMacros: [__capability, __output, __unused]
Definition at line 1194 of file Format.h.
Referenced by clang::format::getLLVMStyle(), llvm::yaml::MappingTraits< FormatStyle >::mapping(), and operator==().
◆ BinPackArguments bool clang::format::FormatStyle::BinPackArguments ◆ BinPackParameters ◆ BitFieldColonSpacing ◆ BracedInitializerIndentWidth std::optional<unsigned> clang::format::FormatStyle::BracedInitializerIndentWidthThe number of columns to use to indent the contents of braced init lists.
If unset, ContinuationIndentWidth
is used.
void f() {
"foo",
"bar",
"baz",
};
.foo = "foo",
.bar = "bar",
.baz = "baz",
};
SomeArrayT a[3] = {
{
foo,
bar,
},
{
foo,
bar,
},
SomeArrayT{},
};
}
__device__ __2f16 float __ockl_bool s
std::optional< unsigned > BracedInitializerIndentWidth
The number of columns to use to indent the contents of braced init lists.
BracketAlignmentStyle AlignAfterOpenBracket
If true, horizontally aligns arguments after an open bracket.
Definition at line 1306 of file Format.h.
Referenced by clang::format::getLLVMStyle(), llvm::yaml::MappingTraits< FormatStyle >::mapping(), and operator==().
◆ BraceWrapping ◆ BreakAdjacentStringLiterals bool clang::format::FormatStyle::BreakAdjacentStringLiterals ◆ BreakAfterAttributes ◆ BreakAfterJavaFieldAnnotations bool clang::format::FormatStyle::BreakAfterJavaFieldAnnotations ◆ BreakAfterReturnType ◆ BreakArrays bool clang::format::FormatStyle::BreakArrays ◆ BreakBeforeBinaryOperators ◆ BreakBeforeBraces ◆ BreakBeforeConceptDeclarations ◆ BreakBeforeInlineASMColon ◆ BreakBeforeTernaryOperators bool clang::format::FormatStyle::BreakBeforeTernaryOperators ◆ BreakBinaryOperations ◆ BreakConstructorInitializers ◆ BreakFunctionDefinitionParameters bool clang::format::FormatStyle::BreakFunctionDefinitionParameters ◆ BreakInheritanceList ◆ BreakStringLiterals bool clang::format::FormatStyle::BreakStringLiteralsAllow breaking string literals when formatting.
In C, C++, and Objective-C:
true:
const char* x = "veryVeryVeryVeryVeryVe"
"ryVeryVeryVeryVeryVery"
"VeryLongString";
false:
const char* x =
"veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongString";
In C# and Java:
true:
string x = "veryVeryVeryVeryVeryVe" +
"ryVeryVeryVeryVeryVery" +
"VeryLongString";
false:
string x =
"veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongString";
C# interpolated strings are not broken.
In Verilog:
true:
string x = {"veryVeryVeryVeryVeryVe",
"ryVeryVeryVeryVeryVery",
"VeryLongString"};
false:
string x =
"veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongString";
Definition at line 2400 of file Format.h.
Referenced by clang::format::getGoogleStyle(), clang::format::getLLVMStyle(), llvm::yaml::MappingTraits< FormatStyle >::mapping(), and operator==().
◆ BreakTemplateDeclarations ◆ ColumnLimit unsigned clang::format::FormatStyle::ColumnLimitThe column limit.
A column limit of 0
means that there is no column limit. In this case, clang-format will respect the input's line breaking decisions within statements unless they contradict other rules.
Definition at line 2408 of file Format.h.
Referenced by clang::tooling::applyAtomicChanges(), clang::format::BreakableBlockComment::BreakableBlockComment(), clang::format::CommaSeparatedList::formatAfterToken(), clang::format::getChromiumStyle(), clang::format::ContinuationIndenter::getColumnLimit(), clang::format::getGNUStyle(), clang::format::getGoogleStyle(), clang::format::getLLVMStyle(), clang::format::getMicrosoftStyle(), clang::format::getWebKitStyle(), llvm::yaml::MappingTraits< FormatStyle >::mapping(), clang::format::ContinuationIndenter::mustBreak(), operator==(), clang::format::CommaSeparatedList::precomputeFormattingInfos(), and clang::format::RawStringFormatStyleManager::RawStringFormatStyleManager().
◆ CommentPragmas std::string clang::format::FormatStyle::CommentPragmas ◆ CompactNamespaces bool clang::format::FormatStyle::CompactNamespaces ◆ ConstructorInitializerIndentWidth unsigned clang::format::FormatStyle::ConstructorInitializerIndentWidth ◆ ContinuationIndentWidth unsigned clang::format::FormatStyle::ContinuationIndentWidth ◆ Cpp11BracedListStyle bool clang::format::FormatStyle::Cpp11BracedListStyleIf true
, format braced lists as best suited for C++11 braced lists.
Important differences:
Fundamentally, C++11 braced lists are formatted exactly like function calls would be formatted in their place. If the braced list follows a name (e.g. a type or variable name), clang-format formats as if the {}
were the parentheses of a function call with that name. If there is no name, a zero-length name is assumed.
true: false:
vector<int> x{1, 2, 3, 4}; vs. vector<int> x{ 1, 2, 3, 4 };
vector<T> x{{}, {}, {}, {}}; vector<T> x{ {}, {}, {}, {} };
f(MyMap[{composite, key}]); f(MyMap[{ composite, key }]);
new int[3]{1, 2, 3}; new int[3]{ 1, 2, 3 };
Definition at line 2531 of file Format.h.
Referenced by clang::format::BreakableStringLiteralUsingOperators::BreakableStringLiteralUsingOperators(), clang::format::getGNUStyle(), clang::format::getGoogleStyle(), clang::format::getLLVMStyle(), clang::format::getMozillaStyle(), clang::format::getWebKitStyle(), llvm::yaml::MappingTraits< FormatStyle >::mapping(), operator==(), and clang::format::CommaSeparatedList::precomputeFormattingInfos().
◆ DerivePointerAlignment bool clang::format::FormatStyle::DerivePointerAlignment ◆ DisableFormat bool clang::format::FormatStyle::DisableFormat ◆ EmptyLineAfterAccessModifier ◆ EmptyLineBeforeAccessModifier ◆ ExperimentalAutoDetectBinPacking bool clang::format::FormatStyle::ExperimentalAutoDetectBinPackingIf true
, clang-format detects whether function calls and definitions are formatted with one parameter per line.
Each call can be bin-packed, one-per-line or inconclusive. If it is inconclusive, e.g. completely on one line, but a decision needs to be made, clang-format analyzes whether there are other bin-packed cases in the input file and act accordingly.
Definition at line 2677 of file Format.h.
Referenced by clang::format::getLLVMStyle(), llvm::yaml::MappingTraits< FormatStyle >::mapping(), and operator==().
◆ FixNamespaceComments bool clang::format::FormatStyle::FixNamespaceComments ◆ ForEachMacros std::vector<std::string> clang::format::FormatStyle::ForEachMacros ◆ IfMacros std::vector<std::string> clang::format::FormatStyle::IfMacros ◆ IncludeStyle ◆ IndentAccessModifiers bool clang::format::FormatStyle::IndentAccessModifiersSpecify whether access modifiers should have their own indentation level.
When false
, access modifiers are indented (or outdented) relative to the record members, respecting the AccessModifierOffset
. Record members are indented one level below the record. When true
, access modifiers get their own indentation level. As a consequence, record members are always indented 2 levels below the record, regardless of the access modifier presence. Value of the AccessModifierOffset
is ignored.
false: true:
void bar(); void bar();
protected: protected:
}; };
public: public:
C(); C();
}; };
void foo() { void foo() {
return 1; return 1;
} }
Definition at line 2761 of file Format.h.
Referenced by clang::format::getLLVMStyle(), llvm::yaml::MappingTraits< FormatStyle >::mapping(), and operator==().
◆ IndentCaseBlocks bool clang::format::FormatStyle::IndentCaseBlocksIndent case label blocks one level from the case label.
When false
, the block following the case label uses the same indentation level as for the case label, treating the case label the same as an if-statement. When true
, the block gets indented as a scope block.
false: true:
switch (fool) { vs. switch (fool) {
case 1: { case 1:
bar(); {
} break; bar();
default: { }
plop(); break;
} default:
} {
plop();
}
}
Definition at line 2784 of file Format.h.
Referenced by clang::format::getLLVMStyle(), llvm::yaml::MappingTraits< FormatStyle >::mapping(), and operator==().
◆ IndentCaseLabels bool clang::format::FormatStyle::IndentCaseLabels ◆ IndentExportBlock bool clang::format::FormatStyle::IndentExportBlock ◆ IndentExternBlock ◆ IndentGotoLabels bool clang::format::FormatStyle::IndentGotoLabels ◆ IndentPPDirectives ◆ IndentRequiresClause bool clang::format::FormatStyle::IndentRequiresClause ◆ IndentWidth unsigned clang::format::FormatStyle::IndentWidth ◆ IndentWrappedFunctionNames bool clang::format::FormatStyle::IndentWrappedFunctionNames ◆ InheritsParentConfig bool clang::format::FormatStyle::InheritsParentConfig ◆ InsertBraces bool clang::format::FormatStyle::InsertBracesInsert braces after control statements (if
, else
, for
, do
, and while
) in C++ unless the control statements are inside macro definitions or the braces would enclose preprocessor directives.
true
could lead to incorrect code formatting due to clang-format's lack of complete semantic information. As such, extra care should be taken to review code changes made by this option. \endwarning
false: true:
if(isa<FunctionDecl>(
D)) vs.
if(isa<FunctionDecl>(
D)) {
handleFunctionDecl(
D); handleFunctionDecl(
D);
else if(isa<VarDecl>(
D)) }
else if(isa<VarDecl>(
D)) {
handleVarDecl(
D); handleVarDecl(
D);
else } else {
return; return;
}
while (i--) vs. while (i--) {
for(
auto*A :
D.attrs())
for(
auto*A :
D.attrs()) {
handleAttr(A); handleAttr(A);
}
}
do vs. do {
--i; --i;
while (i); } while (i);
Definition at line 2991 of file Format.h.
Referenced by clang::format::getClangFormatStyle(), clang::format::getLLVMStyle(), llvm::yaml::MappingTraits< FormatStyle >::mapping(), operator==(), and clang::format::internal::reformat().
◆ InsertNewlineAtEOF bool clang::format::FormatStyle::InsertNewlineAtEOF ◆ InsertTrailingCommas ◆ IntegerLiteralSeparator ◆ JavaImportGroups std::vector<std::string> clang::format::FormatStyle::JavaImportGroupsA vector of prefixes ordered by the desired groups for Java imports.
One group's prefix can be a subset of another - the longest prefix is always matched. Within a group, the imports are ordered lexicographically. Static imports are grouped separately and follow the same group rules. By default, static imports are placed before non-static imports, but this behavior is changed by another option, SortJavaStaticImport
.
In the .clang-format configuration file, this can be configured like in the following yaml example. This will result in imports being formatted as in the Java example below.
JavaImportGroups: [com.example, com, org]
import static com.example.function1;
import static com.test.function2;
import static org.example.function3;
import com.example.ClassA;
import com.example.Test;
import com.example.a.ClassB;
import com.test.ClassC;
import org.example.ClassD;
Definition at line 3138 of file Format.h.
Referenced by clang::format::findJavaImportGroup(), clang::format::getChromiumStyle(), llvm::yaml::MappingTraits< FormatStyle >::mapping(), operator==(), and clang::format::sortJavaImports().
◆ JavaScriptQuotes ◆ JavaScriptWrapImports bool clang::format::FormatStyle::JavaScriptWrapImports ◆ KeepEmptyLines ◆ KeepFormFeed bool clang::format::FormatStyle::KeepFormFeed ◆ LambdaBodyIndentation ◆ LanguageLanguage, this format style is targeted at.
Definition at line 3315 of file Format.h.
Referenced by clang::format::FormatStyle::FormatStyleSet::Add(), clang::format::BreakableBlockComment::BreakableBlockComment(), clang::format::cleanup(), llvm::yaml::DocumentListTraits< std::vector< FormatStyle > >::element(), clang::format::BreakableBlockComment::getContentIndent(), clang::format::getGoogleStyle(), clang::format::ContinuationIndenter::getInitialState(), clang::format::getLineCommentIndentPrefix(), clang::format::getLLVMStyle(), clang::format::getPredefinedStyle(), clang::format::getStyle(), clang::format::FormatTokenLexer::lex(), llvm::yaml::MappingTraits< FormatStyle >::mapping(), clang::format::ContinuationIndenter::mustBreak(), clang::format::opensProtoMessageField(), operator==(), clang::format::RawStringFormatStyleManager::RawStringFormatStyleManager(), clang::format::internal::reformat(), clang::format::sortIncludes(), clang::format::startsNextParameter(), and clang::format::TokenAnalyzer::TokenAnalyzer().
◆ LineEnding ◆ MacroBlockBegin std::string clang::format::FormatStyle::MacroBlockBeginA regular expression matching macros that start a block.
# With:
NS_TABLE_HEAD$"
NS_MAP_END|\
NS_TABLE_.*_END$"
NS_MAP_BEGIN
foo();
NS_MAP_END
NS_TABLE_HEAD
bar();
NS_TABLE_FOO_END
# Without:
NS_MAP_BEGIN
foo();
NS_MAP_END
NS_TABLE_HEAD
bar();
NS_TABLE_FOO_END
std::string MacroBlockBegin
A regular expression matching macros that start a block.
std::string MacroBlockEnd
A regular expression matching macros that end a block.
Definition at line 3360 of file Format.h.
Referenced by llvm::yaml::MappingTraits< FormatStyle >::mapping(), and operator==().
◆ MacroBlockEnd std::string clang::format::FormatStyle::MacroBlockEnd ◆ Macros std::vector<std::string> clang::format::FormatStyle::MacrosA list of macros of the form <definition>=<expansion> .
Code will be parsed with macros expanded, in order to determine how to interpret and format the macro arguments.
For example, the code:
will usually be interpreted as a call to a function A, and the multiplication expression will be formatted as a * b
.
If we specify the macro definition:
the code will now be parsed as a declaration of the variable b of type a*, and formatted as a* b
(depending on pointer-binding rules).
Features and restrictions:
A; -> x;
A(); -> y;
A(z); -> z;
Definition at line 3404 of file Format.h.
Referenced by llvm::yaml::MappingTraits< FormatStyle >::mapping(), and operator==().
◆ MaxEmptyLinesToKeep unsigned clang::format::FormatStyle::MaxEmptyLinesToKeep ◆ NamespaceIndentation ◆ NamespaceMacros std::vector<std::string> clang::format::FormatStyle::NamespaceMacros ◆ ObjCBinPackProtocolList BinPackStyle clang::format::FormatStyle::ObjCBinPackProtocolListControls bin-packing Objective-C protocol conformance list items into as few lines as possible when they go over ColumnLimit
.
If Auto
(the default), delegates to the value in BinPackParameters
. If that is BinPack
, bin-packs Objective-C protocol conformance list items into as few lines as possible whenever they go over ColumnLimit
.
If Always
, always bin-packs Objective-C protocol conformance list items into as few lines as possible whenever they go over ColumnLimit
.
If Never
, lays out Objective-C protocol conformance list items onto individual lines whenever they go over ColumnLimit
.
Always (or Auto, if BinPackParameters==BinPack):
@interface ccccccccccccc () <
ccccccccccccc, ccccccccccccc,
ccccccccccccc, ccccccccccccc> {
}
Never (or Auto, if BinPackParameters!=BinPack):
@interface ddddddddddddd () <
ddddddddddddd,
ddddddddddddd,
ddddddddddddd,
ddddddddddddd> {
}
Definition at line 3502 of file Format.h.
Referenced by clang::format::getGoogleStyle(), clang::format::getLLVMStyle(), llvm::yaml::MappingTraits< FormatStyle >::mapping(), and operator==().
◆ ObjCBlockIndentWidth unsigned clang::format::FormatStyle::ObjCBlockIndentWidth ◆ ObjCBreakBeforeNestedBlockParam bool clang::format::FormatStyle::ObjCBreakBeforeNestedBlockParam ◆ ObjCPropertyAttributeOrder std::vector<std::string> clang::format::FormatStyle::ObjCPropertyAttributeOrderThe order in which ObjC property attributes should appear.
Attributes in code will be sorted in the order specified. Any attributes encountered that are not mentioned in this array will be sorted last, in stable order. Comments between attributes will leave the attributes untouched.
ObjCPropertyAttributeOrder: [
class, direct,
atomic, nonatomic,
assign, retain, strong, copy, weak, unsafe_unretained,
readonly, readwrite, getter, setter,
nullable, nonnull, null_resettable, null_unspecified
]
Definition at line 3560 of file Format.h.
Referenced by llvm::yaml::MappingTraits< FormatStyle >::mapping(), clang::format::ObjCPropertyAttributeOrderFixer::ObjCPropertyAttributeOrderFixer(), operator==(), and clang::format::internal::reformat().
◆ ObjCSpaceAfterProperty bool clang::format::FormatStyle::ObjCSpaceAfterProperty ◆ ObjCSpaceBeforeProtocolList bool clang::format::FormatStyle::ObjCSpaceBeforeProtocolList ◆ PackConstructorInitializers ◆ PenaltyBreakAssignment unsigned clang::format::FormatStyle::PenaltyBreakAssignment ◆ PenaltyBreakBeforeFirstCallParameter unsigned clang::format::FormatStyle::PenaltyBreakBeforeFirstCallParameter ◆ PenaltyBreakBeforeMemberAccess unsigned clang::format::FormatStyle::PenaltyBreakBeforeMemberAccess ◆ PenaltyBreakComment unsigned clang::format::FormatStyle::PenaltyBreakComment ◆ PenaltyBreakFirstLessLess unsigned clang::format::FormatStyle::PenaltyBreakFirstLessLess ◆ PenaltyBreakOpenParenthesis unsigned clang::format::FormatStyle::PenaltyBreakOpenParenthesis ◆ PenaltyBreakScopeResolution unsigned clang::format::FormatStyle::PenaltyBreakScopeResolution ◆ PenaltyBreakString unsigned clang::format::FormatStyle::PenaltyBreakString ◆ PenaltyBreakTemplateDeclaration unsigned clang::format::FormatStyle::PenaltyBreakTemplateDeclaration ◆ PenaltyExcessCharacter unsigned clang::format::FormatStyle::PenaltyExcessCharacter ◆ PenaltyIndentedWhitespace unsigned clang::format::FormatStyle::PenaltyIndentedWhitespace ◆ PenaltyReturnTypeOnItsOwnLine unsigned clang::format::FormatStyle::PenaltyReturnTypeOnItsOwnLine ◆ PointerAlignment ◆ PPIndentWidth int clang::format::FormatStyle::PPIndentWidth ◆ QualifierAlignment ◆ QualifierOrder std::vector<std::string> clang::format::FormatStyle::QualifierOrder ◆ RawStringFormatsDefines hints for detecting supported languages code blocks in raw strings.
A raw string with a matching delimiter or a matching enclosing function name will be reformatted assuming the specified language based on the style for that language defined in the .clang-format file. If no style has been defined in the .clang-format file for the specific language, a predefined style given by BasedOnStyle
is used. If BasedOnStyle
is not found, the formatting is based on LLVM
style. A matching delimiter takes precedence over a matching enclosing function name for determining the language of the raw string contents.
If a canonical delimiter is specified, occurrences of other delimiters for the same language will be updated to the canonical if possible.
There should be at most one specification per language and each delimiter and enclosing function should not occur in multiple specifications.
To configure this in the .clang-format file, use:
RawStringFormats:
- Language: TextProto
Delimiters:
- pb
- proto
EnclosingFunctions:
- PARSE_TEXT_PROTO
BasedOnStyle: google
- Language: Cpp
Delimiters:
- cc
- cpp
BasedOnStyle: LLVM
CanonicalDelimiter: cc
Definition at line 3851 of file Format.h.
Referenced by clang::format::getCanonicalRawStringDelimiter(), clang::format::getGoogleStyle(), llvm::yaml::MappingTraits< FormatStyle >::mapping(), operator==(), and clang::format::RawStringFormatStyleManager::RawStringFormatStyleManager().
◆ ReferenceAlignment ◆ ReflowComments ◆ RemoveBracesLLVM bool clang::format::FormatStyle::RemoveBracesLLVMRemove optional braces of control statements (if
, else
, for
, and while
) in C++ according to the LLVM coding style.
true
could lead to incorrect code formatting due to clang-format's lack of complete semantic information. As such, extra care should be taken to review code changes made by this option. \endwarning
false: true:
if(isa<FunctionDecl>(
D)) { vs.
if(isa<FunctionDecl>(
D))
handleFunctionDecl(
D); handleFunctionDecl(
D);
}
else if(isa<VarDecl>(
D)) {
else if(isa<VarDecl>(
D))
handleVarDecl(
D); handleVarDecl(
D);
}
if(isa<VarDecl>(
D)) { vs.
if(isa<VarDecl>(
D)) {
for(
auto*A :
D.attrs()) {
for(
auto*A :
D.attrs())
if (shouldProcessAttr(A)) { if (shouldProcessAttr(A))
handleAttr(A); handleAttr(A);
} }
}
}
if(isa<FunctionDecl>(
D)) { vs.
if(isa<FunctionDecl>(
D))
for(
auto*A :
D.attrs()) {
for(
auto*A :
D.attrs())
handleAttr(A); handleAttr(A);
}
}
if(
auto*
D= (
T)(
D)) { vs.
if(
auto*
D= (
T)(
D)) {
if(shouldProcess(
D)) {
if(shouldProcess(
D))
handleVarDecl(
D); handleVarDecl(
D);
} else { else
markAsIgnored(
D); markAsIgnored(
D);
} }
}
if (a) { vs. if (a)
d(); else
} else { e();
e();
}
}
Definition at line 3969 of file Format.h.
Referenced by clang::format::getClangFormatStyle(), clang::format::getLLVMStyle(), llvm::yaml::MappingTraits< FormatStyle >::mapping(), operator==(), and clang::format::internal::reformat().
◆ RemoveEmptyLinesInUnwrappedLines bool clang::format::FormatStyle::RemoveEmptyLinesInUnwrappedLines ◆ RemoveParentheses ◆ RemoveSemicolon bool clang::format::FormatStyle::RemoveSemicolon ◆ RequiresClausePosition ◆ RequiresExpressionIndentation ◆ SeparateDefinitionBlocksSpecifies the use of empty lines to separate definition blocks, including classes, structs, enums, and functions.
#include <cstring> #include <cstring>
struct Foo {
inta,
b,
c;
structFoo {
namespace Ns { };
class Bar {
public: namespace Ns {
struct Foobar { class Bar {
int a; public:
}; int a;
int t; };
int method1() {
} int t;
enum List {
ITEM1, int method1() {
ITEM2
}; }
template<typename T>
int method2(T x) { enum List {
} ITEM2
int i, j, k; };
int method3(int par) {
} int method2(T x) {
};
}
int i, j, k;
int method3(int par) {
}
};
}
Definition at line 4234 of file Format.h.
Referenced by clang::format::DefinitionBlockSeparator::analyze(), clang::format::getLLVMStyle(), llvm::yaml::MappingTraits< FormatStyle >::mapping(), operator==(), and clang::format::internal::reformat().
◆ ShortNamespaceLines unsigned clang::format::FormatStyle::ShortNamespaceLines ◆ SkipMacroDefinitionBody bool clang::format::FormatStyle::SkipMacroDefinitionBody ◆ SortIncludes ◆ SortJavaStaticImport ◆ SortUsingDeclarations ◆ SpaceAfterCStyleCast bool clang::format::FormatStyle::SpaceAfterCStyleCast ◆ SpaceAfterLogicalNot bool clang::format::FormatStyle::SpaceAfterLogicalNot ◆ SpaceAfterTemplateKeyword bool clang::format::FormatStyle::SpaceAfterTemplateKeyword ◆ SpaceAroundPointerQualifiers ◆ SpaceBeforeAssignmentOperators bool clang::format::FormatStyle::SpaceBeforeAssignmentOperators ◆ SpaceBeforeCaseColon bool clang::format::FormatStyle::SpaceBeforeCaseColon ◆ SpaceBeforeCpp11BracedList bool clang::format::FormatStyle::SpaceBeforeCpp11BracedListIf true
, a space will be inserted before a C++11 braced list used to initialize an object (after the preceding identifier or type).
true: false:
Foo foo { bar }; vs. Foo foo{ bar };
Foo {}; Foo{};
vector<int> { 1, 2, 3 }; vector<int>{ 1, 2, 3 };
new int[3] { 1, 2, 3 }; new int[3]{ 1, 2, 3 };
Definition at line 4451 of file Format.h.
Referenced by clang::format::getLLVMStyle(), clang::format::getWebKitStyle(), llvm::yaml::MappingTraits< FormatStyle >::mapping(), and operator==().
◆ SpaceBeforeCtorInitializerColon bool clang::format::FormatStyle::SpaceBeforeCtorInitializerColon ◆ SpaceBeforeInheritanceColon bool clang::format::FormatStyle::SpaceBeforeInheritanceColon ◆ SpaceBeforeJsonColon bool clang::format::FormatStyle::SpaceBeforeJsonColon ◆ SpaceBeforeParens ◆ SpaceBeforeParensOptions ◆ SpaceBeforeRangeBasedForLoopColon bool clang::format::FormatStyle::SpaceBeforeRangeBasedForLoopColon ◆ SpaceBeforeSquareBrackets bool clang::format::FormatStyle::SpaceBeforeSquareBrackets ◆ SpaceInEmptyBlock bool clang::format::FormatStyle::SpaceInEmptyBlock ◆ SpacesBeforeTrailingComments unsigned clang::format::FormatStyle::SpacesBeforeTrailingCommentsIf true
, spaces may be inserted into ()
.
This option is deprecated. See InEmptyParentheses
of SpacesInParensOptions
.
//
- comments).
This does not affect trailing block comments (/*
- comments) as those commonly have different usage patterns and a number of special cases. In the case of Verilog, it doesn't affect a comment right after the opening parenthesis in the port or parameter list in a module header, because it is probably for the port on the following line instead of the parenthesis it follows.
void f() {
if (true) {
f();
}
}
unsigned SpacesBeforeTrailingComments
If true, spaces may be inserted into ().
Definition at line 4720 of file Format.h.
Referenced by clang::format::NamespaceEndCommentsFixer::analyze(), clang::format::getGoogleStyle(), clang::format::getLLVMStyle(), llvm::yaml::MappingTraits< FormatStyle >::mapping(), and operator==().
◆ SpacesInAngles ◆ SpacesInContainerLiterals bool clang::format::FormatStyle::SpacesInContainerLiteralsIf true
, spaces will be inserted around if/for/switch/while conditions.
This option is deprecated. See InConditionalStatements
of SpacesInParensOptions
.
true
, spaces are inserted inside container literals (e.g. ObjC and Javascript array and dict literals). For JSON, use SpaceBeforeJsonColon
instead.
true: false:
var arr = [ 1, 2, 3 ]; vs. var arr = [1, 2, 3];
f({a : 1, b : 2, c : 3}); f({a: 1, b: 2, c: 3});
Definition at line 4761 of file Format.h.
Referenced by clang::format::getGoogleStyle(), clang::format::getLLVMStyle(), llvm::yaml::MappingTraits< FormatStyle >::mapping(), and operator==().
◆ SpacesInLineCommentPrefix ◆ SpacesInParens ◆ SpacesInParensOptions ◆ SpacesInSquareBrackets bool clang::format::FormatStyle::SpacesInSquareBrackets ◆ Standard ◆ StatementAttributeLikeMacros std::vector<std::string> clang::format::FormatStyle::StatementAttributeLikeMacrosMacros which are ignored in front of a statement, as if they were an attribute.
So that they are not parsed as identifier, for example for Qts emit.
unsigned char data = 'x';
unsigned char data = 'x';
static void emit(Program &P, std::vector< std::byte > &Code, const T &Val, bool &Success)
Helper to write bytecode and bail out if 32-bit offsets become invalid.
std::vector< std::string > StatementAttributeLikeMacros
Macros which are ignored in front of a statement, as if they were an attribute.
AlignConsecutiveStyle AlignConsecutiveDeclarations
Style of aligning consecutive declarations.
Definition at line 4994 of file Format.h.
Referenced by clang::format::getLLVMStyle(), llvm::yaml::MappingTraits< FormatStyle >::mapping(), and operator==().
◆ StatementMacros std::vector<std::string> clang::format::FormatStyle::StatementMacros ◆ TableGenBreakingDAGArgOperators std::vector<std::string> clang::format::FormatStyle::TableGenBreakingDAGArgOperatorsWorks only when TableGenBreakInsideDAGArg is not DontBreak.
The string list needs to consist of identifiers in TableGen. If any identifier is specified, this limits the line breaks by TableGenBreakInsideDAGArg option only on DAGArg values beginning with the specified identifiers.
For example the configuration,
TableGenBreakInsideDAGArg: BreakAll
TableGenBreakingDAGArgOperators: [ins, outs]
makes the line break only occurs inside DAGArgs beginning with the specified identifiers ins
and outs
.
let DAGArgIns = (ins
i32:$src1,
i32:$src2
);
let DAGArgOtherID = (other i32:$other1, i32:$other2);
let DAGArgBang = (!cast<SomeType>("Some") i32:$src1, i32:$src2)
Definition at line 5030 of file Format.h.
Referenced by clang::format::getLLVMStyle(), llvm::yaml::MappingTraits< FormatStyle >::mapping(), and operator==().
◆ TableGenBreakInsideDAGArg DAGArgStyle clang::format::FormatStyle::TableGenBreakInsideDAGArg ◆ TabWidth unsigned clang::format::FormatStyle::TabWidthThe number of columns used for tab stops.
Definition at line 5062 of file Format.h.
Referenced by clang::format::BreakableBlockComment::BreakableBlockComment(), clang::format::BreakableLineCommentSection::BreakableLineCommentSection(), clang::format::getLLVMStyle(), clang::format::getMicrosoftStyle(), clang::format::BreakableBlockComment::getRangeLength(), clang::format::BreakableLineCommentSection::getRangeLength(), clang::format::BreakableStringLiteral::getRemainingLength(), clang::format::BreakableStringLiteralUsingOperators::getRemainingLength(), clang::format::BreakableStringLiteral::getSplit(), clang::format::BreakableComment::getSplit(), clang::format::BreakableBlockComment::getSplit(), llvm::yaml::MappingTraits< FormatStyle >::mapping(), and operator==().
◆ TemplateNames std::vector<std::string> clang::format::FormatStyle::TemplateNames ◆ TypenameMacros std::vector<std::string> clang::format::FormatStyle::TypenameMacrosA vector of macros that should be interpreted as type declarations instead of as function calls.
These are expected to be macros of the form:
In the .clang-format configuration file, this can be configured like:
TypenameMacros: [STACK_OF, LIST]
For example: OpenSSL STACK_OF, BSD LIST_ENTRY.
Definition at line 5098 of file Format.h.
Referenced by llvm::yaml::MappingTraits< FormatStyle >::mapping(), and operator==().
◆ TypeNames std::vector<std::string> clang::format::FormatStyle::TypeNames ◆ UseTab ◆ VariableTemplates std::vector<std::string> clang::format::FormatStyle::VariableTemplates ◆ VerilogBreakBetweenInstancePorts bool clang::format::FormatStyle::VerilogBreakBetweenInstancePorts ◆ WhitespaceSensitiveMacros std::vector<std::string> clang::format::FormatStyle::WhitespaceSensitiveMacros ◆ WrapNamespaceBodyWithEmptyLinesThe documentation for this struct was generated from the following files:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4