clang  12.0.0git
Public Types | Public Attributes | List of all members
clang::format::FormatStyle Struct Reference

The FormatStyle is used to configure the formatting to follow specific guidelines. More...

#include "clang/Format/Format.h"

Collaboration diagram for clang::format::FormatStyle:
Collaboration graph
[legend]

Public Types

enum  BracketAlignmentStyle { BAS_Align, BAS_DontAlign, BAS_AlwaysBreak }
 Different styles for aligning after open brackets. More...
 
enum  EscapedNewlineAlignmentStyle { ENAS_DontAlign, ENAS_Left, ENAS_Right }
 Different styles for aligning escaped newlines. More...
 
enum  OperandAlignmentStyle { OAS_DontAlign, OAS_Align, OAS_AlignAfterOperator }
 Different styles for aligning operands. More...
 

Public Attributes

int AccessModifierOffset
 The extra indent or outdent of access modifiers, e.g. public:. More...
 
BracketAlignmentStyle AlignAfterOpenBracket
 If true, horizontally aligns arguments after an open bracket. More...
 
bool AlignConsecutiveMacros
 If true, aligns consecutive C/C++ preprocessor macros. More...
 
bool AlignConsecutiveAssignments
 If true, aligns consecutive assignments. More...
 
bool AlignConsecutiveBitFields
 If true, aligns consecutive bitfield members. More...
 
bool AlignConsecutiveDeclarations
 If true, aligns consecutive declarations. More...
 
EscapedNewlineAlignmentStyle AlignEscapedNewlines
 Options for aligning backslashes in escaped newlines. More...
 
OperandAlignmentStyle AlignOperands
 If true, horizontally align operands of binary and ternary expressions. More...
 
bool AlignTrailingComments
 If true, aligns trailing comments. More...
 
bool AllowAllArgumentsOnNextLine
 If a function call or braced initializer list doesn't fit on a line, allow putting all arguments onto the next line, even if BinPackArguments is false. More...
 

Detailed Description

The FormatStyle is used to configure the formatting to follow specific guidelines.

Definition at line 54 of file Format.h.

Member Enumeration Documentation

◆ BracketAlignmentStyle

Different styles for aligning after open brackets.

Enumerator
BAS_Align 

Align parameters on the open bracket, e.g.

:

someLongFunction(argument1,
argument2);
BAS_DontAlign 

Don't align, instead use ContinuationIndentWidth, e.g.

:

someLongFunction(argument1,
argument2);
BAS_AlwaysBreak 

Always break after an open bracket, if the parameters don't fit on a single line, e.g.

:

someLongFunction(
argument1, argument2);

Definition at line 59 of file Format.h.

◆ EscapedNewlineAlignmentStyle

Different styles for aligning escaped newlines.

Enumerator
ENAS_DontAlign 

Don't align escaped newlines.

#define A \
int aaaa; \
int b; \
int dddddddddd;
ENAS_Left 

Align escaped newlines as far left as possible.

true:
#define A \
int aaaa; \
int b; \
int dddddddddd;
false:
ENAS_Right 

Align escaped newlines in the right-most column.

#define A \
int aaaa; \
int b; \
int dddddddddd;

Definition at line 134 of file Format.h.

◆ OperandAlignmentStyle

Different styles for aligning operands.

Enumerator
OAS_DontAlign 

Do not align operands of binary and ternary expressions.

The wrapped lines are indented ContinuationIndentWidth spaces from the start of the line.

OAS_Align 

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.:

int aaa = bbbbbbbbbbbbbbb +
ccccccccccccccc;

When BreakBeforeBinaryOperators is set, the wrapped operator is aligned with the operand on the first line.

int aaa = bbbbbbbbbbbbbbb
+ ccccccccccccccc;
OAS_AlignAfterOperator 

Horizontally align operands of binary and ternary expressions.

This is similar to AO_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.

int aaa = bbbbbbbbbbbbbbb
+ ccccccccccccccc;

Definition at line 168 of file Format.h.

Member Data Documentation

◆ AccessModifierOffset

int clang::format::FormatStyle::AccessModifierOffset

The extra indent or outdent of access modifiers, e.g. public:.

Definition at line 56 of file Format.h.

Referenced by clang::format::getGoogleStyle(), clang::format::getLLVMStyle(), clang::format::getWebKitStyle(), and llvm::yaml::MappingTraits< FormatStyle >::mapping().

