diff --git a/clang/docs/ClangFormatStyleOptions.rst b/clang/docs/ClangFormatStyleOptions.rst --- a/clang/docs/ClangFormatStyleOptions.rst +++ b/clang/docs/ClangFormatStyleOptions.rst @@ -1,3 +1,11 @@ +.. raw:: html + + + +.. role:: versionbadge + ========================== Clang-Format Style Options ========================== @@ -166,10 +174,10 @@ .. START_FORMAT_STYLE_OPTIONS -**AccessModifierOffset** (``Integer``) +**AccessModifierOffset** (``Integer``) :versionbadge:`clang-format 3.3` The extra indent or outdent of access modifiers, e.g. ``public:``. -**AlignAfterOpenBracket** (``BracketAlignmentStyle``) +**AlignAfterOpenBracket** (``BracketAlignmentStyle``) :versionbadge:`clang-format 3.8` If ``true``, horizontally aligns arguments after an open bracket. This applies to round brackets (parentheses), angle brackets and square @@ -204,7 +212,7 @@ -**AlignArrayOfStructures** (``ArrayInitializerAlignmentStyle``) +**AlignArrayOfStructures** (``ArrayInitializerAlignmentStyle``) :versionbadge:`clang-format 13` if not ``None``, when using initialization for an array of structs aligns the fields into columns. @@ -239,7 +247,7 @@ -**AlignConsecutiveAssignments** (``AlignConsecutiveStyle``) +**AlignConsecutiveAssignments** (``AlignConsecutiveStyle``) :versionbadge:`clang-format 13` Style of aligning consecutive assignments. ``Consecutive`` will result in formattings like: @@ -312,7 +320,7 @@ /* A comment. */ double e = 4; -**AlignConsecutiveBitFields** (``AlignConsecutiveStyle``) +**AlignConsecutiveBitFields** (``AlignConsecutiveStyle``) :versionbadge:`clang-format 13` Style of aligning consecutive bit field. ``Consecutive`` will align the bitfield separators of consecutive lines. @@ -386,7 +394,7 @@ /* A comment. */ int ee : 3; -**AlignConsecutiveDeclarations** (``AlignConsecutiveStyle``) +**AlignConsecutiveDeclarations** (``AlignConsecutiveStyle``) :versionbadge:`clang-format 13` Style of aligning consecutive declarations. ``Consecutive`` will align the declaration names of consecutive lines. @@ -460,7 +468,7 @@ /* A comment. */ bool c = false; -**AlignConsecutiveMacros** (``AlignConsecutiveStyle``) +**AlignConsecutiveMacros** (``AlignConsecutiveStyle``) :versionbadge:`clang-format 13` Style of aligning consecutive macro definitions. ``Consecutive`` will result in formattings like: @@ -535,7 +543,7 @@ /* some comment */ #define bar(y, z) (y + z) -**AlignEscapedNewlines** (``EscapedNewlineAlignmentStyle``) +**AlignEscapedNewlines** (``EscapedNewlineAlignmentStyle``) :versionbadge:`clang-format 5` Options for aligning backslashes in escaped newlines. Possible values: @@ -575,7 +583,7 @@ -**AlignOperands** (``OperandAlignmentStyle``) +**AlignOperands** (``OperandAlignmentStyle``) :versionbadge:`clang-format 12` If ``true``, horizontally align operands of binary and ternary expressions. @@ -619,7 +627,7 @@ -**AlignTrailingComments** (``Boolean``) +**AlignTrailingComments** (``Boolean``) :versionbadge:`clang-format 3.7` If ``true``, aligns trailing comments. .. code-block:: c++ @@ -628,7 +636,7 @@ int a; // My comment a vs. int a; // My comment a int b = 2; // comment b int b = 2; // comment about b -**AllowAllArgumentsOnNextLine** (``Boolean``) +**AllowAllArgumentsOnNextLine** (``Boolean``) :versionbadge:`clang-format 9` 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``. @@ -645,11 +653,11 @@ c, d); -**AllowAllConstructorInitializersOnNextLine** (``Boolean``) +**AllowAllConstructorInitializersOnNextLine** (``Boolean``) :versionbadge:`clang-format 9` This option is **deprecated**. See ``NextLine`` of ``PackConstructorInitializers``. -**AllowAllParametersOfDeclarationOnNextLine** (``Boolean``) +**AllowAllParametersOfDeclarationOnNextLine** (``Boolean``) :versionbadge:`clang-format 3.3` If the function declaration doesn't fit on a line, allow putting all parameters of a function declaration onto the next line even if ``BinPackParameters`` is ``false``. @@ -667,7 +675,7 @@ int d, int e); -**AllowShortBlocksOnASingleLine** (``ShortBlockStyle``) +**AllowShortBlocksOnASingleLine** (``ShortBlockStyle``) :versionbadge:`clang-format 11` Dependent on the value, ``while (true) { continue; }`` can be put on a single line. @@ -704,7 +712,7 @@ -**AllowShortCaseLabelsOnASingleLine** (``Boolean``) +**AllowShortCaseLabelsOnASingleLine** (``Boolean``) :versionbadge:`clang-format 3.6` If ``true``, short case labels will be contracted to a single line. .. code-block:: c++ @@ -718,7 +726,7 @@ return; } -**AllowShortEnumsOnASingleLine** (``Boolean``) +**AllowShortEnumsOnASingleLine** (``Boolean``) :versionbadge:`clang-format 12` Allow short enums on a single line. .. code-block:: c++ @@ -732,7 +740,7 @@ B } myEnum; -**AllowShortFunctionsOnASingleLine** (``ShortFunctionStyle``) +**AllowShortFunctionsOnASingleLine** (``ShortFunctionStyle``) :versionbadge:`clang-format 3.5` Dependent on the value, ``int f() { return 0; }`` can be put on a single line. @@ -792,7 +800,7 @@ -**AllowShortIfStatementsOnASingleLine** (``ShortIfStyle``) +**AllowShortIfStatementsOnASingleLine** (``ShortIfStyle``) :versionbadge:`clang-format 9` Dependent on the value, ``if (a) return;`` can be put on a single line. Possible values: @@ -870,7 +878,7 @@ -**AllowShortLambdasOnASingleLine** (``ShortLambdaStyle``) +**AllowShortLambdasOnASingleLine** (``ShortLambdaStyle``) :versionbadge:`clang-format 9` Dependent on the value, ``auto lambda []() { return 0; }`` can be put on a single line. @@ -909,11 +917,11 @@ -**AllowShortLoopsOnASingleLine** (``Boolean``) +**AllowShortLoopsOnASingleLine** (``Boolean``) :versionbadge:`clang-format 3.7` If ``true``, ``while (true) continue;`` can be put on a single line. -**AlwaysBreakAfterDefinitionReturnType** (``DefinitionReturnTypeBreakingStyle``) +**AlwaysBreakAfterDefinitionReturnType** (``DefinitionReturnTypeBreakingStyle``) :versionbadge:`clang-format 3.7` The function definition return type breaking style to use. This option is **deprecated** and is retained for backwards compatibility. @@ -931,7 +939,7 @@ -**AlwaysBreakAfterReturnType** (``ReturnTypeBreakingStyle``) +**AlwaysBreakAfterReturnType** (``ReturnTypeBreakingStyle``) :versionbadge:`clang-format 3.8` The function declaration return type breaking style to use. Possible values: @@ -1014,7 +1022,7 @@ -**AlwaysBreakBeforeMultilineStrings** (``Boolean``) +**AlwaysBreakBeforeMultilineStrings** (``Boolean``) :versionbadge:`clang-format 3.4` If ``true``, always break before multiline string literals. This flag is mean to make cases where there are multiple multiline strings @@ -1029,7 +1037,7 @@ "bbbb" "cccc"; "cccc"; -**AlwaysBreakTemplateDeclarations** (``BreakTemplateDeclarationsStyle``) +**AlwaysBreakTemplateDeclarations** (``BreakTemplateDeclarationsStyle``) :versionbadge:`clang-format 7` The template declaration breaking style to use. Possible values: @@ -1074,7 +1082,7 @@ -**AttributeMacros** (``List of Strings``) +**AttributeMacros** (``List of Strings``) :versionbadge:`clang-format 13` 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. @@ -1093,7 +1101,7 @@ AttributeMacros: ['__capability', '__output', '__ununsed'] -**BinPackArguments** (``Boolean``) +**BinPackArguments** (``Boolean``) :versionbadge:`clang-format 3.7` If ``false``, a function call's arguments will either be all on the same line or will have one line each. @@ -1112,7 +1120,7 @@ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); } -**BinPackParameters** (``Boolean``) +**BinPackParameters** (``Boolean``) :versionbadge:`clang-format 3.7` If ``false``, a function declaration's or function definition's parameters will either all be on the same line or will have one line each. @@ -1127,7 +1135,7 @@ int aaaaaaaaaaaaaaaaaaaa, int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {} -**BitFieldColonSpacing** (``BitFieldColonSpacingStyle``) +**BitFieldColonSpacing** (``BitFieldColonSpacingStyle``) :versionbadge:`clang-format 13` The BitFieldColonSpacingStyle to use for bitfields. Possible values: @@ -1164,7 +1172,7 @@ -**BraceWrapping** (``BraceWrappingFlags``) +**BraceWrapping** (``BraceWrappingFlags``) :versionbadge:`clang-format 3.8` Control of individual brace wrapping cases. If ``BreakBeforeBraces`` is set to ``BS_Custom``, use this to specify how @@ -1450,7 +1458,7 @@ } -**BreakAfterJavaFieldAnnotations** (``Boolean``) +**BreakAfterJavaFieldAnnotations** (``Boolean``) :versionbadge:`clang-format 3.8` Break after each annotation on a field in Java files. .. code-block:: java @@ -1460,7 +1468,7 @@ @Mock DataLoad loader; -**BreakBeforeBinaryOperators** (``BinaryOperatorStyle``) +**BreakBeforeBinaryOperators** (``BinaryOperatorStyle``) :versionbadge:`clang-format 3.6` The way to wrap binary operators. Possible values: @@ -1509,7 +1517,7 @@ -**BreakBeforeBraces** (``BraceBreakingStyle``) +**BreakBeforeBraces** (``BraceBreakingStyle``) :versionbadge:`clang-format 3.7` The brace breaking style to use. Possible values: @@ -1960,7 +1968,7 @@ -**BreakBeforeConceptDeclarations** (``Boolean``) +**BreakBeforeConceptDeclarations** (``Boolean``) :versionbadge:`clang-format 13` If ``true``, concept will be placed on a new line. .. code-block:: c++ @@ -1972,7 +1980,7 @@ false: template concept ... -**BreakBeforeTernaryOperators** (``Boolean``) +**BreakBeforeTernaryOperators** (``Boolean``) :versionbadge:`clang-format 3.7` If ``true``, ternary operators will be placed after line breaks. .. code-block:: c++ @@ -1987,7 +1995,7 @@ firstValue : SecondValueVeryVeryVeryVeryLong; -**BreakConstructorInitializers** (``BreakConstructorInitializersStyle``) +**BreakConstructorInitializers** (``BreakConstructorInitializersStyle``) :versionbadge:`clang-format 5` The break constructor initializers style to use. Possible values: @@ -2022,7 +2030,7 @@ -**BreakInheritanceList** (``BreakInheritanceListStyle``) +**BreakInheritanceList** (``BreakInheritanceListStyle``) :versionbadge:`clang-format 7` The inheritance list style to use. Possible values: @@ -2069,7 +2077,7 @@ -**BreakStringLiterals** (``Boolean``) +**BreakStringLiterals** (``Boolean``) :versionbadge:`clang-format 3.9` Allow breaking string literals when formatting. .. code-block:: c++ @@ -2083,14 +2091,14 @@ const char* x = "veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongString"; -**ColumnLimit** (``Unsigned``) +**ColumnLimit** (``Unsigned``) :versionbadge:`clang-format 3.7` The 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. -**CommentPragmas** (``String``) +**CommentPragmas** (``String``) :versionbadge:`clang-format 3.7` A regular expression that describes comments with special meaning, which should not be split into lines or otherwise changed. @@ -2100,7 +2108,7 @@ // Will leave the following line unaffected #include // FOOBAR pragma: keep -**CompactNamespaces** (``Boolean``) +**CompactNamespaces** (``Boolean``) :versionbadge:`clang-format 5` If ``true``, consecutive namespace declarations will be on the same line. If ``false``, each namespace is declared on a new line. @@ -2125,15 +2133,15 @@ namespace Extra { }}} -**ConstructorInitializerAllOnOneLineOrOnePerLine** (``Boolean``) +**ConstructorInitializerAllOnOneLineOrOnePerLine** (``Boolean``) :versionbadge:`clang-format 3.7` This option is **deprecated**. See ``CurrentLine`` of ``PackConstructorInitializers``. -**ConstructorInitializerIndentWidth** (``Unsigned``) +**ConstructorInitializerIndentWidth** (``Unsigned``) :versionbadge:`clang-format 3.7` The number of characters to use for indentation of constructor initializer lists as well as inheritance lists. -**ContinuationIndentWidth** (``Unsigned``) +**ContinuationIndentWidth** (``Unsigned``) :versionbadge:`clang-format 3.7` Indent width for line continuations. .. code-block:: c++ @@ -2144,7 +2152,7 @@ longFunction( // Again a long comment arg); -**Cpp11BracedListStyle** (``Boolean``) +**Cpp11BracedListStyle** (``Boolean``) :versionbadge:`clang-format 3.4` If ``true``, format braced lists as best suited for C++11 braced lists. @@ -2167,21 +2175,21 @@ f(MyMap[{composite, key}]); f(MyMap[{ composite, key }]); new int[3]{1, 2, 3}; new int[3]{ 1, 2, 3 }; -**DeriveLineEnding** (``Boolean``) +**DeriveLineEnding** (``Boolean``) :versionbadge:`clang-format 11` Analyze the formatted file for the most used line ending (``\r\n`` or ``\n``). ``UseCRLF`` is only used as a fallback if none can be derived. -**DerivePointerAlignment** (``Boolean``) +**DerivePointerAlignment** (``Boolean``) :versionbadge:`clang-format 3.7` 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. -**DisableFormat** (``Boolean``) +**DisableFormat** (``Boolean``) :versionbadge:`clang-format 3.7` Disables formatting completely. -**EmptyLineAfterAccessModifier** (``EmptyLineAfterAccessModifierStyle``) +**EmptyLineAfterAccessModifier** (``EmptyLineAfterAccessModifierStyle``) :versionbadge:`clang-format 14` Defines when to put an empty line after access modifiers. ``EmptyLineBeforeAccessModifier`` configuration handles the number of empty lines between two access modifiers. @@ -2234,7 +2242,7 @@ -**EmptyLineBeforeAccessModifier** (``EmptyLineBeforeAccessModifierStyle``) +**EmptyLineBeforeAccessModifier** (``EmptyLineBeforeAccessModifierStyle``) :versionbadge:`clang-format 13` Defines in which cases to put empty line before access modifiers. Possible values: @@ -2303,7 +2311,7 @@ -**ExperimentalAutoDetectBinPacking** (``Boolean``) +**ExperimentalAutoDetectBinPacking** (``Boolean``) :versionbadge:`clang-format 3.7` If ``true``, clang-format detects whether function calls and definitions are formatted with one parameter per line. @@ -2315,7 +2323,7 @@ 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. -**FixNamespaceComments** (``Boolean``) +**FixNamespaceComments** (``Boolean``) :versionbadge:`clang-format 5` If ``true``, clang-format adds missing namespace end comments for short namespaces and fixes invalid existing ones. Short ones are controlled by "ShortNamespaceLines". @@ -2328,7 +2336,7 @@ bar(); bar(); } // namespace a } -**ForEachMacros** (``List of Strings``) +**ForEachMacros** (``List of Strings``) :versionbadge:`clang-format 3.7` A vector of macros that should be interpreted as foreach loops instead of as function calls. @@ -2347,7 +2355,7 @@ For example: BOOST_FOREACH. -**IfMacros** (``List of Strings``) +**IfMacros** (``List of Strings``) :versionbadge:`clang-format 14` A vector of macros that should be interpreted as conditionals instead of as function calls. @@ -2369,7 +2377,7 @@ For example: `KJ_IF_MAYBE `_ -**IncludeBlocks** (``IncludeBlocksStyle``) +**IncludeBlocks** (``IncludeBlocksStyle``) :versionbadge:`clang-format 7` Dependent on the value, multiple ``#include`` blocks can be sorted as one and divided based on category. @@ -2409,7 +2417,7 @@ -**IncludeCategories** (``List of IncludeCategories``) +**IncludeCategories** (``List of IncludeCategories``) :versionbadge:`clang-format 7` Regular expressions denoting the different ``#include`` categories used for ordering ``#includes``. @@ -2457,7 +2465,7 @@ Priority: 1 SortPriority: 0 -**IncludeIsMainRegex** (``String``) +**IncludeIsMainRegex** (``String``) :versionbadge:`clang-format 7` Specify a regular expression of suffixes that are allowed in the file-to-main-include mapping. @@ -2470,7 +2478,7 @@ For example, if configured to "(_test)?$", then a header a.h would be seen as the "main" include in both a.cc and a_test.cc. -**IncludeIsMainSourceRegex** (``String``) +**IncludeIsMainSourceRegex** (``String``) :versionbadge:`clang-format 7` Specify a regular expression for files being formatted that are allowed to be considered "main" in the file-to-main-include mapping. @@ -2490,7 +2498,7 @@ ``ClassImpl.hpp`` would not have the main include file put on top before any other include. -**IndentAccessModifiers** (``Boolean``) +**IndentAccessModifiers** (``Boolean``) :versionbadge:`clang-format 13` Specify whether access modifiers should have their own indentation level. When ``false``, access modifiers are indented (or outdented) relative to @@ -2517,7 +2525,7 @@ return 1; return 1; } } -**IndentCaseBlocks** (``Boolean``) +**IndentCaseBlocks** (``Boolean``) :versionbadge:`clang-format 11` Indent case label blocks one level from the case label. When ``false``, the block following the case label uses the same @@ -2540,7 +2548,7 @@ } } -**IndentCaseLabels** (``Boolean``) +**IndentCaseLabels** (``Boolean``) :versionbadge:`clang-format 3.3` Indent case labels one level from the switch statement. When ``false``, use the same indentation level as for the switch @@ -2559,7 +2567,7 @@ plop(); plop(); } } -**IndentExternBlock** (``IndentExternBlockStyle``) +**IndentExternBlock** (``IndentExternBlockStyle``) :versionbadge:`clang-format 12` IndentExternBlockStyle is the type of indenting of extern blocks. Possible values: @@ -2605,7 +2613,7 @@ -**IndentGotoLabels** (``Boolean``) +**IndentGotoLabels** (``Boolean``) :versionbadge:`clang-format 10` Indent goto labels. When ``false``, goto labels are flushed left. @@ -2622,7 +2630,7 @@ return 1; return 1; } } -**IndentPPDirectives** (``PPDirectiveIndentStyle``) +**IndentPPDirectives** (``PPDirectiveIndentStyle``) :versionbadge:`clang-format 6` The preprocessor directive indenting style to use. Possible values: @@ -2662,7 +2670,7 @@ -**IndentRequires** (``Boolean``) +**IndentRequires** (``Boolean``) :versionbadge:`clang-format 13` Indent the requires clause in a template .. code-block:: c++ @@ -2681,7 +2689,7 @@ //.... } -**IndentWidth** (``Unsigned``) +**IndentWidth** (``Unsigned``) :versionbadge:`clang-format 3.7` The number of columns to use for indentation. .. code-block:: c++ @@ -2695,7 +2703,7 @@ } } -**IndentWrappedFunctionNames** (``Boolean``) +**IndentWrappedFunctionNames** (``Boolean``) :versionbadge:`clang-format 3.7` Indent if a function definition or declaration is wrapped after the type. @@ -2709,7 +2717,7 @@ LoooooooooooooooooooooooooooooooooooooooongReturnType LoooooooooooooooooooooooooooooooongFunctionDeclaration(); -**InsertTrailingCommas** (``TrailingCommaStyle``) +**InsertTrailingCommas** (``TrailingCommaStyle``) :versionbadge:`clang-format 12` If set to ``TCS_Wrapped`` will insert trailing commas in container literals (arrays and objects) that wrap across multiple lines. It is currently only available for JavaScript @@ -2741,7 +2749,7 @@ -**JavaImportGroups** (``List of Strings``) +**JavaImportGroups** (``List of Strings``) :versionbadge:`clang-format 8` A 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 @@ -2776,7 +2784,7 @@ import org.example.ClassD; -**JavaScriptQuotes** (``JavaScriptQuoteStyle``) +**JavaScriptQuotes** (``JavaScriptQuoteStyle``) :versionbadge:`clang-format 3.9` The JavaScriptQuoteStyle to use for JavaScript strings. Possible values: @@ -2807,7 +2815,7 @@ -**JavaScriptWrapImports** (``Boolean``) +**JavaScriptWrapImports** (``Boolean``) :versionbadge:`clang-format 3.9` Whether to wrap JavaScript import/export statements. .. code-block:: js @@ -2822,7 +2830,7 @@ false: import {VeryLongImportsAreAnnoying, VeryLongImportsAreAnnoying, VeryLongImportsAreAnnoying,} from "some/module.js" -**KeepEmptyLinesAtTheStartOfBlocks** (``Boolean``) +**KeepEmptyLinesAtTheStartOfBlocks** (``Boolean``) :versionbadge:`clang-format 3.7` If true, the empty line at the start of blocks is kept. .. code-block:: c++ @@ -2833,7 +2841,7 @@ bar(); } } -**LambdaBodyIndentation** (``LambdaBodyIndentationKind``) +**LambdaBodyIndentation** (``LambdaBodyIndentationKind``) :versionbadge:`clang-format 13` 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 @@ -2869,7 +2877,7 @@ -**Language** (``LanguageKind``) +**Language** (``LanguageKind``) :versionbadge:`clang-format 3.5` Language, this format style is targeted at. Possible values: @@ -2908,7 +2916,7 @@ -**MacroBlockBegin** (``String``) +**MacroBlockBegin** (``String``) :versionbadge:`clang-format 3.7` A regular expression matching macros that start a block. .. code-block:: c++ @@ -2937,10 +2945,10 @@ bar(); NS_TABLE_FOO_END -**MacroBlockEnd** (``String``) +**MacroBlockEnd** (``String``) :versionbadge:`clang-format 3.7` A regular expression matching macros that end a block. -**MaxEmptyLinesToKeep** (``Unsigned``) +**MaxEmptyLinesToKeep** (``Unsigned``) :versionbadge:`clang-format 3.7` The maximum number of consecutive empty lines to keep. .. code-block:: c++ @@ -2954,7 +2962,7 @@ return i; } -**NamespaceIndentation** (``NamespaceIndentationKind``) +**NamespaceIndentation** (``NamespaceIndentationKind``) :versionbadge:`clang-format 3.7` The indentation used for namespaces. Possible values: @@ -2997,7 +3005,7 @@ -**NamespaceMacros** (``List of Strings``) +**NamespaceMacros** (``List of Strings``) :versionbadge:`clang-format 9` A vector of macros which are used to open namespace blocks. These are expected to be macros of the form: @@ -3010,7 +3018,7 @@ For example: TESTSUITE -**ObjCBinPackProtocolList** (``BinPackStyle``) +**ObjCBinPackProtocolList** (``BinPackStyle``) :versionbadge:`clang-format 7` Controls bin-packing Objective-C protocol conformance list items into as few lines as possible when they go over ``ColumnLimit``. @@ -3056,7 +3064,7 @@ -**ObjCBlockIndentWidth** (``Unsigned``) +**ObjCBlockIndentWidth** (``Unsigned``) :versionbadge:`clang-format 3.7` The number of characters to use for indentation of ObjC blocks. .. code-block:: objc @@ -3067,7 +3075,7 @@ [self onOperationDone]; }]; -**ObjCBreakBeforeNestedBlockParam** (``Boolean``) +**ObjCBreakBeforeNestedBlockParam** (``Boolean``) :versionbadge:`clang-format 12` Break parameters list into lines when there is nested block parameters in a function call. @@ -3091,15 +3099,15 @@ }] } -**ObjCSpaceAfterProperty** (``Boolean``) +**ObjCSpaceAfterProperty** (``Boolean``) :versionbadge:`clang-format 3.7` Add a space after ``@property`` in Objective-C, i.e. use ``@property (readonly)`` instead of ``@property(readonly)``. -**ObjCSpaceBeforeProtocolList** (``Boolean``) +**ObjCSpaceBeforeProtocolList** (``Boolean``) :versionbadge:`clang-format 3.7` Add a space in front of an Objective-C protocol list, i.e. use ``Foo `` instead of ``Foo``. -**PPIndentWidth** (``Integer``) +**PPIndentWidth** (``Integer``) :versionbadge:`clang-format 14` The number of columns to use for indentation of preprocessor statements. When set to -1 (default) ``IndentWidth`` is used also for preprocessor statements. @@ -3114,7 +3122,7 @@ # define BAR #endif -**PackConstructorInitializers** (``PackConstructorInitializersStyle``) +**PackConstructorInitializers** (``PackConstructorInitializersStyle``) :versionbadge:`clang-format 14` The pack constructor initializers style to use. Possible values: @@ -3168,36 +3176,36 @@ -**PenaltyBreakAssignment** (``Unsigned``) +**PenaltyBreakAssignment** (``Unsigned``) :versionbadge:`clang-format 5` The penalty for breaking around an assignment operator. -**PenaltyBreakBeforeFirstCallParameter** (``Unsigned``) +**PenaltyBreakBeforeFirstCallParameter** (``Unsigned``) :versionbadge:`clang-format 3.7` The penalty for breaking a function call after ``call(``. -**PenaltyBreakComment** (``Unsigned``) +**PenaltyBreakComment** (``Unsigned``) :versionbadge:`clang-format 3.7` The penalty for each line break introduced inside a comment. -**PenaltyBreakFirstLessLess** (``Unsigned``) +**PenaltyBreakFirstLessLess** (``Unsigned``) :versionbadge:`clang-format 3.7` The penalty for breaking before the first ``<<``. -**PenaltyBreakString** (``Unsigned``) +**PenaltyBreakString** (``Unsigned``) :versionbadge:`clang-format 3.7` The penalty for each line break introduced inside a string literal. -**PenaltyBreakTemplateDeclaration** (``Unsigned``) +**PenaltyBreakTemplateDeclaration** (``Unsigned``) :versionbadge:`clang-format 7` The penalty for breaking after template declaration. -**PenaltyExcessCharacter** (``Unsigned``) +**PenaltyExcessCharacter** (``Unsigned``) :versionbadge:`clang-format 3.7` The penalty for each character outside of the column limit. -**PenaltyIndentedWhitespace** (``Unsigned``) +**PenaltyIndentedWhitespace** (``Unsigned``) :versionbadge:`clang-format 13` Penalty for each character of whitespace indentation (counted relative to leading non-whitespace column). -**PenaltyReturnTypeOnItsOwnLine** (``Unsigned``) +**PenaltyReturnTypeOnItsOwnLine** (``Unsigned``) :versionbadge:`clang-format 3.7` Penalty for putting the return type of a function onto its own line. -**PointerAlignment** (``PointerAlignmentStyle``) +**PointerAlignment** (``PointerAlignmentStyle``) :versionbadge:`clang-format 3.7` Pointer and reference alignment style. Possible values: @@ -3225,7 +3233,7 @@ -**QualifierAlignment** (``QualifierAlignmentStyle``) +**QualifierAlignment** (``QualifierAlignmentStyle``) :versionbadge:`clang-format 14` Different ways to arrange const/volatile qualifiers. .. warning:: @@ -3276,7 +3284,7 @@ -**QualifierOrder** (``List of Strings``) +**QualifierOrder** (``List of Strings``) :versionbadge:`clang-format 14` The Order in which the qualifiers appear. Order is a an array can contain any of the following @@ -3297,7 +3305,7 @@ QualifierOrder: ['inline', 'static', 'type', 'const', 'volatile' ] -**RawStringFormats** (``List of RawStringFormats``) +**RawStringFormats** (``List of RawStringFormats``) :versionbadge:`clang-format 6` Defines hints for detecting supported languages code blocks in raw strings. @@ -3335,7 +3343,7 @@ BasedOnStyle: llvm CanonicalDelimiter: 'cc' -**ReferenceAlignment** (``ReferenceAlignmentStyle``) +**ReferenceAlignment** (``ReferenceAlignmentStyle``) :versionbadge:`clang-format 14` Reference alignment style (overrides ``PointerAlignment`` for references). @@ -3367,7 +3375,7 @@ -**ReflowComments** (``Boolean``) +**ReflowComments** (``Boolean``) :versionbadge:`clang-format 4` If ``true``, clang-format will attempt to re-flow comments. .. code-block:: c++ @@ -3382,7 +3390,7 @@ /* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of * information */ -**ShortNamespaceLines** (``Unsigned``) +**ShortNamespaceLines** (``Unsigned``) :versionbadge:`clang-format 14` The maximal number of unwrapped lines that a short namespace spans. Defaults to 1. @@ -3404,7 +3412,7 @@ int bar; int bar; } // namespace b } // namespace b -**SortIncludes** (``SortIncludesOptions``) +**SortIncludes** (``SortIncludesOptions``) :versionbadge:`clang-format 4` 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 @@ -3449,7 +3457,7 @@ -**SortJavaStaticImport** (``SortJavaStaticImportOptions``) +**SortJavaStaticImport** (``SortJavaStaticImportOptions``) :versionbadge:`clang-format 13` 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. @@ -3476,7 +3484,7 @@ -**SortUsingDeclarations** (``Boolean``) +**SortUsingDeclarations** (``Boolean``) :versionbadge:`clang-format 5` If ``true``, clang-format will sort using declarations. The order of using declarations is defined as follows: @@ -3493,7 +3501,7 @@ using std::cout; vs. using std::cin; using std::cin; using std::cout; -**SpaceAfterCStyleCast** (``Boolean``) +**SpaceAfterCStyleCast** (``Boolean``) :versionbadge:`clang-format 3.5` If ``true``, a space is inserted after C style casts. .. code-block:: c++ @@ -3501,7 +3509,7 @@ true: false: (int) i; vs. (int)i; -**SpaceAfterLogicalNot** (``Boolean``) +**SpaceAfterLogicalNot** (``Boolean``) :versionbadge:`clang-format 9` If ``true``, a space is inserted after the logical not operator (``!``). .. code-block:: c++ @@ -3509,7 +3517,7 @@ true: false: ! someExpression(); vs. !someExpression(); -**SpaceAfterTemplateKeyword** (``Boolean``) +**SpaceAfterTemplateKeyword** (``Boolean``) :versionbadge:`clang-format 4` If ``true``, a space will be inserted after the 'template' keyword. .. code-block:: c++ @@ -3517,7 +3525,7 @@ true: false: template void foo(); vs. template void foo(); -**SpaceAroundPointerQualifiers** (``SpaceAroundPointerQualifiersStyle``) +**SpaceAroundPointerQualifiers** (``SpaceAroundPointerQualifiersStyle``) :versionbadge:`clang-format 13` Defines in which cases to put a space before or after pointer qualifiers Possible values: @@ -3557,7 +3565,7 @@ -**SpaceBeforeAssignmentOperators** (``Boolean``) +**SpaceBeforeAssignmentOperators** (``Boolean``) :versionbadge:`clang-format 3.7` If ``false``, spaces will be removed before assignment operators. .. code-block:: c++ @@ -3566,7 +3574,7 @@ int a = 5; vs. int a= 5; a += 42; a+= 42; -**SpaceBeforeCaseColon** (``Boolean``) +**SpaceBeforeCaseColon** (``Boolean``) :versionbadge:`clang-format 13` If ``false``, spaces will be removed before case colon. .. code-block:: c++ @@ -3576,7 +3584,7 @@ case 1 : break; case 1: break; } } -**SpaceBeforeCpp11BracedList** (``Boolean``) +**SpaceBeforeCpp11BracedList** (``Boolean``) :versionbadge:`clang-format 7` If ``true``, a space will be inserted before a C++11 braced list used to initialize an object (after the preceding identifier or type). @@ -3588,7 +3596,7 @@ vector { 1, 2, 3 }; vector{ 1, 2, 3 }; new int[3] { 1, 2, 3 }; new int[3]{ 1, 2, 3 }; -**SpaceBeforeCtorInitializerColon** (``Boolean``) +**SpaceBeforeCtorInitializerColon** (``Boolean``) :versionbadge:`clang-format 7` If ``false``, spaces will be removed before constructor initializer colon. @@ -3597,7 +3605,7 @@ true: false: Foo::Foo() : a(a) {} Foo::Foo(): a(a) {} -**SpaceBeforeInheritanceColon** (``Boolean``) +**SpaceBeforeInheritanceColon** (``Boolean``) :versionbadge:`clang-format 7` If ``false``, spaces will be removed before inheritance colon. .. code-block:: c++ @@ -3605,7 +3613,7 @@ true: false: class Foo : Bar {} vs. class Foo: Bar {} -**SpaceBeforeParens** (``SpaceBeforeParensOptions``) +**SpaceBeforeParens** (``SpaceBeforeParensOptions``) :versionbadge:`clang-format 3.5` Defines in which cases to put a space before opening parentheses. Possible values: @@ -3677,7 +3685,7 @@ -**SpaceBeforeRangeBasedForLoopColon** (``Boolean``) +**SpaceBeforeRangeBasedForLoopColon** (``Boolean``) :versionbadge:`clang-format 7` If ``false``, spaces will be removed before range-based for loop colon. @@ -3686,7 +3694,7 @@ true: false: for (auto v : values) {} vs. for(auto v: values) {} -**SpaceBeforeSquareBrackets** (``Boolean``) +**SpaceBeforeSquareBrackets** (``Boolean``) :versionbadge:`clang-format 11` If ``true``, spaces will be before ``[``. Lambdas will not be affected. Only the first ``[`` will get a space added. @@ -3696,7 +3704,7 @@ int a [5]; vs. int a[5]; int a [5][5]; vs. int a[5][5]; -**SpaceInEmptyBlock** (``Boolean``) +**SpaceInEmptyBlock** (``Boolean``) :versionbadge:`clang-format 11` If ``true``, spaces will be inserted into ``{}``. .. code-block:: c++ @@ -3705,7 +3713,7 @@ void f() { } vs. void f() {} while (true) { } while (true) {} -**SpaceInEmptyParentheses** (``Boolean``) +**SpaceInEmptyParentheses** (``Boolean``) :versionbadge:`clang-format 3.7` If ``true``, spaces may be inserted into ``()``. .. code-block:: c++ @@ -3718,7 +3726,7 @@ } } } } -**SpacesBeforeTrailingComments** (``Unsigned``) +**SpacesBeforeTrailingComments** (``Unsigned``) :versionbadge:`clang-format 3.7` The number of spaces before trailing line comments (``//`` - comments). @@ -3735,7 +3743,7 @@ } // foo } -**SpacesInAngles** (``SpacesInAnglesStyle``) +**SpacesInAngles** (``SpacesInAnglesStyle``) :versionbadge:`clang-format 14` The SpacesInAnglesStyle to use for template argument lists. Possible values: @@ -3762,7 +3770,7 @@ -**SpacesInCStyleCastParentheses** (``Boolean``) +**SpacesInCStyleCastParentheses** (``Boolean``) :versionbadge:`clang-format 3.7` If ``true``, spaces may be inserted into C style casts. .. code-block:: c++ @@ -3770,7 +3778,7 @@ true: false: x = ( int32 )y vs. x = (int32)y -**SpacesInConditionalStatement** (``Boolean``) +**SpacesInConditionalStatement** (``Boolean``) :versionbadge:`clang-format 11` If ``true``, spaces will be inserted around if/for/switch/while conditions. @@ -3780,7 +3788,7 @@ if ( a ) { ... } vs. if (a) { ... } while ( i < 5 ) { ... } while (i < 5) { ... } -**SpacesInContainerLiterals** (``Boolean``) +**SpacesInContainerLiterals** (``Boolean``) :versionbadge:`clang-format 3.7` If ``true``, spaces are inserted inside container literals (e.g. ObjC and Javascript array and dict literals). @@ -3790,7 +3798,7 @@ 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}); -**SpacesInLineCommentPrefix** (``SpacesInLineComment``) +**SpacesInLineCommentPrefix** (``SpacesInLineComment``) :versionbadge:`clang-format 14` How many spaces are allowed at the start of a line comment. To disable the maximum set it to ``-1``, apart from that the maximum takes precedence over the minimum. @@ -3827,7 +3835,7 @@ * ``unsigned Maximum`` The maximum number of spaces at the start of the comment. -**SpacesInParentheses** (``Boolean``) +**SpacesInParentheses** (``Boolean``) :versionbadge:`clang-format 3.7` If ``true``, spaces will be inserted after ``(`` and before ``)``. .. code-block:: c++ @@ -3835,7 +3843,7 @@ true: false: t f( Deleted & ) & = delete; vs. t f(Deleted &) & = delete; -**SpacesInSquareBrackets** (``Boolean``) +**SpacesInSquareBrackets** (``Boolean``) :versionbadge:`clang-format 3.7` If ``true``, spaces will be inserted after ``[`` and before ``]``. Lambdas without arguments or unspecified size array declarations will not be affected. @@ -3846,7 +3854,7 @@ int a[ 5 ]; vs. int a[5]; std::unique_ptr foo() {} // Won't be affected -**Standard** (``LanguageStandard``) +**Standard** (``LanguageStandard``) :versionbadge:`clang-format 3.7` Parse and format C++ constructs compatible with this standard. .. code-block:: c++ @@ -3881,7 +3889,7 @@ -**StatementAttributeLikeMacros** (``List of Strings``) +**StatementAttributeLikeMacros** (``List of Strings``) :versionbadge:`clang-format 13` Macros 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. @@ -3898,7 +3906,7 @@ unsigned char data = 'x'; emit signal(data); // Now it's fine again. -**StatementMacros** (``List of Strings``) +**StatementMacros** (``List of Strings``) :versionbadge:`clang-format 8` A vector of macros that should be interpreted as complete statements. @@ -3908,10 +3916,10 @@ For example: Q_UNUSED -**TabWidth** (``Unsigned``) +**TabWidth** (``Unsigned``) :versionbadge:`clang-format 3.7` The number of columns used for tab stops. -**TypenameMacros** (``List of Strings``) +**TypenameMacros** (``List of Strings``) :versionbadge:`clang-format 9` A vector of macros that should be interpreted as type declarations instead of as function calls. @@ -3929,11 +3937,11 @@ For example: OpenSSL STACK_OF, BSD LIST_ENTRY. -**UseCRLF** (``Boolean``) +**UseCRLF** (``Boolean``) :versionbadge:`clang-format 11` Use ``\r\n`` instead of ``\n`` for line breaks. Also used as fallback if ``DeriveLineEnding`` is true. -**UseTab** (``UseTabStyle``) +**UseTab** (``UseTabStyle``) :versionbadge:`clang-format 3.7` The way to use tab characters in the resulting file. Possible values: @@ -3958,7 +3966,7 @@ -**WhitespaceSensitiveMacros** (``List of Strings``) +**WhitespaceSensitiveMacros** (``List of Strings``) :versionbadge:`clang-format 12` A vector of macros which are whitespace-sensitive and should not be touched. diff --git a/clang/docs/tools/dump_format_style.py b/clang/docs/tools/dump_format_style.py --- a/clang/docs/tools/dump_format_style.py +++ b/clang/docs/tools/dump_format_style.py @@ -87,15 +87,20 @@ return indent + s class Option(object): - def __init__(self, name, type, comment): + def __init__(self, name, type, comment, version): self.name = name self.type = type self.comment = comment.strip() self.enum = None self.nested_struct = None + self.version = version def __str__(self): - s = '**%s** (``%s``)\n%s' % (self.name, to_yaml_type(self.type), + if self.version: + s = '**%s** (``%s``) :versionbadge:`clang-format %s`\n%s' % (self.name, to_yaml_type(self.type), self.version, + doxygen2rst(indent(self.comment, 2))) + else: + s = '**%s** (``%s``)\n%s' % (self.name, to_yaml_type(self.type), doxygen2rst(indent(self.comment, 2))) if self.enum and self.enum.values: s += indent('\n\nPossible values:\n\n%s\n' % self.enum, 2) @@ -194,6 +199,7 @@ comment = '' enum = None nested_struct = None + version = None for line in header: line = line.strip() @@ -208,7 +214,11 @@ state = State.Finished break elif state == State.InFieldComment: - if line.startswith('///'): + if line.startswith(r'/// \version'): + match = re.match(r'/// \\version\s*(?P[0-9.]+)*',line) + if match: + version = match.group('version') + elif line.startswith('///'): comment += clean_comment_line(line) elif line.startswith('enum'): state = State.InEnum @@ -222,10 +232,14 @@ state = State.InStruct field_type, field_name = re.match(r'([<>:\w(,\s)]+)\s+(\w+);', line).groups() - option = Option(str(field_name), str(field_type), comment) + + if not version: + print('Warning missing version for ', field_name) + option = Option(str(field_name), str(field_type), comment, version) options.append(option) + version=None else: - raise Exception('Invalid format, expected comment, field or enum') + raise Exception('Invalid format, expected comment, field or enum\n'+line) elif state == State.InNestedStruct: if line.startswith('///'): state = State.InNestedFieldComment diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h --- a/clang/include/clang/Format/Format.h +++ b/clang/include/clang/Format/Format.h @@ -63,6 +63,7 @@ bool InheritsParentConfig; /// The extra indent or outdent of access modifiers, e.g. ``public:``. + /// \version 3.3 int AccessModifierOffset; /// Different styles for aligning after open brackets. @@ -92,6 +93,7 @@ /// /// This applies to round brackets (parentheses), angle brackets and square /// brackets. + /// \version 3.8 BracketAlignmentStyle AlignAfterOpenBracket; /// Different style for aligning array initializers. @@ -121,6 +123,7 @@ }; /// if not ``None``, when using initialization for an array of structs /// aligns the fields into columns. + /// \version 13 ArrayInitializerAlignmentStyle AlignArrayOfStructures; /// Styles for alignment of consecutive tokens. Tokens can be assignment signs @@ -205,6 +208,7 @@ /// /* some comment */ /// #define bar(y, z) (y + z) /// \endcode + /// \version 13 AlignConsecutiveStyle AlignConsecutiveMacros; /// Style of aligning consecutive assignments. @@ -273,6 +277,7 @@ /// /* A comment. */ /// double e = 4; /// \endcode + /// \version 13 AlignConsecutiveStyle AlignConsecutiveAssignments; /// Style of aligning consecutive bit field. @@ -342,6 +347,7 @@ /// /* A comment. */ /// int ee : 3; /// \endcode + /// \version 13 AlignConsecutiveStyle AlignConsecutiveBitFields; /// Style of aligning consecutive declarations. @@ -411,6 +417,7 @@ /// /* A comment. */ /// bool c = false; /// \endcode + /// \version 13 AlignConsecutiveStyle AlignConsecutiveDeclarations; /// Different styles for aligning escaped newlines. @@ -445,6 +452,7 @@ }; /// Options for aligning backslashes in escaped newlines. + /// \version 5 EscapedNewlineAlignmentStyle AlignEscapedNewlines; /// Different styles for aligning operands. @@ -483,6 +491,7 @@ /// If ``true``, horizontally align operands of binary and ternary /// expressions. + /// \version 12 OperandAlignmentStyle AlignOperands; /// If ``true``, aligns trailing comments. @@ -491,6 +500,7 @@ /// int a; // My comment a vs. int a; // My comment a /// int b = 2; // comment b int b = 2; // comment about b /// \endcode + /// \version 3.7 bool AlignTrailingComments; /// \brief If a function call or braced initializer list doesn't fit on a @@ -507,10 +517,12 @@ /// c, /// d); /// \endcode + /// \version 9 bool AllowAllArgumentsOnNextLine; /// This option is **deprecated**. See ``NextLine`` of /// ``PackConstructorInitializers``. + /// \version 9 bool AllowAllConstructorInitializersOnNextLine; /// If the function declaration doesn't fit on a line, @@ -528,6 +540,7 @@ /// int d, /// int e); /// \endcode + /// \version 3.3 bool AllowAllParametersOfDeclarationOnNextLine; /// Allow short enums on a single line. @@ -541,6 +554,7 @@ /// B /// } myEnum; /// \endcode + /// \version 12 bool AllowShortEnumsOnASingleLine; /// Different styles for merging short blocks containing at most one @@ -573,6 +587,7 @@ /// Dependent on the value, ``while (true) { continue; }`` can be put on a /// single line. + /// \version 11 ShortBlockStyle AllowShortBlocksOnASingleLine; /// If ``true``, short case labels will be contracted to a single line. @@ -586,6 +601,7 @@ /// return; /// } /// \endcode + /// \version 3.6 bool AllowShortCaseLabelsOnASingleLine; /// Different styles for merging short functions containing at most one @@ -638,6 +654,7 @@ /// Dependent on the value, ``int f() { return 0; }`` can be put on a /// single line. + /// \version 3.5 ShortFunctionStyle AllowShortFunctionsOnASingleLine; /// Different styles for handling short if statements. @@ -708,6 +725,7 @@ }; /// Dependent on the value, ``if (a) return;`` can be put on a single line. + /// \version 9 ShortIfStyle AllowShortIfStatementsOnASingleLine; /// Different styles for merging short lambdas containing at most one @@ -741,10 +759,12 @@ /// Dependent on the value, ``auto lambda []() { return 0; }`` can be put on a /// single line. + /// \version 9 ShortLambdaStyle AllowShortLambdasOnASingleLine; /// If ``true``, ``while (true) continue;`` can be put on a single /// line. + /// \version 3.7 bool AllowShortLoopsOnASingleLine; /// Different ways to break after the function definition return type. @@ -832,9 +852,11 @@ /// The function definition return type breaking style to use. This /// option is **deprecated** and is retained for backwards compatibility. + /// \version 3.7 DefinitionReturnTypeBreakingStyle AlwaysBreakAfterDefinitionReturnType; /// The function declaration return type breaking style to use. + /// \version 3.8 ReturnTypeBreakingStyle AlwaysBreakAfterReturnType; /// If ``true``, always break before multiline string literals. @@ -849,6 +871,7 @@ /// "bbbb" "cccc"; /// "cccc"; /// \endcode + /// \version 3.4 bool AlwaysBreakBeforeMultilineStrings; /// Different ways to break after the template declaration. @@ -888,6 +911,7 @@ }; /// The template declaration breaking style to use. + /// \version 7 BreakTemplateDeclarationsStyle AlwaysBreakTemplateDeclarations; /// A vector of strings that should be interpreted as attributes/qualifiers @@ -906,6 +930,7 @@ /// AttributeMacros: ['__capability', '__output', '__ununsed'] /// \endcode /// + /// \version 13 std::vector AttributeMacros; /// If ``false``, a function call's arguments will either be all on the @@ -924,6 +949,7 @@ /// aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); /// } /// \endcode + /// \version 3.7 bool BinPackArguments; /// The style of inserting trailing commas into container literals. @@ -953,6 +979,7 @@ /// // ^ inserted /// ] /// \endcode + /// \version 12 TrailingCommaStyle InsertTrailingCommas; /// If ``false``, a function declaration's or function definition's @@ -967,6 +994,7 @@ /// int aaaaaaaaaaaaaaaaaaaa, /// int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {} /// \endcode + /// \version 3.7 bool BinPackParameters; /// The style of wrapping parameters on the same line (bin-packed) or @@ -1021,6 +1049,7 @@ }; /// The way to wrap binary operators. + /// \version 3.6 BinaryOperatorStyle BreakBeforeBinaryOperators; /// Different ways to attach braces to their surrounding context. @@ -1455,6 +1484,7 @@ }; /// The brace breaking style to use. + /// \version 3.7 BraceBreakingStyle BreakBeforeBraces; /// Different ways to wrap braces after control statements. @@ -1729,6 +1759,7 @@ /// AfterStruct: false /// SplitEmptyFunction: false /// \endcode + /// \version 3.8 BraceWrappingFlags BraceWrapping; /// If ``true``, concept will be placed on a new line. @@ -1740,6 +1771,7 @@ /// false: /// template concept ... /// \endcode + /// \version 13 bool BreakBeforeConceptDeclarations; /// If ``true``, ternary operators will be placed after line breaks. @@ -1754,6 +1786,7 @@ /// firstValue : /// SecondValueVeryVeryVeryVeryLong; /// \endcode + /// \version 3.7 bool BreakBeforeTernaryOperators; /// Different ways to break initializers. @@ -1783,6 +1816,7 @@ }; /// The break constructor initializers style to use. + /// \version 5 BreakConstructorInitializersStyle BreakConstructorInitializers; /// Break after each annotation on a field in Java files. @@ -1792,6 +1826,7 @@ /// @Mock /// DataLoad loader; /// \endcode + /// \version 3.8 bool BreakAfterJavaFieldAnnotations; /// Allow breaking string literals when formatting. @@ -1805,6 +1840,7 @@ /// const char* x = /// "veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongString"; /// \endcode + /// \version 3.9 bool BreakStringLiterals; /// The column limit. @@ -1812,6 +1848,7 @@ /// 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. + /// \version 3.7 unsigned ColumnLimit; /// A regular expression that describes comments with special meaning, @@ -1821,6 +1858,7 @@ /// // Will leave the following line unaffected /// #include // FOOBAR pragma: keep /// \endcode + /// \version 3.7 std::string CommentPragmas; /// Different const/volatile qualifier alignment styles. @@ -1862,6 +1900,7 @@ /// \warning /// ``QualifierAlignment`` COULD lead to incorrect code generation. /// \endwarning + /// \version 14 QualifierAlignmentStyle QualifierAlignment; /// The Order in which the qualifiers appear. @@ -1882,6 +1921,7 @@ /// \code{.yaml} /// QualifierOrder: ['inline', 'static', 'type', 'const', 'volatile' ] /// \endcode + /// \version 14 std::vector QualifierOrder; /// Different ways to break inheritance list. @@ -1921,6 +1961,7 @@ }; /// The inheritance list style to use. + /// \version 7 BreakInheritanceListStyle BreakInheritanceList; /// If ``true``, consecutive namespace declarations will be on the same @@ -1944,14 +1985,17 @@ /// namespace Extra { /// }}} /// \endcode + /// \version 5 bool CompactNamespaces; /// This option is **deprecated**. See ``CurrentLine`` of /// ``PackConstructorInitializers``. + /// \version 3.7 bool ConstructorInitializerAllOnOneLineOrOnePerLine; /// The number of characters to use for indentation of constructor /// initializer lists as well as inheritance lists. + /// \version 3.7 unsigned ConstructorInitializerIndentWidth; /// Indent width for line continuations. @@ -1962,6 +2006,7 @@ /// longFunction( // Again a long comment /// arg); /// \endcode + /// \version 3.7 unsigned ContinuationIndentWidth; /// If ``true``, format braced lists as best suited for C++11 braced @@ -1984,10 +2029,12 @@ /// f(MyMap[{composite, key}]); f(MyMap[{ composite, key }]); /// new int[3]{1, 2, 3}; new int[3]{ 1, 2, 3 }; /// \endcode + /// \version 3.4 bool Cpp11BracedListStyle; /// \brief Analyze the formatted file for the most used line ending (``\r\n`` /// or ``\n``). ``UseCRLF`` is only used as a fallback if none can be derived. + /// \version 11 bool DeriveLineEnding; /// If ``true``, analyze the formatted file for the most common @@ -1995,9 +2042,11 @@ /// 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. + /// \version 3.7 bool DerivePointerAlignment; /// Disables formatting completely. + /// \version 3.7 bool DisableFormat; /// Different styles for empty line after access modifiers. @@ -2048,6 +2097,7 @@ /// Defines when to put an empty line after access modifiers. /// ``EmptyLineBeforeAccessModifier`` configuration handles the number of /// empty lines between two access modifiers. + /// \version 14 EmptyLineAfterAccessModifierStyle EmptyLineAfterAccessModifier; /// Different styles for empty line before access modifiers. @@ -2110,6 +2160,7 @@ }; /// Defines in which cases to put empty line before access modifiers. + /// \version 13 EmptyLineBeforeAccessModifierStyle EmptyLineBeforeAccessModifier; /// If ``true``, clang-format detects whether function calls and @@ -2122,6 +2173,7 @@ /// /// 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. + /// \version 3.7 bool ExperimentalAutoDetectBinPacking; /// Different ways to try to fit all constructor initializers on a line. @@ -2168,6 +2220,7 @@ }; /// The pack constructor initializers style to use. + /// \version 14; PackConstructorInitializersStyle PackConstructorInitializers; /// If ``true``, clang-format adds missing namespace end comments for @@ -2180,6 +2233,7 @@ /// bar(); bar(); /// } // namespace a } /// \endcode + /// \version 5 bool FixNamespaceComments; /// A vector of macros that should be interpreted as foreach loops @@ -2197,6 +2251,7 @@ /// \endcode /// /// For example: BOOST_FOREACH. + /// \version 3.7 std::vector ForEachMacros; /// A vector of macros that should be interpreted as conditionals @@ -2217,6 +2272,7 @@ /// /// For example: `KJ_IF_MAYBE /// `_ + /// \version 14 std::vector IfMacros; /// \brief A vector of macros that should be interpreted as type declarations @@ -2233,6 +2289,7 @@ /// \endcode /// /// For example: OpenSSL STACK_OF, BSD LIST_ENTRY. + /// \version 9 std::vector TypenameMacros; /// A vector of macros that should be interpreted as complete @@ -2243,6 +2300,7 @@ /// clang-format aware of such cases. /// /// For example: Q_UNUSED + /// \version 8 std::vector StatementMacros; /// A vector of macros which are used to open namespace blocks. @@ -2255,6 +2313,7 @@ /// \endcode /// /// For example: TESTSUITE + /// \version 9 std::vector NamespaceMacros; /// A vector of macros which are whitespace-sensitive and should not @@ -2271,6 +2330,7 @@ /// \endcode /// /// For example: BOOST_PP_STRINGIZE + /// \version 12 std::vector WhitespaceSensitiveMacros; tooling::IncludeStyle IncludeStyle; @@ -2299,6 +2359,7 @@ /// return 1; return 1; /// } } /// \endcode + /// \version 13 bool IndentAccessModifiers; /// Indent case labels one level from the switch statement. @@ -2317,6 +2378,7 @@ /// plop(); plop(); /// } } /// \endcode + /// \version 3.3 bool IndentCaseLabels; /// Indent case label blocks one level from the case label. @@ -2339,6 +2401,7 @@ /// } /// } /// \endcode + /// \version 11 bool IndentCaseBlocks; /// Indent goto labels. @@ -2355,6 +2418,7 @@ /// return 1; return 1; /// } } /// \endcode + /// \version 10 bool IndentGotoLabels; /// Options for indenting preprocessor directives. @@ -2389,6 +2453,7 @@ }; /// The preprocessor directive indenting style to use. + /// \version 6 PPDirectiveIndentStyle IndentPPDirectives; /// Indents extern blocks @@ -2428,6 +2493,7 @@ }; /// IndentExternBlockStyle is the type of indenting of extern blocks. + /// \version 12 IndentExternBlockStyle IndentExternBlock; /// Indent the requires clause in a template @@ -2446,6 +2512,7 @@ /// //.... /// } /// \endcode + /// \version 13 bool IndentRequires; /// The number of columns to use for indentation. @@ -2459,6 +2526,7 @@ /// } /// } /// \endcode + /// \version 3.7 unsigned IndentWidth; /// Indent if a function definition or declaration is wrapped after the @@ -2472,6 +2540,7 @@ /// LoooooooooooooooooooooooooooooooooooooooongReturnType /// LoooooooooooooooooooooooooooooooongFunctionDeclaration(); /// \endcode + /// \version 3.7 bool IndentWrappedFunctionNames; /// A vector of prefixes ordered by the desired groups for Java imports. @@ -2505,6 +2574,7 @@ /// /// import org.example.ClassD; /// \endcode + /// \version 8 std::vector JavaImportGroups; /// Quotation styles for JavaScript strings. Does not affect template @@ -2531,6 +2601,7 @@ }; /// The JavaScriptQuoteStyle to use for JavaScript strings. + /// \version 3.9 JavaScriptQuoteStyle JavaScriptQuotes; // clang-format off @@ -2546,6 +2617,7 @@ /// false: /// import {VeryLongImportsAreAnnoying, VeryLongImportsAreAnnoying, VeryLongImportsAreAnnoying,} from "some/module.js" /// \endcode + /// \version 3.9 bool JavaScriptWrapImports; // clang-format on @@ -2557,6 +2629,7 @@ /// bar(); } /// } /// \endcode + /// \version 3.7 bool KeepEmptyLinesAtTheStartOfBlocks; /// Supported languages. @@ -2593,6 +2666,7 @@ bool isJson() const { return Language == LK_Json; } /// Language, this format style is targeted at. + /// \version 3.5 LanguageKind Language; /// Indentation logic for lambda bodies. @@ -2625,16 +2699,17 @@ /// ``OuterScope``. The KJ style guide requires ``OuterScope``. /// `KJ style guide /// `_ + /// \version 13 LambdaBodyIndentationKind LambdaBodyIndentation; /// A regular expression matching macros that start a block. /// \code /// # With: /// MacroBlockBegin: "^NS_MAP_BEGIN|\ - /// NS_TABLE_HEAD$" + /// NS_TABLE_HEAD$" /// MacroBlockEnd: "^\ - /// NS_MAP_END|\ - /// NS_TABLE_.*_END$" + /// NS_MAP_END|\ + /// NS_TABLE_.*_END$" /// /// NS_MAP_BEGIN /// foo(); @@ -2653,9 +2728,11 @@ /// bar(); /// NS_TABLE_FOO_END /// \endcode + /// \version 3.7 std::string MacroBlockBegin; /// A regular expression matching macros that end a block. + /// \version 3.7 std::string MacroBlockEnd; /// The maximum number of consecutive empty lines to keep. @@ -2669,6 +2746,7 @@ /// return i; /// } /// \endcode + /// \version 3.7 unsigned MaxEmptyLinesToKeep; /// Different ways to indent namespace contents. @@ -2706,6 +2784,7 @@ }; /// The indentation used for namespaces. + /// \version 3.7 NamespaceIndentationKind NamespaceIndentation; /// Controls bin-packing Objective-C protocol conformance list @@ -2738,6 +2817,7 @@ /// ddddddddddddd> { /// } /// \endcode + /// \version 7 BinPackStyle ObjCBinPackProtocolList; /// The number of characters to use for indentation of ObjC blocks. @@ -2748,10 +2828,12 @@ /// [self onOperationDone]; /// }]; /// \endcode + /// \version 3.7 unsigned ObjCBlockIndentWidth; /// Add a space after ``@property`` in Objective-C, i.e. use /// ``@property (readonly)`` instead of ``@property(readonly)``. + /// \version 3.7 bool ObjCSpaceAfterProperty; /// Break parameters list into lines when there is nested block @@ -2775,39 +2857,50 @@ /// }] /// } /// \endcode + /// \version 12 bool ObjCBreakBeforeNestedBlockParam; /// Add a space in front of an Objective-C protocol list, i.e. use /// ``Foo `` instead of ``Foo``. + /// \version 3.7 bool ObjCSpaceBeforeProtocolList; /// The penalty for breaking around an assignment operator. + /// \version 5 unsigned PenaltyBreakAssignment; /// The penalty for breaking a function call after ``call(``. + /// \version 3.7 unsigned PenaltyBreakBeforeFirstCallParameter; /// The penalty for each line break introduced inside a comment. + /// \version 3.7 unsigned PenaltyBreakComment; /// The penalty for breaking before the first ``<<``. + /// \version 3.7 unsigned PenaltyBreakFirstLessLess; /// The penalty for each line break introduced inside a string literal. + /// \version 3.7 unsigned PenaltyBreakString; /// The penalty for breaking after template declaration. + /// \version 7 unsigned PenaltyBreakTemplateDeclaration; /// The penalty for each character outside of the column limit. + /// \version 3.7 unsigned PenaltyExcessCharacter; /// Penalty for putting the return type of a function onto its own /// line. + /// \version 3.7 unsigned PenaltyReturnTypeOnItsOwnLine; /// Penalty for each character of whitespace indentation /// (counted relative to leading non-whitespace column). + /// \version 13 unsigned PenaltyIndentedWhitespace; /// The ``&``, ``&&`` and ``*`` alignment style. @@ -2830,6 +2923,7 @@ }; /// Pointer and reference alignment style. + /// \version 3.7 PointerAlignmentStyle PointerAlignment; /// The number of columns to use for indentation of preprocessor statements. @@ -2844,6 +2938,7 @@ /// # define BAR /// #endif /// \endcode + /// \version 14 int PPIndentWidth; /// See documentation of ``RawStringFormats``. @@ -2903,6 +2998,7 @@ /// BasedOnStyle: llvm /// CanonicalDelimiter: 'cc' /// \endcode + /// \version 6 std::vector RawStringFormats; /// \brief The ``&`` and ``&&`` alignment style. @@ -2928,6 +3024,7 @@ /// \brief Reference alignment style (overrides ``PointerAlignment`` for /// references). + /// \version 14 ReferenceAlignmentStyle ReferenceAlignment; // clang-format off @@ -2943,6 +3040,7 @@ /// /* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of /// * information */ /// \endcode + /// \version 4 bool ReflowComments; // clang-format on @@ -2965,6 +3063,7 @@ /// int bar; int bar; /// } // namespace b } // namespace b /// \endcode + /// \version 14 unsigned ShortNamespaceLines; /// Include sorting options. @@ -3004,6 +3103,7 @@ /// insensitive fashion. /// If ``CaseSensitive``, includes are sorted in an alphabetical or case /// sensitive fashion. + /// \version 4 SortIncludesOptions SortIncludes; /// Position for Java Static imports. @@ -3027,6 +3127,7 @@ /// 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. + /// \version 13 SortJavaStaticImportOptions SortJavaStaticImport; /// If ``true``, clang-format will sort using declarations. @@ -3043,6 +3144,7 @@ /// using std::cout; vs. using std::cin; /// using std::cin; using std::cout; /// \endcode + /// \version 5 bool SortUsingDeclarations; /// If ``true``, a space is inserted after C style casts. @@ -3050,6 +3152,7 @@ /// true: false: /// (int) i; vs. (int)i; /// \endcode + /// \version 3.5 bool SpaceAfterCStyleCast; /// If ``true``, a space is inserted after the logical not operator (``!``). @@ -3057,6 +3160,7 @@ /// true: false: /// ! someExpression(); vs. !someExpression(); /// \endcode + /// \version 9 bool SpaceAfterLogicalNot; /// If \c true, a space will be inserted after the 'template' keyword. @@ -3064,6 +3168,7 @@ /// true: false: /// template void foo(); vs. template void foo(); /// \endcode + /// \version 4 bool SpaceAfterTemplateKeyword; /// Different ways to put a space before opening parentheses. @@ -3096,6 +3201,7 @@ }; /// Defines in which cases to put a space before or after pointer qualifiers + /// \version 13 SpaceAroundPointerQualifiersStyle SpaceAroundPointerQualifiers; /// If ``false``, spaces will be removed before assignment operators. @@ -3104,6 +3210,7 @@ /// int a = 5; vs. int a= 5; /// a += 42; a+= 42; /// \endcode + /// \version 3.7 bool SpaceBeforeAssignmentOperators; /// If ``false``, spaces will be removed before case colon. @@ -3113,6 +3220,7 @@ /// case 1 : break; case 1: break; /// } } /// \endcode + /// \version 13 bool SpaceBeforeCaseColon; /// If ``true``, a space will be inserted before a C++11 braced list @@ -3124,6 +3232,7 @@ /// vector { 1, 2, 3 }; vector{ 1, 2, 3 }; /// new int[3] { 1, 2, 3 }; new int[3]{ 1, 2, 3 }; /// \endcode + /// \version 7 bool SpaceBeforeCpp11BracedList; /// If ``false``, spaces will be removed before constructor initializer @@ -3132,6 +3241,7 @@ /// true: false: /// Foo::Foo() : a(a) {} Foo::Foo(): a(a) {} /// \endcode + /// \version 7 bool SpaceBeforeCtorInitializerColon; /// If ``false``, spaces will be removed before inheritance colon. @@ -3139,6 +3249,7 @@ /// true: false: /// class Foo : Bar {} vs. class Foo: Bar {} /// \endcode + /// \version 7 bool SpaceBeforeInheritanceColon; /// Different ways to put a space before opening parentheses. @@ -3201,6 +3312,7 @@ }; /// Defines in which cases to put a space before opening parentheses. + /// \version 3.5 SpaceBeforeParensOptions SpaceBeforeParens; /// If ``false``, spaces will be removed before range-based for loop @@ -3209,6 +3321,7 @@ /// true: false: /// for (auto v : values) {} vs. for(auto v: values) {} /// \endcode + /// \version 7 bool SpaceBeforeRangeBasedForLoopColon; /// If ``true``, spaces will be inserted into ``{}``. @@ -3217,6 +3330,7 @@ /// void f() { } vs. void f() {} /// while (true) { } while (true) {} /// \endcode + /// \version 11 bool SpaceInEmptyBlock; /// If ``true``, spaces may be inserted into ``()``. @@ -3229,6 +3343,7 @@ /// } } /// } } /// \endcode + /// \version 3.7 bool SpaceInEmptyParentheses; /// The number of spaces before trailing line comments @@ -3245,6 +3360,7 @@ /// } // foo /// } /// \endcode + /// \version 3.7 unsigned SpacesBeforeTrailingComments; /// Styles for adding spacing after ``<`` and before ``>` @@ -3267,6 +3383,7 @@ SIAS_Leave }; /// The SpacesInAnglesStyle to use for template argument lists. + /// \version 14 SpacesInAnglesStyle SpacesInAngles; /// If ``true``, spaces will be inserted around if/for/switch/while @@ -3276,6 +3393,7 @@ /// if ( a ) { ... } vs. if (a) { ... } /// while ( i < 5 ) { ... } while (i < 5) { ... } /// \endcode + /// \version 11 bool SpacesInConditionalStatement; /// If ``true``, spaces are inserted inside container literals (e.g. @@ -3285,6 +3403,7 @@ /// 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}); /// \endcode + /// \version 3.7 bool SpacesInContainerLiterals; /// If ``true``, spaces may be inserted into C style casts. @@ -3292,6 +3411,7 @@ /// true: false: /// x = ( int32 )y vs. x = (int32)y /// \endcode + /// \version 3.7 bool SpacesInCStyleCastParentheses; /// Control of spaces within a single line comment @@ -3329,6 +3449,7 @@ /// /// - Foo /// - Foo /// /// - Bar /// - Bar /// \endcode + /// \version 14 SpacesInLineComment SpacesInLineCommentPrefix; /// If ``true``, spaces will be inserted after ``(`` and before ``)``. @@ -3336,6 +3457,7 @@ /// true: false: /// t f( Deleted & ) & = delete; vs. t f(Deleted &) & = delete; /// \endcode + /// \version 3.7 bool SpacesInParentheses; /// If ``true``, spaces will be inserted after ``[`` and before ``]``. @@ -3346,6 +3468,7 @@ /// int a[ 5 ]; vs. int a[5]; /// std::unique_ptr foo() {} // Won't be affected /// \endcode + /// \version 3.7 bool SpacesInSquareBrackets; /// If ``true``, spaces will be before ``[``. @@ -3355,6 +3478,7 @@ /// int a [5]; vs. int a[5]; /// int a [5][5]; vs. int a[5][5]; /// \endcode + /// \version 11 bool SpaceBeforeSquareBrackets; /// Styles for adding spacing around ``:`` in bitfield definitions. @@ -3383,6 +3507,7 @@ BFCS_After }; /// The BitFieldColonSpacingStyle to use for bitfields. + /// \version 13 BitFieldColonSpacingStyle BitFieldColonSpacing; /// Supported language standards for parsing and formatting C++ constructs. @@ -3417,6 +3542,7 @@ /// c++03: latest: /// vector > x; vs. vector> x; /// \endcode + /// \version 3.7 LanguageStandard Standard; /// Macros which are ignored in front of a statement, as if they were an @@ -3433,9 +3559,11 @@ /// unsigned char data = 'x'; /// emit signal(data); // Now it's fine again. /// \endcode + /// \version 13 std::vector StatementAttributeLikeMacros; /// The number of columns used for tab stops. + /// \version 3.7 unsigned TabWidth; /// Different ways to use tab in formatting. @@ -3457,9 +3585,11 @@ /// \brief Use ``\r\n`` instead of ``\n`` for line breaks. /// Also used as fallback if ``DeriveLineEnding`` is true. + /// \version 11 bool UseCRLF; /// The way to use tab characters in the resulting file. + /// \version 3.7 UseTabStyle UseTab; bool operator==(const FormatStyle &R) const { diff --git a/clang/include/clang/Tooling/Inclusions/IncludeStyle.h b/clang/include/clang/Tooling/Inclusions/IncludeStyle.h --- a/clang/include/clang/Tooling/Inclusions/IncludeStyle.h +++ b/clang/include/clang/Tooling/Inclusions/IncludeStyle.h @@ -50,6 +50,7 @@ /// Dependent on the value, multiple ``#include`` blocks can be sorted /// as one and divided based on category. + /// \version 7 IncludeBlocksStyle IncludeBlocks; /// See documentation of ``IncludeCategories``. @@ -113,6 +114,7 @@ /// Priority: 1 /// SortPriority: 0 /// \endcode + /// \version 7 std::vector IncludeCategories; /// Specify a regular expression of suffixes that are allowed in the @@ -126,6 +128,7 @@ /// /// For example, if configured to "(_test)?$", then a header a.h would be seen /// as the "main" include in both a.cc and a_test.cc. + /// \version 7 std::string IncludeIsMainRegex; /// Specify a regular expression for files being formatted @@ -146,6 +149,7 @@ /// also being respected in later phase). Without this option set, /// ``ClassImpl.hpp`` would not have the main include file put on top /// before any other include. + /// \version 7 std::string IncludeIsMainSourceRegex; };