struct FormatStyle

Declaration

struct FormatStyle { /* full declaration omitted */ };

Description

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

Declared at: clang/include/clang/Format/Format.h:54

Member Variables

public bool InheritsParentConfig
public int AccessModifierOffset
The extra indent or outdent of access modifiers, e.g. ``public:``.
public clang::format::FormatStyle::BracketAlignmentStyle AlignAfterOpenBracket
This applies to round brackets (parentheses), angle brackets and square brackets.
public clang::format::FormatStyle:: ArrayInitializerAlignmentStyle AlignArrayOfStructures
public clang::format::FormatStyle::AlignConsecutiveStyle AlignConsecutiveMacros
public clang::format::FormatStyle::AlignConsecutiveStyle AlignConsecutiveAssignments
public clang::format::FormatStyle::AlignConsecutiveStyle AlignConsecutiveBitFields
public clang::format::FormatStyle::AlignConsecutiveStyle AlignConsecutiveDeclarations
public clang::format::FormatStyle:: EscapedNewlineAlignmentStyle AlignEscapedNewlines
Options for aligning backslashes in escaped newlines.
public clang::format::FormatStyle::OperandAlignmentStyle AlignOperands
If ``true``, horizontally align operands of binary and ternary expressions.
public bool AlignTrailingComments
public bool AllowAllArgumentsOnNextLine
public bool AllowAllParametersOfDeclarationOnNextLine
public bool AllowShortEnumsOnASingleLine
public clang::format::FormatStyle::ShortBlockStyle AllowShortBlocksOnASingleLine
Dependent on the value, ``while (true) { continue; }`` can be put on a single line.
public bool AllowShortCaseLabelsOnASingleLine
public clang::format::FormatStyle::ShortFunctionStyle AllowShortFunctionsOnASingleLine
Dependent on the value, ``int f() { return 0; }`` can be put on a single line.
public clang::format::FormatStyle::ShortIfStyle AllowShortIfStatementsOnASingleLine
Dependent on the value, ``if (a) return;`` can be put on a single line.
public clang::format::FormatStyle::ShortLambdaStyle AllowShortLambdasOnASingleLine
Dependent on the value, ``auto lambda []() { return 0; }`` can be put on a single line.
public bool AllowShortLoopsOnASingleLine
If ``true``, ``while (true) continue;`` can be put on a single line.
public clang::format::FormatStyle:: DefinitionReturnTypeBreakingStyle AlwaysBreakAfterDefinitionReturnType
The function definition return type breaking style to use. This option is **deprecated** and is retained for backwards compatibility.
public clang::format::FormatStyle:: ReturnTypeBreakingStyle AlwaysBreakAfterReturnType
The function declaration return type breaking style to use.
public bool AlwaysBreakBeforeMultilineStrings
public clang::format::FormatStyle:: BreakTemplateDeclarationsStyle AlwaysBreakTemplateDeclarations
The template declaration breaking style to use.
public std::vector<std::string> AttributeMacros
public bool BinPackArguments
public clang::format::FormatStyle::TrailingCommaStyle InsertTrailingCommas
public bool BinPackParameters
public clang::format::FormatStyle::BinaryOperatorStyle BreakBeforeBinaryOperators
The way to wrap binary operators.
public clang::format::FormatStyle::BraceBreakingStyle BreakBeforeBraces
The brace breaking style to use.
public clang::format::FormatStyle::BraceWrappingFlags BraceWrapping
public clang::format::FormatStyle:: BreakBeforeConceptDeclarationsStyle BreakBeforeConceptDeclarations
The concept declaration style to use.
public bool BreakBeforeTernaryOperators
public clang::format::FormatStyle:: BreakConstructorInitializersStyle BreakConstructorInitializers
The break constructor initializers style to use.
public bool BreakAfterJavaFieldAnnotations
public bool BreakStringLiterals
public unsigned int ColumnLimit
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.
public std::string CommentPragmas
public clang::format::FormatStyle:: QualifierAlignmentStyle QualifierAlignment
Different ways to arrange specifiers and qualifiers (e.g. const/volatile).
public std::vector<std::string> QualifierOrder
public clang::format::FormatStyle:: BreakInheritanceListStyle BreakInheritanceList
The inheritance list style to use.
public bool CompactNamespaces
public unsigned int ConstructorInitializerIndentWidth
The number of characters to use for indentation of constructor initializer lists as well as inheritance lists.
public unsigned int ContinuationIndentWidth
public bool Cpp11BracedListStyle
public bool DeriveLineEnding
public bool DerivePointerAlignment
If ``true``, analyze the formatted file for the most common alignment of `` & `` and ``*``. Pointer and reference alignment styles are going to be updated according to the preferences found in the file. ``PointerAlignment`` is then used only as fallback.
public bool DisableFormat
Disables formatting completely.
public clang::format::FormatStyle:: EmptyLineAfterAccessModifierStyle EmptyLineAfterAccessModifier
Defines when to put an empty line after access modifiers. ``EmptyLineBeforeAccessModifier`` configuration handles the number of empty lines between two access modifiers.
public clang::format::FormatStyle:: EmptyLineBeforeAccessModifierStyle EmptyLineBeforeAccessModifier
Defines in which cases to put empty line before access modifiers.
public bool ExperimentalAutoDetectBinPacking
NOTE: This is an experimental flag, that might go away or be renamed. Do not use this in config files, etc. Use at your own risk.
public clang::format::FormatStyle:: PackConstructorInitializersStyle PackConstructorInitializers
The pack constructor initializers style to use.
public bool FixNamespaceComments
public std::vector<std::string> ForEachMacros
For example: BOOST_FOREACH.
public std::vector<std::string> IfMacros
For example: `KJ_IF_MAYBE <https ://github.com/capnproto/capnproto/blob/master/kjdoc/tour.md#maybes>`_
public std::vector<std::string> TypenameMacros
For example: OpenSSL STACK_OF, BSD LIST_ENTRY.
public std::vector<std::string> StatementMacros
For example: Q_UNUSED
public std::vector<std::string> NamespaceMacros
For example: TESTSUITE
public std::vector<std::string> WhitespaceSensitiveMacros
For example: BOOST_PP_STRINGIZE
public tooling::IncludeStyle IncludeStyle
public bool IndentAccessModifiers
public bool IndentCaseLabels
public bool IndentCaseBlocks
public bool IndentGotoLabels
public clang::format::FormatStyle::PPDirectiveIndentStyle IndentPPDirectives
The preprocessor directive indenting style to use.
public clang::format::FormatStyle::IndentExternBlockStyle IndentExternBlock
IndentExternBlockStyle is the type of indenting of extern blocks.
public bool IndentRequiresClause
public unsigned int IndentWidth
public bool IndentWrappedFunctionNames
public bool InsertBraces
public std::vector<std::string> JavaImportGroups
public clang::format::FormatStyle::JavaScriptQuoteStyle JavaScriptQuotes
The JavaScriptQuoteStyle to use for JavaScript strings.
public bool JavaScriptWrapImports
public bool KeepEmptyLinesAtTheStartOfBlocks
public clang::format::FormatStyle::LanguageKind Language
Language, this format style is targeted at.
public clang::format::FormatStyle:: LambdaBodyIndentationKind LambdaBodyIndentation
The indentation style of lambda bodies. ``Signature`` (the default) causes the lambda body to be indented one additional level relative to the indentation level of the signature. ``OuterScope`` forces the lambda body to be indented one additional level relative to the parent scope containing the lambda signature. For callback-heavy code, it may improve readability to have the signature indented two levels and to use ``OuterScope``. The KJ style guide requires ``OuterScope``. `KJ style guide <https ://github.com/capnproto/capnproto/blob/master/style-guide.md>`_
public std::string MacroBlockBegin
public std::string MacroBlockEnd
A regular expression matching macros that end a block.
public unsigned int MaxEmptyLinesToKeep
public clang::format::FormatStyle:: NamespaceIndentationKind NamespaceIndentation
The indentation used for namespaces.
public clang::format::FormatStyle::BinPackStyle ObjCBinPackProtocolList
public unsigned int ObjCBlockIndentWidth
public bool ObjCSpaceAfterProperty
public bool ObjCBreakBeforeNestedBlockParam
public bool ObjCSpaceBeforeProtocolList
Add a space in front of an Objective-C protocol list, i.e. use ``Foo <Protocol >`` instead of ``Foo <Protocol >``.
public unsigned int PenaltyBreakAssignment
The penalty for breaking around an assignment operator.
public unsigned int PenaltyBreakBeforeFirstCallParameter
The penalty for breaking a function call after ``call(``.
public unsigned int PenaltyBreakComment
The penalty for each line break introduced inside a comment.
public unsigned int PenaltyBreakFirstLessLess
The penalty for breaking before the first `` < < ``.
public unsigned int PenaltyBreakOpenParenthesis
The penalty for breaking after ``(``.
public unsigned int PenaltyBreakString
The penalty for each line break introduced inside a string literal.
public unsigned int PenaltyBreakTemplateDeclaration
The penalty for breaking after template declaration.
public unsigned int PenaltyExcessCharacter
The penalty for each character outside of the column limit.
public unsigned int PenaltyReturnTypeOnItsOwnLine
Penalty for putting the return type of a function onto its own line.
public unsigned int PenaltyIndentedWhitespace
Penalty for each character of whitespace indentation (counted relative to leading non-whitespace column).
public clang::format::FormatStyle::PointerAlignmentStyle PointerAlignment
Pointer and reference alignment style.
public int PPIndentWidth
public std::vector<RawStringFormat> RawStringFormats
public clang::format::FormatStyle:: ReferenceAlignmentStyle ReferenceAlignment
public bool ReflowComments
public bool RemoveBracesLLVM
public clang::format::FormatStyle:: RequiresClausePositionStyle RequiresClausePosition
public clang::format::FormatStyle:: SeparateDefinitionStyle SeparateDefinitionBlocks
public unsigned int ShortNamespaceLines
public clang::format::FormatStyle::SortIncludesOptions SortIncludes
Controls if and how clang-format will sort ``#includes``. If ``Never``, includes are never sorted. If ``CaseInsensitive``, includes are sorted in an ASCIIbetical or case insensitive fashion. If ``CaseSensitive``, includes are sorted in an alphabetical or case sensitive fashion.
public clang::format::FormatStyle:: SortJavaStaticImportOptions SortJavaStaticImport
When sorting Java imports, by default static imports are placed before non-static imports. If ``JavaStaticImportAfterImport`` is ``After``, static imports are placed after non-static imports.
public bool SortUsingDeclarations
public bool SpaceAfterCStyleCast
public bool SpaceAfterLogicalNot
public bool SpaceAfterTemplateKeyword
public clang::format::FormatStyle:: SpaceAroundPointerQualifiersStyle SpaceAroundPointerQualifiers
Defines in which cases to put a space before or after pointer qualifiers
public bool SpaceBeforeAssignmentOperators
public bool SpaceBeforeCaseColon
public bool SpaceBeforeCpp11BracedList
public bool SpaceBeforeCtorInitializerColon
public bool SpaceBeforeInheritanceColon
public clang::format::FormatStyle::SpaceBeforeParensStyle SpaceBeforeParens
Defines in which cases to put a space before opening parentheses.
public clang::format::FormatStyle:: SpaceBeforeParensCustom SpaceBeforeParensOptions
public bool SpaceBeforeRangeBasedForLoopColon
public bool SpaceInEmptyBlock
public bool SpaceInEmptyParentheses
public unsigned int SpacesBeforeTrailingComments
public clang::format::FormatStyle::SpacesInAnglesStyle SpacesInAngles
The SpacesInAnglesStyle to use for template argument lists.
public bool SpacesInConditionalStatement
public bool SpacesInContainerLiterals
public bool SpacesInCStyleCastParentheses
public clang::format::FormatStyle::SpacesInLineComment SpacesInLineCommentPrefix
public bool SpacesInParentheses
public bool SpacesInSquareBrackets
public bool SpaceBeforeSquareBrackets
public clang::format::FormatStyle:: BitFieldColonSpacingStyle BitFieldColonSpacing
The BitFieldColonSpacingStyle to use for bitfields.
public clang::format::FormatStyle::LanguageStandard Standard
public std::vector<std::string> StatementAttributeLikeMacros
public unsigned int TabWidth
The number of columns used for tab stops.
public bool UseCRLF
public clang::format::FormatStyle::UseTabStyle UseTab
The way to use tab characters in the resulting file.
private clang::format::FormatStyle::FormatStyleSet StyleSet

Method Overview

  • public static clang::format::FormatStyle::FormatStyleSet BuildStyleSetFromConfiguration(const clang::format::FormatStyle & MainStyle, const std::vector<FormatStyle> & ConfigurationStyles)
  • public llvm::Optional<FormatStyle> GetLanguageStyle(clang::format::FormatStyle::LanguageKind Language) const
  • public bool isCSharp() const
  • public bool isCpp() const
  • public bool isJavaScript() const
  • public bool isJson() const
  • public bool isVerilog() const

Methods

static clang::format::FormatStyle::FormatStyleSet
BuildStyleSetFromConfiguration(
    const clang::format::FormatStyle& MainStyle,
    const std::vector<FormatStyle>&
        ConfigurationStyles)

Declared at: clang/include/clang/Format/Format.h:4023

Parameters

const clang::format::FormatStyle& MainStyle
const std::vector<FormatStyle>& ConfigurationStyles

llvm::Optional<FormatStyle> GetLanguageStyle(
    clang::format::FormatStyle::LanguageKind
        Language) const

Declared at: clang/include/clang/Format/Format.h:3995

Parameters

clang::format::FormatStyle::LanguageKind Language

bool isCSharp() const

Declared at: clang/include/clang/Format/Format.h:2599

bool isCpp() const

Declared at: clang/include/clang/Format/Format.h:2598

bool isJavaScript() const

Declared at: clang/include/clang/Format/Format.h:2601

bool isJson() const

Declared at: clang/include/clang/Format/Format.h:2600

bool isVerilog() const

Declared at: clang/include/clang/Format/Format.h:2602