clang  13.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 : unsigned char { BAS_Align, BAS_DontAlign, BAS_AlwaysBreak }
 Different styles for aligning after open brackets. More...
 
enum  AlignConsecutiveStyle {
  ACS_None, ACS_Consecutive, ACS_AcrossEmptyLines, ACS_AcrossComments,
  ACS_AcrossEmptyLinesAndComments
}
 Styles for alignment of consecutive tokens. More...
 
enum  EscapedNewlineAlignmentStyle : unsigned char { ENAS_DontAlign, ENAS_Left, ENAS_Right }
 Different styles for aligning escaped newlines. More...
 
enum  OperandAlignmentStyle : unsigned char { OAS_DontAlign, OAS_Align, OAS_AlignAfterOperator }
 Different styles for aligning operands. More...
 

Public Attributes

bool InheritsParentConfig
 
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...
 
AlignConsecutiveStyle AlignConsecutiveMacros
 Style of aligning consecutive macro definitions. More...
 
AlignConsecutiveStyle AlignConsecutiveAssignments
 Style of aligning consecutive assignments. More...
 
AlignConsecutiveStyle AlignConsecutiveBitFields
 Style of aligning consecutive bit field. More...
 
AlignConsecutiveStyle AlignConsecutiveDeclarations
 Style of aligning 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 55 of file Format.h.

Member Enumeration Documentation

◆ AlignConsecutiveStyle

Styles for alignment of consecutive tokens.

Tokens can be assignment signs (see AlignConsecutiveAssignments), bitfield member separators (see AlignConsecutiveBitFields), names in declarations (see AlignConsecutiveDeclarations) or macro definitions (see AlignConsecutiveMacros).

Enumerator
ACS_None 
ACS_Consecutive 
ACS_AcrossEmptyLines 
ACS_AcrossComments 
ACS_AcrossEmptyLinesAndComments 

Definition at line 99 of file Format.h.

◆ 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 65 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 384 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.:
\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;
\endcode 
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.
\code
  int aaa = bbbbbbbbbbbbbbb
          + ccccccccccccccc;
\endcode 

Definition at line 418 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 62 of file Format.h.

Referenced by clang::format::getGoogleStyle(), and clang::format::getLLVMStyle().

◆ 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 91 of file Format.h.

Referenced by clang::format::getGoogleStyle(), clang::format::getLLVMStyle(), and clang::format::CommaSeparatedList::precomputeFormattingInfos().

◆ AlignConsecutiveAssignments

AlignConsecutiveStyle clang::format::FormatStyle::AlignConsecutiveAssignments

Style of aligning consecutive assignments.

Consecutive will result in formattings like:

int a = 1;
int somelongname = 2;
double c = 3;

Possible values:

  • ACS_None (in configuration: None) Do not align assignments on consecutive lines.
  • ACS_Consecutive (in configuration: Consecutive) Align assignments on consecutive lines. This will result in formattings like:
    int a = 1;
    int somelongname = 2;
    double c = 3;
    int d = 3;
    /* A comment. */
    double e = 4;
  • ACS_AcrossEmptyLines (in configuration: AcrossEmptyLines) Same as ACS_Consecutive, but also spans over empty lines, e.g.
    int a = 1;
    int somelongname = 2;
    double c = 3;
    int d = 3;
    /* A comment. */
    double e = 4;
  • ACS_AcrossComments (in configuration: AcrossComments) Same as ACS_Consecutive, but also spans over lines only containing comments, e.g.
    int a = 1;
    int somelongname = 2;
    double c = 3;
    int d = 3;
    /* A comment. */
    double e = 4;
  • ACS_AcrossEmptyLinesAndComments (in configuration: AcrossEmptyLinesAndComments)

    Same as ACS_Consecutive, but also spans over lines only containing comments and empty lines, e.g.

    int a = 1;
    int somelongname = 2;
    double c = 3;
    int d = 3;
    /* A comment. */
    double e = 4;

Definition at line 243 of file Format.h.

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

◆ AlignConsecutiveBitFields

AlignConsecutiveStyle clang::format::FormatStyle::AlignConsecutiveBitFields

Style of aligning consecutive bit field.

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

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

Possible values:

  • ACS_None (in configuration: None) Do not align bit fields on consecutive lines.
  • ACS_Consecutive (in configuration: Consecutive) Align bit fields on consecutive lines. This will result in formattings like:
    int aaaa : 1;
    int b : 12;
    int ccc : 8;
    int d : 2;
    /* A comment. */
    int ee : 3;
  • ACS_AcrossEmptyLines (in configuration: AcrossEmptyLines) Same as ACS_Consecutive, but also spans over empty lines, e.g.
    int aaaa : 1;
    int b : 12;
    int ccc : 8;
    int d : 2;
    /* A comment. */
    int ee : 3;
  • ACS_AcrossComments (in configuration: AcrossComments) Same as ACS_Consecutive, but also spans over lines only containing comments, e.g.
    int aaaa : 1;
    int b : 12;
    int ccc : 8;
    int d : 2;
    /* A comment. */
    int ee : 3;
  • ACS_AcrossEmptyLinesAndComments (in configuration: AcrossEmptyLinesAndComments)

    Same as ACS_Consecutive, but also spans over lines only containing comments and empty lines, e.g.

    int aaaa : 1;
    int b : 12;
    int ccc : 8;
    int d : 2;
    /* A comment. */
    int ee : 3;

Definition at line 312 of file Format.h.

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

◆ AlignConsecutiveDeclarations

AlignConsecutiveStyle clang::format::FormatStyle::AlignConsecutiveDeclarations

Style of aligning consecutive declarations.

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

int aaaa = 12;
float b = 23;

Possible values:

  • ACS_None (in configuration: None) Do not align bit declarations on consecutive lines.
  • ACS_Consecutive (in configuration: Consecutive) Align declarations on consecutive lines. This will result in formattings like:
    int aaaa = 12;
    float b = 23;
    int a = 42;
    /* A comment. */
    bool c = false;
  • ACS_AcrossEmptyLines (in configuration: AcrossEmptyLines) Same as ACS_Consecutive, but also spans over empty lines, e.g.
    int aaaa = 12;
    float b = 23;
    int a = 42;
    /* A comment. */
    bool c = false;
  • ACS_AcrossComments (in configuration: AcrossComments) Same as ACS_Consecutive, but also spans over lines only containing comments, e.g.
    int aaaa = 12;
    float b = 23;
    int a = 42;
    /* A comment. */
    bool c = false;
  • ACS_AcrossEmptyLinesAndComments (in configuration: AcrossEmptyLinesAndComments)

    Same as ACS_Consecutive, but also spans over lines only containing comments and empty lines, e.g.

    int aaaa = 12;
    float b = 23;
    int a = 42;
    /* A comment. */
    bool c = false;

Definition at line 381 of file Format.h.

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

◆ AlignConsecutiveMacros

AlignConsecutiveStyle clang::format::FormatStyle::AlignConsecutiveMacros

Style of aligning consecutive macro definitions.

Consecutive 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)

Possible values:

  • ACS_None (in configuration: None) Do not align macro definitions on consecutive lines.
  • ACS_Consecutive (in configuration: Consecutive) Align macro definitions on consecutive lines. This will result in formattings like:
    #define SHORT_NAME 42
    #define LONGER_NAME 0x007f
    #define EVEN_LONGER_NAME (2)
    #define foo(x) (x * x)
    /* some comment */
    #define bar(y, z) (y + z)
  • ACS_AcrossEmptyLines (in configuration: AcrossEmptyLines) Same as ACS_Consecutive, but also spans over empty lines, e.g.
    #define SHORT_NAME 42
    #define LONGER_NAME 0x007f
    #define EVEN_LONGER_NAME (2)
    #define foo(x) (x * x)
    /* some comment */
    #define bar(y, z) (y + z)
  • ACS_AcrossComments (in configuration: AcrossComments) Same as ACS_Consecutive, but also spans over lines only containing comments, e.g.
    #define SHORT_NAME 42
    #define LONGER_NAME 0x007f
    #define EVEN_LONGER_NAME (2)
    #define foo(x) (x * x)
    /* some comment */
    #define bar(y, z) (y + z)
  • ACS_AcrossEmptyLinesAndComments (in configuration: AcrossEmptyLinesAndComments)

    Same as ACS_Consecutive, but also spans over lines only containing comments and empty lines, e.g.

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

Definition at line 175 of file Format.h.

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

◆ AlignEscapedNewlines

EscapedNewlineAlignmentStyle clang::format::FormatStyle::AlignEscapedNewlines

Options for aligning backslashes in escaped newlines.

Definition at line 415 of file Format.h.

Referenced by clang::format::getGoogleStyle(), and clang::format::getLLVMStyle().

◆ AlignOperands

OperandAlignmentStyle clang::format::FormatStyle::AlignOperands

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

Definition at line 453 of file Format.h.

Referenced by clang::format::getGoogleStyle(), and clang::format::getLLVMStyle().

◆ 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 461 of file Format.h.

Referenced by clang::format::getGoogleStyle(), and clang::format::getLLVMStyle().

◆ 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 477 of file Format.h.

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

◆ InheritsParentConfig

bool clang::format::FormatStyle::InheritsParentConfig

Definition at line 59 of file Format.h.

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


The documentation for this struct was generated from the following file:
string
string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD) string(SUBSTRING $
Definition: CMakeLists.txt:22
b
__device__ __2f16 b
Definition: __clang_hip_libdevice_declares.h:302
c
__device__ __2f16 float c
Definition: __clang_hip_libdevice_declares.h:303