◆ AlignAfterOpenBracket

BracketAlignmentStyle clang::format::FormatStyle::AlignAfterOpenBracket

If true, horizontally aligns arguments after an open bracket.

This applies to round brackets (parentheses), angle brackets and square brackets.

Definition at line 85 of file Format.h.

Referenced by clang::format::getGoogleStyle(), clang::format::getLLVMStyle(), clang::format::getWebKitStyle(), llvm::yaml::MappingTraits< FormatStyle >::mapping(), and clang::format::CommaSeparatedList::precomputeFormattingInfos().

◆ AlignConsecutiveAssignments

bool clang::format::FormatStyle::AlignConsecutiveAssignments

If true, aligns consecutive assignments.

This will align the assignment operators of consecutive lines. This will result in formattings like

int aaaa = 12;
int b = 23;
int ccc = 23;

Definition at line 109 of file Format.h.

Referenced by clang::format::getLLVMStyle(), and llvm::yaml::MappingTraits< FormatStyle >::mapping().

◆ AlignConsecutiveBitFields

bool clang::format::FormatStyle::AlignConsecutiveBitFields

If true, aligns consecutive bitfield members.

This will align the bitfield separators of consecutive lines. This will result in formattings like

int aaaa : 1;
int b : 12;
int ccc : 8;

Definition at line 120 of file Format.h.

Referenced by clang::format::getLLVMStyle(), and llvm::yaml::MappingTraits< FormatStyle >::mapping().

◆ AlignConsecutiveDeclarations

bool clang::format::FormatStyle::AlignConsecutiveDeclarations

If true, aligns consecutive declarations.

This will align the declaration names of consecutive lines. This will result in formattings like

int aaaa = 12;
float b = 23;
std::string ccc = 23;

Definition at line 131 of file Format.h.

Referenced by clang::format::getLLVMStyle(), and llvm::yaml::MappingTraits< FormatStyle >::mapping().

◆ AlignConsecutiveMacros

bool clang::format::FormatStyle::AlignConsecutiveMacros

If true, aligns consecutive C/C++ preprocessor macros.

This will align C/C++ preprocessor macros of consecutive lines. Will result in formattings like

#define SHORT_NAME 42
#define LONGER_NAME 0x007f
#define EVEN_LONGER_NAME (2)
#define foo(x) (x * x)
#define bar(y, z) (y + z)

Definition at line 98 of file Format.h.

Referenced by clang::format::AlignMacroSequence(), clang::format::getLLVMStyle(), and llvm::yaml::MappingTraits< FormatStyle >::mapping().

◆ AlignEscapedNewlines

EscapedNewlineAlignmentStyle clang::format::FormatStyle::AlignEscapedNewlines

Options for aligning backslashes in escaped newlines.

Definition at line 165 of file Format.h.

Referenced by clang::format::getGoogleStyle(), clang::format::getLLVMStyle(), and llvm::yaml::MappingTraits< FormatStyle >::mapping().

◆ AlignOperands

OperandAlignmentStyle clang::format::FormatStyle::AlignOperands

If true, horizontally align operands of binary and ternary expressions.

Definition at line 203 of file Format.h.

Referenced by clang::format::getGoogleStyle(), clang::format::getLLVMStyle(), clang::format::getWebKitStyle(), and llvm::yaml::MappingTraits< FormatStyle >::mapping().

◆ AlignTrailingComments

bool clang::format::FormatStyle::AlignTrailingComments

If true, aligns trailing comments.

true: false:
int a; // My comment a vs. int a; // My comment a
int b = 2; // comment b int b = 2; // comment about b

Definition at line 211 of file Format.h.

Referenced by clang::format::getGoogleStyle(), clang::format::getLLVMStyle(), clang::format::getWebKitStyle(), and llvm::yaml::MappingTraits< FormatStyle >::mapping().

◆ AllowAllArgumentsOnNextLine

bool clang::format::FormatStyle::AllowAllArgumentsOnNextLine

If a function call or braced initializer list doesn't fit on a line, allow putting all arguments onto the next line, even if BinPackArguments is false.

true:
callFunction(
a, b, c, d);
false:
callFunction(a,
b,
c,
d);

Definition at line 227 of file Format.h.

Referenced by clang::format::getLLVMStyle(), and llvm::yaml::MappingTraits< FormatStyle >::mapping().


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