clang  9.0.0svn
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...
 

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 AlignConsecutiveAssignments
 If true, aligns consecutive assignments. More...
 
bool AlignConsecutiveDeclarations
 If true, aligns consecutive declarations. More...
 
EscapedNewlineAlignmentStyle AlignEscapedNewlines
 Options for aligning backslashes in escaped newlines. More...
 
bool 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 49 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 54 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 105 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 51 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 80 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 91 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 102 of file Format.h.

Referenced by 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 136 of file Format.h.

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

◆ AlignOperands

bool clang::format::FormatStyle::AlignOperands

If true, 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;

Definition at line 147 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 155 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 171 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: