3 This file is automatically generated, in part. Do not edit the style options
4 in this file directly. Instead, modify them in include/clang/Format/Format.h
5 and run the docs/tools/dump_format_style.py script to update this file.
9 <style type="text/css">
10 .versionbadge { background-color: #1c913d; height: 20px; display: inline-block; min-width: 120px; text-align: center; border-radius: 5px; color: #FFFFFF; font-family: "Verdana,Geneva,DejaVu Sans,sans-serif"; }
13 .. role:: versionbadge
15 ==========================
16 Clang-Format Style Options
17 ==========================
19 :doc:`ClangFormatStyleOptions` describes configurable formatting style options
20 supported by :doc:`LibFormat` and :doc:`ClangFormat`.
22 When using :program:`clang-format` command line utility or
23 ``clang::format::reformat(...)`` functions from code, one can either use one of
24 the predefined styles (LLVM, Google, Chromium, Mozilla, WebKit, Microsoft) or
25 create a custom style by configuring specific style options.
28 Configuring Style with clang-format
29 ===================================
31 :program:`clang-format` supports two ways to provide custom style options:
32 directly specify style configuration in the ``-style=`` command line option or
33 use ``-style=file`` and put style configuration in the ``.clang-format`` or
34 ``_clang-format`` file in the project directory.
36 When using ``-style=file``, :program:`clang-format` for each input file will
37 try to find the ``.clang-format`` file located in the closest parent directory
38 of the input file. When the standard input is used, the search is started from
39 the current directory.
41 When using ``-style=file:<format_file_path>``, :program:`clang-format` for
42 each input file will use the format file located at `<format_file_path>`.
43 The path may be absolute or relative to the working directory.
45 The ``.clang-format`` file uses YAML format:
54 The configuration file can consist of several sections each having different
55 ``Language:`` parameter denoting the programming language this section of the
56 configuration is targeted at. See the description of the **Language** option
57 below for the list of supported languages. The first section may have no
58 language set, it will set the default style options for all languages.
59 Configuration sections for specific language will override options set in the
62 When :program:`clang-format` formats a file, it auto-detects the language using
63 the file name. When formatting standard input or a file that doesn't have the
64 extension corresponding to its language, ``-assume-filename=`` option can be
65 used to override the file name :program:`clang-format` uses to detect the
68 An example of a configuration file for multiple languages:
73 # We'll use defaults from the LLVM style, but with 4 columns indentation.
78 # Force pointers to the type for C++.
79 DerivePointerAlignment: false
80 PointerAlignment: Left
83 # Use 100 columns for JS.
87 # Don't format .proto files.
91 # Use 100 columns for C#.
95 An easy way to get a valid ``.clang-format`` file containing all configuration
96 options of a certain predefined style is:
98 .. code-block:: console
100 clang-format -style=llvm -dump-config > .clang-format
102 When specifying configuration in the ``-style=`` option, the same configuration
103 is applied for all input files. The format of the configuration is:
105 .. code-block:: console
107 -style='{key1: value1, key2: value2, ...}'
110 Disabling Formatting on a Piece of Code
111 =======================================
113 Clang-format understands also special comments that switch formatting in a
114 delimited range. The code between a comment ``// clang-format off`` or
115 ``/* clang-format off */`` up to a comment ``// clang-format on`` or
116 ``/* clang-format on */`` will not be formatted. The comments themselves will be
117 formatted (aligned) normally. Also, a colon (``:``) and additional text may
118 follow ``// clang-format off`` or ``// clang-format on`` to explain why
119 clang-format is turned off or back on.
125 void unformatted_code ;
127 void formatted_code_again;
130 Configuring Style in Code
131 =========================
133 When using ``clang::format::reformat(...)`` functions, the format is specified
134 by supplying the `clang::format::FormatStyle
135 <https://clang.llvm.org/doxygen/structclang_1_1format_1_1FormatStyle.html>`_
139 Configurable Format Style Options
140 =================================
142 This section lists the supported style options. Value type is specified for
143 each option. For enumeration types possible values are specified both as a C++
144 enumeration member (with a prefix, e.g. ``LS_Auto``), and as a value usable in
145 the configuration (without a prefix: ``Auto``).
149 **BasedOnStyle** (``String``) :ref:`¶ <BasedOnStyle>`
150 The style used for all options not specifically set in the configuration.
152 This option is supported only in the :program:`clang-format` configuration
153 (both within ``-style='{...}'`` and the ``.clang-format`` file).
158 A style complying with the `LLVM coding standards
159 <https://llvm.org/docs/CodingStandards.html>`_
161 A style complying with `Google's C++ style guide
162 <https://google.github.io/styleguide/cppguide.html>`_
164 A style complying with `Chromium's style guide
165 <https://chromium.googlesource.com/chromium/src/+/refs/heads/main/styleguide/styleguide.md>`_
167 A style complying with `Mozilla's style guide
168 <https://firefox-source-docs.mozilla.org/code-quality/coding-style/index.html>`_
170 A style complying with `WebKit's style guide
171 <https://www.webkit.org/coding/coding-style.html>`_
173 A style complying with `Microsoft's style guide
174 <https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference>`_
176 A style complying with the `GNU coding standards
177 <https://www.gnu.org/prep/standards/standards.html>`_
178 * ``InheritParentConfig``
179 Not a real style, but allows to use the ``.clang-format`` file from the
180 parent directory (or its parent if there is none). If there is no parent
181 file found it falls back to the ``fallback`` style, and applies the changes
184 With this option you can overwrite some parts of your main style for your
185 subdirectories. This is also possible through the command line, e.g.:
186 ``--style={BasedOnStyle: InheritParentConfig, ColumnLimit: 20}``
188 .. START_FORMAT_STYLE_OPTIONS
190 .. _AccessModifierOffset:
192 **AccessModifierOffset** (``Integer``) :versionbadge:`clang-format 3.3` :ref:`¶ <AccessModifierOffset>`
193 The extra indent or outdent of access modifiers, e.g. ``public:``.
195 .. _AlignAfterOpenBracket:
197 **AlignAfterOpenBracket** (``BracketAlignmentStyle``) :versionbadge:`clang-format 3.8` :ref:`¶ <AlignAfterOpenBracket>`
198 If ``true``, horizontally aligns arguments after an open bracket.
200 This applies to round brackets (parentheses), angle brackets and square
205 * ``BAS_Align`` (in configuration: ``Align``)
206 Align parameters on the open bracket, e.g.:
210 someLongFunction(argument1,
213 * ``BAS_DontAlign`` (in configuration: ``DontAlign``)
214 Don't align, instead use ``ContinuationIndentWidth``, e.g.:
218 someLongFunction(argument1,
221 * ``BAS_AlwaysBreak`` (in configuration: ``AlwaysBreak``)
222 Always break after an open bracket, if the parameters don't fit
223 on a single line, e.g.:
228 argument1, argument2);
230 * ``BAS_BlockIndent`` (in configuration: ``BlockIndent``)
231 Always break after an open bracket, if the parameters don't fit
232 on a single line. Closing brackets will be placed on a new line.
244 This currently only applies to braced initializer lists (when
245 ``Cpp11BracedListStyle`` is ``true``) and parentheses.
249 .. _AlignArrayOfStructures:
251 **AlignArrayOfStructures** (``ArrayInitializerAlignmentStyle``) :versionbadge:`clang-format 13` :ref:`¶ <AlignArrayOfStructures>`
252 If not ``None``, when using initialization for an array of structs
253 aligns the fields into columns.
258 As of clang-format 15 this option only applied to arrays with equal
259 number of columns per row.
263 * ``AIAS_Left`` (in configuration: ``Left``)
264 Align array column and left justify the columns e.g.:
271 {-1, 93463, "world"},
275 * ``AIAS_Right`` (in configuration: ``Right``)
276 Align array column and right justify the columns e.g.:
283 {-1, 93463, "world"},
287 * ``AIAS_None`` (in configuration: ``None``)
288 Don't align array initializer columns.
292 .. _AlignConsecutiveAssignments:
294 **AlignConsecutiveAssignments** (``AlignConsecutiveStyle``) :versionbadge:`clang-format 3.8` :ref:`¶ <AlignConsecutiveAssignments>`
295 Style of aligning consecutive assignments.
297 ``Consecutive`` will result in formattings like:
302 int somelongname = 2;
305 Nested configuration flags:
309 They can also be read as a whole for compatibility. The choices are:
313 * ``AcrossEmptyLines``
315 * ``AcrossEmptyLinesAndComments``
317 For example, to align across empty lines and not across comments, either
322 AlignConsecutiveAssignments: AcrossEmptyLines
324 AlignConsecutiveAssignments:
326 AcrossEmptyLines: true
327 AcrossComments: false
329 * ``bool Enabled`` Whether aligning is enabled.
333 #define SHORT_NAME 42
334 #define LONGER_NAME 0x007f
335 #define EVEN_LONGER_NAME (2)
336 #define foo(x) (x * x)
337 #define bar(y, z) (y + z)
340 int somelongname = 2;
351 * ``bool AcrossEmptyLines`` Whether to align across empty lines.
357 int somelongname = 2;
364 int somelongname = 2;
369 * ``bool AcrossComments`` Whether to align across comments.
383 * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``. Whether compound assignments
384 like ``+=`` are aligned along with ``=``.
396 * ``bool AlignFunctionDeclarations`` Only for ``AlignConsecutiveDeclarations``. Whether function declarations
402 unsigned int f1(void);
407 unsigned int f1(void);
411 * ``bool AlignFunctionPointers`` Only for ``AlignConsecutiveDeclarations``. Whether function pointers are
428 * ``bool PadOperators`` Only for ``AlignConsecutiveAssignments``. Whether short assignment
429 operators are left-padded to the same length as long ones in order to
430 put all assignment operators to the right of the left hand side.
449 .. _AlignConsecutiveBitFields:
451 **AlignConsecutiveBitFields** (``AlignConsecutiveStyle``) :versionbadge:`clang-format 11` :ref:`¶ <AlignConsecutiveBitFields>`
452 Style of aligning consecutive bit fields.
454 ``Consecutive`` will align the bitfield separators of consecutive lines.
455 This will result in formattings like:
463 Nested configuration flags:
467 They can also be read as a whole for compatibility. The choices are:
471 * ``AcrossEmptyLines``
473 * ``AcrossEmptyLinesAndComments``
475 For example, to align across empty lines and not across comments, either
480 AlignConsecutiveBitFields: AcrossEmptyLines
482 AlignConsecutiveBitFields:
484 AcrossEmptyLines: true
485 AcrossComments: false
487 * ``bool Enabled`` Whether aligning is enabled.
491 #define SHORT_NAME 42
492 #define LONGER_NAME 0x007f
493 #define EVEN_LONGER_NAME (2)
494 #define foo(x) (x * x)
495 #define bar(y, z) (y + z)
498 int somelongname = 2;
509 * ``bool AcrossEmptyLines`` Whether to align across empty lines.
515 int somelongname = 2;
522 int somelongname = 2;
527 * ``bool AcrossComments`` Whether to align across comments.
541 * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``. Whether compound assignments
542 like ``+=`` are aligned along with ``=``.
554 * ``bool AlignFunctionDeclarations`` Only for ``AlignConsecutiveDeclarations``. Whether function declarations
560 unsigned int f1(void);
565 unsigned int f1(void);
569 * ``bool AlignFunctionPointers`` Only for ``AlignConsecutiveDeclarations``. Whether function pointers are
586 * ``bool PadOperators`` Only for ``AlignConsecutiveAssignments``. Whether short assignment
587 operators are left-padded to the same length as long ones in order to
588 put all assignment operators to the right of the left hand side.
607 .. _AlignConsecutiveDeclarations:
609 **AlignConsecutiveDeclarations** (``AlignConsecutiveStyle``) :versionbadge:`clang-format 3.8` :ref:`¶ <AlignConsecutiveDeclarations>`
610 Style of aligning consecutive declarations.
612 ``Consecutive`` will align the declaration names of consecutive lines.
613 This will result in formattings like:
621 Nested configuration flags:
625 They can also be read as a whole for compatibility. The choices are:
629 * ``AcrossEmptyLines``
631 * ``AcrossEmptyLinesAndComments``
633 For example, to align across empty lines and not across comments, either
638 AlignConsecutiveDeclarations: AcrossEmptyLines
640 AlignConsecutiveDeclarations:
642 AcrossEmptyLines: true
643 AcrossComments: false
645 * ``bool Enabled`` Whether aligning is enabled.
649 #define SHORT_NAME 42
650 #define LONGER_NAME 0x007f
651 #define EVEN_LONGER_NAME (2)
652 #define foo(x) (x * x)
653 #define bar(y, z) (y + z)
656 int somelongname = 2;
667 * ``bool AcrossEmptyLines`` Whether to align across empty lines.
673 int somelongname = 2;
680 int somelongname = 2;
685 * ``bool AcrossComments`` Whether to align across comments.
699 * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``. Whether compound assignments
700 like ``+=`` are aligned along with ``=``.
712 * ``bool AlignFunctionDeclarations`` Only for ``AlignConsecutiveDeclarations``. Whether function declarations
718 unsigned int f1(void);
723 unsigned int f1(void);
727 * ``bool AlignFunctionPointers`` Only for ``AlignConsecutiveDeclarations``. Whether function pointers are
744 * ``bool PadOperators`` Only for ``AlignConsecutiveAssignments``. Whether short assignment
745 operators are left-padded to the same length as long ones in order to
746 put all assignment operators to the right of the left hand side.
765 .. _AlignConsecutiveMacros:
767 **AlignConsecutiveMacros** (``AlignConsecutiveStyle``) :versionbadge:`clang-format 9` :ref:`¶ <AlignConsecutiveMacros>`
768 Style of aligning consecutive macro definitions.
770 ``Consecutive`` will result in formattings like:
774 #define SHORT_NAME 42
775 #define LONGER_NAME 0x007f
776 #define EVEN_LONGER_NAME (2)
777 #define foo(x) (x * x)
778 #define bar(y, z) (y + z)
780 Nested configuration flags:
784 They can also be read as a whole for compatibility. The choices are:
788 * ``AcrossEmptyLines``
790 * ``AcrossEmptyLinesAndComments``
792 For example, to align across empty lines and not across comments, either
797 AlignConsecutiveMacros: AcrossEmptyLines
799 AlignConsecutiveMacros:
801 AcrossEmptyLines: true
802 AcrossComments: false
804 * ``bool Enabled`` Whether aligning is enabled.
808 #define SHORT_NAME 42
809 #define LONGER_NAME 0x007f
810 #define EVEN_LONGER_NAME (2)
811 #define foo(x) (x * x)
812 #define bar(y, z) (y + z)
815 int somelongname = 2;
826 * ``bool AcrossEmptyLines`` Whether to align across empty lines.
832 int somelongname = 2;
839 int somelongname = 2;
844 * ``bool AcrossComments`` Whether to align across comments.
858 * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``. Whether compound assignments
859 like ``+=`` are aligned along with ``=``.
871 * ``bool AlignFunctionDeclarations`` Only for ``AlignConsecutiveDeclarations``. Whether function declarations
877 unsigned int f1(void);
882 unsigned int f1(void);
886 * ``bool AlignFunctionPointers`` Only for ``AlignConsecutiveDeclarations``. Whether function pointers are
903 * ``bool PadOperators`` Only for ``AlignConsecutiveAssignments``. Whether short assignment
904 operators are left-padded to the same length as long ones in order to
905 put all assignment operators to the right of the left hand side.
924 .. _AlignConsecutiveShortCaseStatements:
926 **AlignConsecutiveShortCaseStatements** (``ShortCaseStatementsAlignmentStyle``) :versionbadge:`clang-format 17` :ref:`¶ <AlignConsecutiveShortCaseStatements>`
927 Style of aligning consecutive short case labels.
928 Only applies if ``AllowShortCaseExpressionOnASingleLine`` or
929 ``AllowShortCaseLabelsOnASingleLine`` is ``true``.
935 AlignConsecutiveShortCaseStatements:
937 AcrossEmptyLines: true
939 AlignCaseColons: false
941 Nested configuration flags:
945 * ``bool Enabled`` Whether aligning is enabled.
951 case log::info: return "info:";
952 case log::warning: return "warning:";
958 case log::info: return "info:";
959 case log::warning: return "warning:";
963 * ``bool AcrossEmptyLines`` Whether to align across empty lines.
969 case log::info: return "info:";
970 case log::warning: return "warning:";
977 case log::info: return "info:";
978 case log::warning: return "warning:";
983 * ``bool AcrossComments`` Whether to align across comments.
989 case log::info: return "info:";
990 case log::warning: return "warning:";
997 case log::info: return "info:";
998 case log::warning: return "warning:";
1003 * ``bool AlignCaseArrows`` Whether to align the case arrows when aligning short case expressions.
1005 .. code-block:: java
1009 case THURSDAY, SATURDAY -> 8;
1010 case WEDNESDAY -> 9;
1016 case THURSDAY, SATURDAY -> 8;
1017 case WEDNESDAY -> 9;
1021 * ``bool AlignCaseColons`` Whether aligned case labels are aligned on the colon, or on the tokens
1028 case log::info : return "info:";
1029 case log::warning: return "warning:";
1030 default : return "";
1035 case log::info: return "info:";
1036 case log::warning: return "warning:";
1041 .. _AlignConsecutiveTableGenBreakingDAGArgColons:
1043 **AlignConsecutiveTableGenBreakingDAGArgColons** (``AlignConsecutiveStyle``) :versionbadge:`clang-format 19` :ref:`¶ <AlignConsecutiveTableGenBreakingDAGArgColons>`
1044 Style of aligning consecutive TableGen DAGArg operator colons.
1045 If enabled, align the colon inside DAGArg which have line break inside.
1046 This works only when TableGenBreakInsideDAGArg is BreakElements or
1047 BreakAll and the DAGArg is not excepted by
1048 TableGenBreakingDAGArgOperators's effect.
1058 Nested configuration flags:
1062 They can also be read as a whole for compatibility. The choices are:
1066 * ``AcrossEmptyLines``
1067 * ``AcrossComments``
1068 * ``AcrossEmptyLinesAndComments``
1070 For example, to align across empty lines and not across comments, either
1075 AlignConsecutiveTableGenBreakingDAGArgColons: AcrossEmptyLines
1077 AlignConsecutiveTableGenBreakingDAGArgColons:
1079 AcrossEmptyLines: true
1080 AcrossComments: false
1082 * ``bool Enabled`` Whether aligning is enabled.
1086 #define SHORT_NAME 42
1087 #define LONGER_NAME 0x007f
1088 #define EVEN_LONGER_NAME (2)
1089 #define foo(x) (x * x)
1090 #define bar(y, z) (y + z)
1093 int somelongname = 2;
1104 * ``bool AcrossEmptyLines`` Whether to align across empty lines.
1110 int somelongname = 2;
1117 int somelongname = 2;
1122 * ``bool AcrossComments`` Whether to align across comments.
1136 * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``. Whether compound assignments
1137 like ``+=`` are aligned along with ``=``.
1149 * ``bool AlignFunctionDeclarations`` Only for ``AlignConsecutiveDeclarations``. Whether function declarations
1155 unsigned int f1(void);
1160 unsigned int f1(void);
1164 * ``bool AlignFunctionPointers`` Only for ``AlignConsecutiveDeclarations``. Whether function pointers are
1181 * ``bool PadOperators`` Only for ``AlignConsecutiveAssignments``. Whether short assignment
1182 operators are left-padded to the same length as long ones in order to
1183 put all assignment operators to the right of the left hand side.
1202 .. _AlignConsecutiveTableGenCondOperatorColons:
1204 **AlignConsecutiveTableGenCondOperatorColons** (``AlignConsecutiveStyle``) :versionbadge:`clang-format 19` :ref:`¶ <AlignConsecutiveTableGenCondOperatorColons>`
1205 Style of aligning consecutive TableGen cond operator colons.
1206 Align the colons of cases inside !cond operators.
1210 !cond(!eq(size, 1) : 1,
1214 Nested configuration flags:
1218 They can also be read as a whole for compatibility. The choices are:
1222 * ``AcrossEmptyLines``
1223 * ``AcrossComments``
1224 * ``AcrossEmptyLinesAndComments``
1226 For example, to align across empty lines and not across comments, either
1231 AlignConsecutiveTableGenCondOperatorColons: AcrossEmptyLines
1233 AlignConsecutiveTableGenCondOperatorColons:
1235 AcrossEmptyLines: true
1236 AcrossComments: false
1238 * ``bool Enabled`` Whether aligning is enabled.
1242 #define SHORT_NAME 42
1243 #define LONGER_NAME 0x007f
1244 #define EVEN_LONGER_NAME (2)
1245 #define foo(x) (x * x)
1246 #define bar(y, z) (y + z)
1249 int somelongname = 2;
1260 * ``bool AcrossEmptyLines`` Whether to align across empty lines.
1266 int somelongname = 2;
1273 int somelongname = 2;
1278 * ``bool AcrossComments`` Whether to align across comments.
1292 * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``. Whether compound assignments
1293 like ``+=`` are aligned along with ``=``.
1305 * ``bool AlignFunctionDeclarations`` Only for ``AlignConsecutiveDeclarations``. Whether function declarations
1311 unsigned int f1(void);
1316 unsigned int f1(void);
1320 * ``bool AlignFunctionPointers`` Only for ``AlignConsecutiveDeclarations``. Whether function pointers are
1337 * ``bool PadOperators`` Only for ``AlignConsecutiveAssignments``. Whether short assignment
1338 operators are left-padded to the same length as long ones in order to
1339 put all assignment operators to the right of the left hand side.
1358 .. _AlignConsecutiveTableGenDefinitionColons:
1360 **AlignConsecutiveTableGenDefinitionColons** (``AlignConsecutiveStyle``) :versionbadge:`clang-format 19` :ref:`¶ <AlignConsecutiveTableGenDefinitionColons>`
1361 Style of aligning consecutive TableGen definition colons.
1362 This aligns the inheritance colons of consecutive definitions.
1367 def DefDef : Parent {}
1368 def DefDefDef : Parent {}
1370 Nested configuration flags:
1374 They can also be read as a whole for compatibility. The choices are:
1378 * ``AcrossEmptyLines``
1379 * ``AcrossComments``
1380 * ``AcrossEmptyLinesAndComments``
1382 For example, to align across empty lines and not across comments, either
1387 AlignConsecutiveTableGenDefinitionColons: AcrossEmptyLines
1389 AlignConsecutiveTableGenDefinitionColons:
1391 AcrossEmptyLines: true
1392 AcrossComments: false
1394 * ``bool Enabled`` Whether aligning is enabled.
1398 #define SHORT_NAME 42
1399 #define LONGER_NAME 0x007f
1400 #define EVEN_LONGER_NAME (2)
1401 #define foo(x) (x * x)
1402 #define bar(y, z) (y + z)
1405 int somelongname = 2;
1416 * ``bool AcrossEmptyLines`` Whether to align across empty lines.
1422 int somelongname = 2;
1429 int somelongname = 2;
1434 * ``bool AcrossComments`` Whether to align across comments.
1448 * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``. Whether compound assignments
1449 like ``+=`` are aligned along with ``=``.
1461 * ``bool AlignFunctionDeclarations`` Only for ``AlignConsecutiveDeclarations``. Whether function declarations
1467 unsigned int f1(void);
1472 unsigned int f1(void);
1476 * ``bool AlignFunctionPointers`` Only for ``AlignConsecutiveDeclarations``. Whether function pointers are
1493 * ``bool PadOperators`` Only for ``AlignConsecutiveAssignments``. Whether short assignment
1494 operators are left-padded to the same length as long ones in order to
1495 put all assignment operators to the right of the left hand side.
1514 .. _AlignEscapedNewlines:
1516 **AlignEscapedNewlines** (``EscapedNewlineAlignmentStyle``) :versionbadge:`clang-format 5` :ref:`¶ <AlignEscapedNewlines>`
1517 Options for aligning backslashes in escaped newlines.
1521 * ``ENAS_DontAlign`` (in configuration: ``DontAlign``)
1522 Don't align escaped newlines.
1531 * ``ENAS_Left`` (in configuration: ``Left``)
1532 Align escaped newlines as far left as possible.
1541 * ``ENAS_LeftWithLastLine`` (in configuration: ``LeftWithLastLine``)
1542 Align escaped newlines as far left as possible, using the last line of
1543 the preprocessor directive as the reference if it's the longest.
1552 * ``ENAS_Right`` (in configuration: ``Right``)
1553 Align escaped newlines in the right-most column.
1566 **AlignOperands** (``OperandAlignmentStyle``) :versionbadge:`clang-format 3.5` :ref:`¶ <AlignOperands>`
1567 If ``true``, horizontally align operands of binary and ternary
1572 * ``OAS_DontAlign`` (in configuration: ``DontAlign``)
1573 Do not align operands of binary and ternary expressions.
1574 The wrapped lines are indented ``ContinuationIndentWidth`` spaces from
1575 the start of the line.
1577 * ``OAS_Align`` (in configuration: ``Align``)
1578 Horizontally align operands of binary and ternary expressions.
1580 Specifically, this aligns operands of a single expression that needs
1581 to be split over multiple lines, e.g.:
1585 int aaa = bbbbbbbbbbbbbbb +
1588 When ``BreakBeforeBinaryOperators`` is set, the wrapped operator is
1589 aligned with the operand on the first line.
1593 int aaa = bbbbbbbbbbbbbbb
1596 * ``OAS_AlignAfterOperator`` (in configuration: ``AlignAfterOperator``)
1597 Horizontally align operands of binary and ternary expressions.
1599 This is similar to ``OAS_Align``, except when
1600 ``BreakBeforeBinaryOperators`` is set, the operator is un-indented so
1601 that the wrapped operand is aligned with the operand on the first line.
1605 int aaa = bbbbbbbbbbbbbbb
1610 .. _AlignTrailingComments:
1612 **AlignTrailingComments** (``TrailingCommentsAlignmentStyle``) :versionbadge:`clang-format 3.7` :ref:`¶ <AlignTrailingComments>`
1613 Control of trailing comments.
1615 The alignment stops at closing braces after a line break, and only
1616 followed by other closing braces, a (``do-``) ``while``, a lambda call, or
1622 As of clang-format 16 this option is not a bool but can be set
1623 to the options. Conventional bool options still can be parsed as before.
1626 .. code-block:: yaml
1629 AlignTrailingComments:
1633 Nested configuration flags:
1637 * ``TrailingCommentsAlignmentKinds Kind``
1638 Specifies the way to align trailing comments.
1642 * ``TCAS_Leave`` (in configuration: ``Leave``)
1643 Leave trailing comments as they are.
1651 int abcd; // comment
1653 * ``TCAS_Always`` (in configuration: ``Always``)
1654 Align trailing comments.
1662 int abcd; // comment
1664 * ``TCAS_Never`` (in configuration: ``Never``)
1665 Don't align trailing comments but other formatter applies.
1673 int abcd; // comment
1676 * ``unsigned OverEmptyLines`` How many empty lines to apply alignment.
1677 When both ``MaxEmptyLinesToKeep`` and ``OverEmptyLines`` are set to 2,
1678 it formats like below.
1684 int ab; // comments are
1687 int abcdef; // aligned
1689 When ``MaxEmptyLinesToKeep`` is set to 2 and ``OverEmptyLines`` is set
1690 to 1, it formats like below.
1699 int abcdef; // but this isn't
1702 .. _AllowAllArgumentsOnNextLine:
1704 **AllowAllArgumentsOnNextLine** (``Boolean``) :versionbadge:`clang-format 9` :ref:`¶ <AllowAllArgumentsOnNextLine>`
1705 If a function call or braced initializer list doesn't fit on a
1706 line, allow putting all arguments onto the next line, even if
1707 ``BinPackArguments`` is ``false``.
1721 .. _AllowAllConstructorInitializersOnNextLine:
1723 **AllowAllConstructorInitializersOnNextLine** (``Boolean``) :versionbadge:`clang-format 9` :ref:`¶ <AllowAllConstructorInitializersOnNextLine>`
1724 This option is **deprecated**. See ``NextLine`` of
1725 ``PackConstructorInitializers``.
1727 .. _AllowAllParametersOfDeclarationOnNextLine:
1729 **AllowAllParametersOfDeclarationOnNextLine** (``Boolean``) :versionbadge:`clang-format 3.3` :ref:`¶ <AllowAllParametersOfDeclarationOnNextLine>`
1730 If the function declaration doesn't fit on a line,
1731 allow putting all parameters of a function declaration onto
1732 the next line even if ``BinPackParameters`` is ``OnePerLine``.
1738 int a, int b, int c, int d, int e);
1741 void myFunction(int a,
1747 .. _AllowBreakBeforeNoexceptSpecifier:
1749 **AllowBreakBeforeNoexceptSpecifier** (``BreakBeforeNoexceptSpecifierStyle``) :versionbadge:`clang-format 18` :ref:`¶ <AllowBreakBeforeNoexceptSpecifier>`
1750 Controls if there could be a line break before a ``noexcept`` specifier.
1754 * ``BBNSS_Never`` (in configuration: ``Never``)
1755 No line break allowed.
1760 double arg2) noexcept;
1762 void bar(int arg1, double arg2) noexcept(
1763 noexcept(baz(arg1)) &&
1764 noexcept(baz(arg2)));
1766 * ``BBNSS_OnlyWithParen`` (in configuration: ``OnlyWithParen``)
1767 For a simple ``noexcept`` there is no line break allowed, but when we
1768 have a condition it is.
1773 double arg2) noexcept;
1775 void bar(int arg1, double arg2)
1776 noexcept(noexcept(baz(arg1)) &&
1777 noexcept(baz(arg2)));
1779 * ``BBNSS_Always`` (in configuration: ``Always``)
1780 Line breaks are allowed. But note that because of the associated
1781 penalties ``clang-format`` often prefers not to break before the
1787 double arg2) noexcept;
1789 void bar(int arg1, double arg2)
1790 noexcept(noexcept(baz(arg1)) &&
1791 noexcept(baz(arg2)));
1795 .. _AllowShortBlocksOnASingleLine:
1797 **AllowShortBlocksOnASingleLine** (``ShortBlockStyle``) :versionbadge:`clang-format 3.5` :ref:`¶ <AllowShortBlocksOnASingleLine>`
1798 Dependent on the value, ``while (true) { continue; }`` can be put on a
1803 * ``SBS_Never`` (in configuration: ``Never``)
1804 Never merge blocks into a single line.
1814 * ``SBS_Empty`` (in configuration: ``Empty``)
1815 Only merge empty blocks.
1824 * ``SBS_Always`` (in configuration: ``Always``)
1825 Always merge short blocks into a single line.
1830 while (true) { continue; }
1834 .. _AllowShortCaseExpressionOnASingleLine:
1836 **AllowShortCaseExpressionOnASingleLine** (``Boolean``) :versionbadge:`clang-format 19` :ref:`¶ <AllowShortCaseExpressionOnASingleLine>`
1837 Whether to merge a short switch labeled rule into a single line.
1839 .. code-block:: java
1842 switch (a) { vs. switch (a) {
1843 case 1 -> 1; case 1 ->
1849 .. _AllowShortCaseLabelsOnASingleLine:
1851 **AllowShortCaseLabelsOnASingleLine** (``Boolean``) :versionbadge:`clang-format 3.6` :ref:`¶ <AllowShortCaseLabelsOnASingleLine>`
1852 If ``true``, short case labels will be contracted to a single line.
1857 switch (a) { vs. switch (a) {
1858 case 1: x = 1; break; case 1:
1859 case 2: return; x = 1;
1865 .. _AllowShortCompoundRequirementOnASingleLine:
1867 **AllowShortCompoundRequirementOnASingleLine** (``Boolean``) :versionbadge:`clang-format 18` :ref:`¶ <AllowShortCompoundRequirementOnASingleLine>`
1868 Allow short compound requirement on a single line.
1873 template <typename T>
1874 concept c = requires(T x) {
1875 { x + 1 } -> std::same_as<int>;
1879 template <typename T>
1880 concept c = requires(T x) {
1883 } -> std::same_as<int>;
1886 .. _AllowShortEnumsOnASingleLine:
1888 **AllowShortEnumsOnASingleLine** (``Boolean``) :versionbadge:`clang-format 11` :ref:`¶ <AllowShortEnumsOnASingleLine>`
1889 Allow short enums on a single line.
1894 enum { A, B } myEnum;
1902 .. _AllowShortFunctionsOnASingleLine:
1904 **AllowShortFunctionsOnASingleLine** (``ShortFunctionStyle``) :versionbadge:`clang-format 3.5` :ref:`¶ <AllowShortFunctionsOnASingleLine>`
1905 Dependent on the value, ``int f() { return 0; }`` can be put on a
1910 * ``SFS_None`` (in configuration: ``None``)
1911 Never merge functions into a single line.
1913 * ``SFS_InlineOnly`` (in configuration: ``InlineOnly``)
1914 Only merge functions defined inside a class. Same as ``inline``,
1915 except it does not implies ``empty``: i.e. top level empty functions
1916 are not merged either.
1929 * ``SFS_Empty`` (in configuration: ``Empty``)
1930 Only merge empty functions.
1939 * ``SFS_Inline`` (in configuration: ``Inline``)
1940 Only merge functions defined inside a class. Implies ``empty``.
1952 * ``SFS_All`` (in configuration: ``All``)
1953 Merge all functions fitting on a single line.
1964 .. _AllowShortIfStatementsOnASingleLine:
1966 **AllowShortIfStatementsOnASingleLine** (``ShortIfStyle``) :versionbadge:`clang-format 3.3` :ref:`¶ <AllowShortIfStatementsOnASingleLine>`
1967 Dependent on the value, ``if (a) return;`` can be put on a single line.
1971 * ``SIS_Never`` (in configuration: ``Never``)
1972 Never put short ifs on the same line.
1990 * ``SIS_WithoutElse`` (in configuration: ``WithoutElse``)
1991 Put short ifs on the same line only if there is no else statement.
2008 * ``SIS_OnlyFirstIf`` (in configuration: ``OnlyFirstIf``)
2009 Put short ifs, but not else ifs nor else statements, on the same line.
2026 * ``SIS_AllIfsAndElse`` (in configuration: ``AllIfsAndElse``)
2027 Always put short ifs, else ifs and else statements on the same
2044 .. _AllowShortLambdasOnASingleLine:
2046 **AllowShortLambdasOnASingleLine** (``ShortLambdaStyle``) :versionbadge:`clang-format 9` :ref:`¶ <AllowShortLambdasOnASingleLine>`
2047 Dependent on the value, ``auto lambda []() { return 0; }`` can be put on a
2052 * ``SLS_None`` (in configuration: ``None``)
2053 Never merge lambdas into a single line.
2055 * ``SLS_Empty`` (in configuration: ``Empty``)
2056 Only merge empty lambdas.
2060 auto lambda = [](int a) {};
2061 auto lambda2 = [](int a) {
2065 * ``SLS_Inline`` (in configuration: ``Inline``)
2066 Merge lambda into a single line if the lambda is argument of a function.
2070 auto lambda = [](int x, int y) {
2073 sort(a.begin(), a.end(), [](int x, int y) { return x < y; });
2075 * ``SLS_All`` (in configuration: ``All``)
2076 Merge all lambdas fitting on a single line.
2080 auto lambda = [](int a) {};
2081 auto lambda2 = [](int a) { return a; };
2085 .. _AllowShortLoopsOnASingleLine:
2087 **AllowShortLoopsOnASingleLine** (``Boolean``) :versionbadge:`clang-format 3.7` :ref:`¶ <AllowShortLoopsOnASingleLine>`
2088 If ``true``, ``while (true) continue;`` can be put on a single
2091 .. _AllowShortNamespacesOnASingleLine:
2093 **AllowShortNamespacesOnASingleLine** (``Boolean``) :versionbadge:`clang-format 20` :ref:`¶ <AllowShortNamespacesOnASingleLine>`
2094 If ``true``, ``namespace a { class b; }`` can be put on a single line.
2096 .. _AlwaysBreakAfterDefinitionReturnType:
2098 **AlwaysBreakAfterDefinitionReturnType** (``DefinitionReturnTypeBreakingStyle``) :versionbadge:`clang-format 3.7` :ref:`¶ <AlwaysBreakAfterDefinitionReturnType>`
2099 The function definition return type breaking style to use. This
2100 option is **deprecated** and is retained for backwards compatibility.
2104 * ``DRTBS_None`` (in configuration: ``None``)
2105 Break after return type automatically.
2106 ``PenaltyReturnTypeOnItsOwnLine`` is taken into account.
2108 * ``DRTBS_All`` (in configuration: ``All``)
2109 Always break after the return type.
2111 * ``DRTBS_TopLevel`` (in configuration: ``TopLevel``)
2112 Always break after the return types of top-level functions.
2116 .. _AlwaysBreakAfterReturnType:
2118 **AlwaysBreakAfterReturnType** (``deprecated``) :versionbadge:`clang-format 3.8` :ref:`¶ <AlwaysBreakAfterReturnType>`
2119 This option is renamed to ``BreakAfterReturnType``.
2121 .. _AlwaysBreakBeforeMultilineStrings:
2123 **AlwaysBreakBeforeMultilineStrings** (``Boolean``) :versionbadge:`clang-format 3.4` :ref:`¶ <AlwaysBreakBeforeMultilineStrings>`
2124 If ``true``, always break before multiline string literals.
2126 This flag is mean to make cases where there are multiple multiline strings
2127 in a file look more consistent. Thus, it will only take effect if wrapping
2128 the string at that point leads to it being indented
2129 ``ContinuationIndentWidth`` spaces from the start of the line.
2134 aaaa = vs. aaaa = "bbbb"
2138 .. _AlwaysBreakTemplateDeclarations:
2140 **AlwaysBreakTemplateDeclarations** (``deprecated``) :versionbadge:`clang-format 3.4` :ref:`¶ <AlwaysBreakTemplateDeclarations>`
2141 This option is renamed to ``BreakTemplateDeclarations``.
2143 .. _AttributeMacros:
2145 **AttributeMacros** (``List of Strings``) :versionbadge:`clang-format 12` :ref:`¶ <AttributeMacros>`
2146 A vector of strings that should be interpreted as attributes/qualifiers
2147 instead of identifiers. This can be useful for language extensions or
2148 static analyzer annotations.
2154 x = (char *__capability)&y;
2155 int function(void) __unused;
2156 void only_writes_to_buffer(char *__output buffer);
2158 In the .clang-format configuration file, this can be configured like:
2160 .. code-block:: yaml
2162 AttributeMacros: [__capability, __output, __unused]
2164 .. _BinPackArguments:
2166 **BinPackArguments** (``Boolean``) :versionbadge:`clang-format 3.7` :ref:`¶ <BinPackArguments>`
2167 If ``false``, a function call's arguments will either be all on the
2168 same line or will have one line each.
2174 f(aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa,
2175 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
2180 f(aaaaaaaaaaaaaaaaaaaa,
2181 aaaaaaaaaaaaaaaaaaaa,
2182 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
2185 .. _BinPackParameters:
2187 **BinPackParameters** (``BinPackParametersStyle``) :versionbadge:`clang-format 3.7` :ref:`¶ <BinPackParameters>`
2188 The bin pack parameters style to use.
2192 * ``BPPS_BinPack`` (in configuration: ``BinPack``)
2193 Bin-pack parameters.
2197 void f(int a, int bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
2198 int ccccccccccccccccccccccccccccccccccccccccccc);
2200 * ``BPPS_OnePerLine`` (in configuration: ``OnePerLine``)
2201 Put all parameters on the current line if they fit.
2202 Otherwise, put each one on its own line.
2206 void f(int a, int b, int c);
2210 int ccccccccccccccccccccccccccccccccccccc);
2212 * ``BPPS_AlwaysOnePerLine`` (in configuration: ``AlwaysOnePerLine``)
2213 Always put each parameter on its own line.
2223 .. _BitFieldColonSpacing:
2225 **BitFieldColonSpacing** (``BitFieldColonSpacingStyle``) :versionbadge:`clang-format 12` :ref:`¶ <BitFieldColonSpacing>`
2226 The BitFieldColonSpacingStyle to use for bitfields.
2230 * ``BFCS_Both`` (in configuration: ``Both``)
2231 Add one space on each side of the ``:``
2237 * ``BFCS_None`` (in configuration: ``None``)
2238 Add no space around the ``:`` (except when needed for
2239 ``AlignConsecutiveBitFields``).
2245 * ``BFCS_Before`` (in configuration: ``Before``)
2246 Add space before the ``:`` only
2252 * ``BFCS_After`` (in configuration: ``After``)
2253 Add space after the ``:`` only (space may be added before if
2254 needed for ``AlignConsecutiveBitFields``).
2264 **BraceWrapping** (``BraceWrappingFlags``) :versionbadge:`clang-format 3.8` :ref:`¶ <BraceWrapping>`
2265 Control of individual brace wrapping cases.
2267 If ``BreakBeforeBraces`` is set to ``Custom``, use this to specify how
2268 each individual brace case should be handled. Otherwise, this is ignored.
2270 .. code-block:: yaml
2273 BreakBeforeBraces: Custom
2277 SplitEmptyFunction: false
2279 Nested configuration flags:
2281 Precise control over the wrapping of braces.
2285 # Should be declared this way:
2286 BreakBeforeBraces: Custom
2290 * ``bool AfterCaseLabel`` Wrap case labels.
2295 switch (foo) { vs. switch (foo) {
2307 * ``bool AfterClass`` Wrap class definitions.
2318 * ``BraceWrappingAfterControlStatementStyle AfterControlStatement``
2319 Wrap control statements (``if``/``for``/``while``/``switch``/..).
2323 * ``BWACS_Never`` (in configuration: ``Never``)
2324 Never wrap braces after a control statement.
2331 for (int i = 0; i < 10; ++i) {
2334 * ``BWACS_MultiLine`` (in configuration: ``MultiLine``)
2335 Only wrap braces after a multi-line control statement.
2344 while (foo || bar) {
2347 * ``BWACS_Always`` (in configuration: ``Always``)
2348 Always wrap braces after a control statement.
2356 for (int i = 0; i < 10; ++i)
2360 * ``bool AfterEnum`` Wrap enum definitions.
2373 * ``bool AfterFunction`` Wrap function definitions.
2390 * ``bool AfterNamespace`` Wrap namespace definitions.
2407 * ``bool AfterObjCDeclaration`` Wrap ObjC definitions (interfaces, implementations...).
2411 @autoreleasepool and @synchronized blocks are wrapped
2412 according to ``AfterControlStatement`` flag.
2414 * ``bool AfterStruct`` Wrap struct definitions.
2429 * ``bool AfterUnion`` Wrap union definitions.
2444 * ``bool AfterExternBlock`` Wrap extern blocks.
2459 * ``bool BeforeCatch`` Wrap before ``catch``.
2476 * ``bool BeforeElse`` Wrap before ``else``.
2491 * ``bool BeforeLambdaBody`` Wrap lambda block.
2509 * ``bool BeforeWhile`` Wrap before ``while``.
2524 * ``bool IndentBraces`` Indent the wrapped braces themselves.
2526 * ``bool SplitEmptyFunction`` If ``false``, empty function body can be put on a single line.
2527 This option is used only if the opening brace of the function has
2528 already been wrapped, i.e. the ``AfterFunction`` brace wrapping mode is
2529 set, and the function could/should not be put on a single line (as per
2530 ``AllowShortFunctionsOnASingleLine`` and constructor formatting
2540 * ``bool SplitEmptyRecord`` If ``false``, empty record (e.g. class, struct or union) body
2541 can be put on a single line. This option is used only if the opening
2542 brace of the record has already been wrapped, i.e. the ``AfterClass``
2543 (for classes) brace wrapping mode is set.
2548 class Foo vs. class Foo
2552 * ``bool SplitEmptyNamespace`` If ``false``, empty namespace body can be put on a single line.
2553 This option is used only if the opening brace of the namespace has
2554 already been wrapped, i.e. the ``AfterNamespace`` brace wrapping mode is
2560 namespace Foo vs. namespace Foo
2565 .. _BracedInitializerIndentWidth:
2567 **BracedInitializerIndentWidth** (``Unsigned``) :versionbadge:`clang-format 17` :ref:`¶ <BracedInitializerIndentWidth>`
2568 The number of columns to use to indent the contents of braced init lists.
2569 If unset, ``ContinuationIndentWidth`` is used.
2573 AlignAfterOpenBracket: AlwaysBreak
2574 BracedInitializerIndentWidth: 2
2582 auto s = SomeStruct{
2600 .. _BreakAdjacentStringLiterals:
2602 **BreakAdjacentStringLiterals** (``Boolean``) :versionbadge:`clang-format 18` :ref:`¶ <BreakAdjacentStringLiterals>`
2603 Break between adjacent string literals.
2613 return "Code" "\0\52\26\55\55\0" "x013" "\02\xBA";
2615 .. _BreakAfterAttributes:
2617 **BreakAfterAttributes** (``AttributeBreakingStyle``) :versionbadge:`clang-format 16` :ref:`¶ <BreakAfterAttributes>`
2618 Break after a group of C++11 attributes before variable or function
2619 (including constructor/destructor) declaration/definition names or before
2620 control statements, i.e. ``if``, ``switch`` (including ``case`` and
2621 ``default`` labels), ``for``, and ``while`` statements.
2625 * ``ABS_Always`` (in configuration: ``Always``)
2626 Always break after attributes.
2632 [[gnu::const]] [[maybe_unused]]
2637 [[gnu::const]] [[nodiscard]]
2656 * ``ABS_Leave`` (in configuration: ``Leave``)
2657 Leave the line breaking after attributes as is.
2661 [[maybe_unused]] const int i;
2662 [[gnu::const]] [[maybe_unused]]
2665 [[nodiscard]] inline int f();
2666 [[gnu::const]] [[nodiscard]]
2675 [[unlikely]] case 1:
2683 * ``ABS_Never`` (in configuration: ``Never``)
2684 Never break after attributes.
2688 [[maybe_unused]] const int i;
2689 [[gnu::const]] [[maybe_unused]] int j;
2691 [[nodiscard]] inline int f();
2692 [[gnu::const]] [[nodiscard]] int g();
2700 [[unlikely]] case 1:
2709 .. _BreakAfterJavaFieldAnnotations:
2711 **BreakAfterJavaFieldAnnotations** (``Boolean``) :versionbadge:`clang-format 3.8` :ref:`¶ <BreakAfterJavaFieldAnnotations>`
2712 Break after each annotation on a field in Java files.
2714 .. code-block:: java
2717 @Partial vs. @Partial @Mock DataLoad loader;
2721 .. _BreakAfterReturnType:
2723 **BreakAfterReturnType** (``ReturnTypeBreakingStyle``) :versionbadge:`clang-format 19` :ref:`¶ <BreakAfterReturnType>`
2724 The function declaration return type breaking style to use.
2728 * ``RTBS_None`` (in configuration: ``None``)
2729 This is **deprecated**. See ``Automatic`` below.
2731 * ``RTBS_Automatic`` (in configuration: ``Automatic``)
2732 Break after return type based on ``PenaltyReturnTypeOnItsOwnLine``.
2737 int f() { return 0; };
2740 int f() { return 1; }
2742 LongName::AnotherLongName();
2744 * ``RTBS_ExceptShortType`` (in configuration: ``ExceptShortType``)
2745 Same as ``Automatic`` above, except that there is no break after short
2751 int f() { return 0; };
2754 int f() { return 1; }
2758 * ``RTBS_All`` (in configuration: ``All``)
2759 Always break after the return type.
2776 LongName::AnotherLongName();
2778 * ``RTBS_TopLevel`` (in configuration: ``TopLevel``)
2779 Always break after the return types of top-level functions.
2784 int f() { return 0; };
2793 LongName::AnotherLongName();
2795 * ``RTBS_AllDefinitions`` (in configuration: ``AllDefinitions``)
2796 Always break after the return type of function definitions.
2812 LongName::AnotherLongName();
2814 * ``RTBS_TopLevelDefinitions`` (in configuration: ``TopLevelDefinitions``)
2815 Always break after the return type of top-level definitions.
2820 int f() { return 0; };
2828 LongName::AnotherLongName();
2834 **BreakArrays** (``Boolean``) :versionbadge:`clang-format 16` :ref:`¶ <BreakArrays>`
2835 If ``true``, clang-format will always break after a Json array ``[``
2836 otherwise it will scan until the closing ``]`` to determine if it should
2837 add newlines between elements (prettier compatible).
2842 This is currently only for formatting JSON.
2854 .. _BreakBeforeBinaryOperators:
2856 **BreakBeforeBinaryOperators** (``BinaryOperatorStyle``) :versionbadge:`clang-format 3.6` :ref:`¶ <BreakBeforeBinaryOperators>`
2857 The way to wrap binary operators.
2861 * ``BOS_None`` (in configuration: ``None``)
2862 Break after operators.
2866 LooooooooooongType loooooooooooooooooooooongVariable =
2867 someLooooooooooooooooongFunction();
2869 bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
2870 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ==
2871 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &&
2872 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa >
2873 ccccccccccccccccccccccccccccccccccccccccc;
2875 * ``BOS_NonAssignment`` (in configuration: ``NonAssignment``)
2876 Break before operators that aren't assignments.
2880 LooooooooooongType loooooooooooooooooooooongVariable =
2881 someLooooooooooooooooongFunction();
2883 bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
2884 + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
2885 == aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
2886 && aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
2887 > ccccccccccccccccccccccccccccccccccccccccc;
2889 * ``BOS_All`` (in configuration: ``All``)
2890 Break before operators.
2894 LooooooooooongType loooooooooooooooooooooongVariable
2895 = someLooooooooooooooooongFunction();
2897 bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
2898 + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
2899 == aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
2900 && aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
2901 > ccccccccccccccccccccccccccccccccccccccccc;
2905 .. _BreakBeforeBraces:
2907 **BreakBeforeBraces** (``BraceBreakingStyle``) :versionbadge:`clang-format 3.7` :ref:`¶ <BreakBeforeBraces>`
2908 The brace breaking style to use.
2912 * ``BS_Attach`` (in configuration: ``Attach``)
2913 Always attach braces to surrounding context.
2956 void bar() { foo(true); }
2959 * ``BS_Linux`` (in configuration: ``Linux``)
2960 Like ``Attach``, but break before braces on function, namespace and
3008 void bar() { foo(true); }
3011 * ``BS_Mozilla`` (in configuration: ``Mozilla``)
3012 Like ``Attach``, but break before braces on enum, function, and record
3060 void bar() { foo(true); }
3063 * ``BS_Stroustrup`` (in configuration: ``Stroustrup``)
3064 Like ``Attach``, but break before function definitions, ``catch``, and
3112 void bar() { foo(true); }
3115 * ``BS_Allman`` (in configuration: ``Allman``)
3116 Always break before braces.
3174 void bar() { foo(true); }
3177 * ``BS_Whitesmiths`` (in configuration: ``Whitesmiths``)
3178 Like ``Allman`` but always indent braces and line up code with braces.
3236 void bar() { foo(true); }
3239 * ``BS_GNU`` (in configuration: ``GNU``)
3240 Always break before braces and add an extra level of indentation to
3241 braces of control statements, not to those of class, function
3242 or other definitions.
3301 void bar() { foo(true); }
3304 * ``BS_WebKit`` (in configuration: ``WebKit``)
3305 Like ``Attach``, but break before functions.
3350 void bar() { foo(true); }
3353 * ``BS_Custom`` (in configuration: ``Custom``)
3354 Configure each individual brace in ``BraceWrapping``.
3358 .. _BreakBeforeConceptDeclarations:
3360 **BreakBeforeConceptDeclarations** (``BreakBeforeConceptDeclarationsStyle``) :versionbadge:`clang-format 12` :ref:`¶ <BreakBeforeConceptDeclarations>`
3361 The concept declaration style to use.
3365 * ``BBCDS_Never`` (in configuration: ``Never``)
3366 Keep the template declaration line together with ``concept``.
3370 template <typename T> concept C = ...;
3372 * ``BBCDS_Allowed`` (in configuration: ``Allowed``)
3373 Breaking between template declaration and ``concept`` is allowed. The
3374 actual behavior depends on the content and line breaking rules and
3377 * ``BBCDS_Always`` (in configuration: ``Always``)
3378 Always break before ``concept``, putting it in the line after the
3379 template declaration.
3383 template <typename T>
3388 .. _BreakBeforeInlineASMColon:
3390 **BreakBeforeInlineASMColon** (``BreakBeforeInlineASMColonStyle``) :versionbadge:`clang-format 16` :ref:`¶ <BreakBeforeInlineASMColon>`
3391 The inline ASM colon style to use.
3395 * ``BBIAS_Never`` (in configuration: ``Never``)
3396 No break before inline ASM colon.
3400 asm volatile("string", : : val);
3402 * ``BBIAS_OnlyMultiline`` (in configuration: ``OnlyMultiline``)
3403 Break before inline ASM colon if the line length is longer than column
3408 asm volatile("string", : : val);
3409 asm("cmoveq %1, %2, %[result]"
3410 : [result] "=r"(result)
3411 : "r"(test), "r"(new), "[result]"(old));
3413 * ``BBIAS_Always`` (in configuration: ``Always``)
3414 Always break before inline ASM colon.
3418 asm volatile("string",
3424 .. _BreakBeforeTernaryOperators:
3426 **BreakBeforeTernaryOperators** (``Boolean``) :versionbadge:`clang-format 3.7` :ref:`¶ <BreakBeforeTernaryOperators>`
3427 If ``true``, ternary operators will be placed after line breaks.
3432 veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongDescription
3434 : SecondValueVeryVeryVeryVeryLong;
3437 veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongDescription ?
3439 SecondValueVeryVeryVeryVeryLong;
3441 .. _BreakBinaryOperations:
3443 **BreakBinaryOperations** (``BreakBinaryOperationsStyle``) :versionbadge:`clang-format 20` :ref:`¶ <BreakBinaryOperations>`
3444 The break binary operations style to use.
3448 * ``BBO_Never`` (in configuration: ``Never``)
3449 Don't break binary operations
3453 aaa + bbbb * ccccc - ddddd +
3456 * ``BBO_OnePerLine`` (in configuration: ``OnePerLine``)
3457 Binary operations will either be all on the same line, or each operation
3458 will have one line each.
3468 * ``BBO_RespectPrecedence`` (in configuration: ``RespectPrecedence``)
3469 Binary operations of a particular precedence that exceed the column
3470 limit will have one line each.
3481 .. _BreakConstructorInitializers:
3483 **BreakConstructorInitializers** (``BreakConstructorInitializersStyle``) :versionbadge:`clang-format 5` :ref:`¶ <BreakConstructorInitializers>`
3484 The break constructor initializers style to use.
3488 * ``BCIS_BeforeColon`` (in configuration: ``BeforeColon``)
3489 Break constructor initializers before the colon and after the commas.
3497 * ``BCIS_BeforeComma`` (in configuration: ``BeforeComma``)
3498 Break constructor initializers before the colon and commas, and align
3499 the commas with the colon.
3507 * ``BCIS_AfterColon`` (in configuration: ``AfterColon``)
3508 Break constructor initializers after the colon and commas.
3518 .. _BreakFunctionDefinitionParameters:
3520 **BreakFunctionDefinitionParameters** (``Boolean``) :versionbadge:`clang-format 19` :ref:`¶ <BreakFunctionDefinitionParameters>`
3521 If ``true``, clang-format will always break before function definition
3527 void functionDefinition(
3531 void functionDefinition(int A, int B) {}
3533 .. _BreakInheritanceList:
3535 **BreakInheritanceList** (``BreakInheritanceListStyle``) :versionbadge:`clang-format 7` :ref:`¶ <BreakInheritanceList>`
3536 The inheritance list style to use.
3540 * ``BILS_BeforeColon`` (in configuration: ``BeforeColon``)
3541 Break inheritance list before the colon and after the commas.
3550 * ``BILS_BeforeComma`` (in configuration: ``BeforeComma``)
3551 Break inheritance list before the colon and commas, and align
3552 the commas with the colon.
3561 * ``BILS_AfterColon`` (in configuration: ``AfterColon``)
3562 Break inheritance list after the colon and commas.
3571 * ``BILS_AfterComma`` (in configuration: ``AfterComma``)
3572 Break inheritance list only after the commas.
3582 .. _BreakStringLiterals:
3584 **BreakStringLiterals** (``Boolean``) :versionbadge:`clang-format 3.9` :ref:`¶ <BreakStringLiterals>`
3585 Allow breaking string literals when formatting.
3587 In C, C++, and Objective-C:
3592 const char* x = "veryVeryVeryVeryVeryVe"
3593 "ryVeryVeryVeryVeryVery"
3598 "veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongString";
3605 string x = "veryVeryVeryVeryVeryVe" +
3606 "ryVeryVeryVeryVeryVery" +
3611 "veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongString";
3613 C# interpolated strings are not broken.
3620 string x = {"veryVeryVeryVeryVeryVe",
3621 "ryVeryVeryVeryVeryVery",
3626 "veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongString";
3628 .. _BreakTemplateDeclarations:
3630 **BreakTemplateDeclarations** (``BreakTemplateDeclarationsStyle``) :versionbadge:`clang-format 19` :ref:`¶ <BreakTemplateDeclarations>`
3631 The template declaration breaking style to use.
3635 * ``BTDS_Leave`` (in configuration: ``Leave``)
3636 Do not change the line breaking before the declaration.
3640 template <typename T>
3643 template <typename T> T foo(int aaaaaaaaaaaaaaaaaaaaa,
3644 int bbbbbbbbbbbbbbbbbbbbb) {
3647 * ``BTDS_No`` (in configuration: ``No``)
3648 Do not force break before declaration.
3649 ``PenaltyBreakTemplateDeclaration`` is taken into account.
3653 template <typename T> T foo() {
3655 template <typename T> T foo(int aaaaaaaaaaaaaaaaaaaaa,
3656 int bbbbbbbbbbbbbbbbbbbbb) {
3659 * ``BTDS_MultiLine`` (in configuration: ``MultiLine``)
3660 Force break after template declaration only when the following
3661 declaration spans multiple lines.
3665 template <typename T> T foo() {
3667 template <typename T>
3668 T foo(int aaaaaaaaaaaaaaaaaaaaa,
3669 int bbbbbbbbbbbbbbbbbbbbb) {
3672 * ``BTDS_Yes`` (in configuration: ``Yes``)
3673 Always break after template declaration.
3677 template <typename T>
3680 template <typename T>
3681 T foo(int aaaaaaaaaaaaaaaaaaaaa,
3682 int bbbbbbbbbbbbbbbbbbbbb) {
3689 **ColumnLimit** (``Unsigned``) :versionbadge:`clang-format 3.7` :ref:`¶ <ColumnLimit>`
3692 A column limit of ``0`` means that there is no column limit. In this case,
3693 clang-format will respect the input's line breaking decisions within
3694 statements unless they contradict other rules.
3698 **CommentPragmas** (``String``) :versionbadge:`clang-format 3.7` :ref:`¶ <CommentPragmas>`
3699 A regular expression that describes comments with special meaning,
3700 which should not be split into lines or otherwise changed.
3704 // CommentPragmas: '^ FOOBAR pragma:'
3705 // Will leave the following line unaffected
3706 #include <vector> // FOOBAR pragma: keep
3708 .. _CompactNamespaces:
3710 **CompactNamespaces** (``Boolean``) :versionbadge:`clang-format 5` :ref:`¶ <CompactNamespaces>`
3711 If ``true``, consecutive namespace declarations will be on the same
3712 line. If ``false``, each namespace is declared on a new line.
3717 namespace Foo { namespace Bar {
3726 If it does not fit on a single line, the overflowing namespaces get
3731 namespace Foo { namespace Bar {
3735 .. _ConstructorInitializerAllOnOneLineOrOnePerLine:
3737 **ConstructorInitializerAllOnOneLineOrOnePerLine** (``Boolean``) :versionbadge:`clang-format 3.7` :ref:`¶ <ConstructorInitializerAllOnOneLineOrOnePerLine>`
3738 This option is **deprecated**. See ``CurrentLine`` of
3739 ``PackConstructorInitializers``.
3741 .. _ConstructorInitializerIndentWidth:
3743 **ConstructorInitializerIndentWidth** (``Unsigned``) :versionbadge:`clang-format 3.7` :ref:`¶ <ConstructorInitializerIndentWidth>`
3744 The number of characters to use for indentation of constructor
3745 initializer lists as well as inheritance lists.
3747 .. _ContinuationIndentWidth:
3749 **ContinuationIndentWidth** (``Unsigned``) :versionbadge:`clang-format 3.7` :ref:`¶ <ContinuationIndentWidth>`
3750 Indent width for line continuations.
3754 ContinuationIndentWidth: 2
3756 int i = // VeryVeryVeryVeryVeryLongComment
3757 longFunction( // Again a long comment
3760 .. _Cpp11BracedListStyle:
3762 **Cpp11BracedListStyle** (``Boolean``) :versionbadge:`clang-format 3.4` :ref:`¶ <Cpp11BracedListStyle>`
3763 If ``true``, format braced lists as best suited for C++11 braced
3766 Important differences:
3768 * No spaces inside the braced list.
3769 * No line break before the closing brace.
3770 * Indentation with the continuation indent, not with the block indent.
3772 Fundamentally, C++11 braced lists are formatted exactly like function
3773 calls would be formatted in their place. If the braced list follows a name
3774 (e.g. a type or variable name), clang-format formats as if the ``{}`` were
3775 the parentheses of a function call with that name. If there is no name,
3776 a zero-length name is assumed.
3781 vector<int> x{1, 2, 3, 4}; vs. vector<int> x{ 1, 2, 3, 4 };
3782 vector<T> x{{}, {}, {}, {}}; vector<T> x{ {}, {}, {}, {} };
3783 f(MyMap[{composite, key}]); f(MyMap[{ composite, key }]);
3784 new int[3]{1, 2, 3}; new int[3]{ 1, 2, 3 };
3786 .. _DeriveLineEnding:
3788 **DeriveLineEnding** (``Boolean``) :versionbadge:`clang-format 10` :ref:`¶ <DeriveLineEnding>`
3789 This option is **deprecated**. See ``DeriveLF`` and ``DeriveCRLF`` of
3792 .. _DerivePointerAlignment:
3794 **DerivePointerAlignment** (``Boolean``) :versionbadge:`clang-format 3.7` :ref:`¶ <DerivePointerAlignment>`
3795 If ``true``, analyze the formatted file for the most common
3796 alignment of ``&`` and ``*``.
3797 Pointer and reference alignment styles are going to be updated according
3798 to the preferences found in the file.
3799 ``PointerAlignment`` is then used only as fallback.
3803 **DisableFormat** (``Boolean``) :versionbadge:`clang-format 3.7` :ref:`¶ <DisableFormat>`
3804 Disables formatting completely.
3806 .. _EmptyLineAfterAccessModifier:
3808 **EmptyLineAfterAccessModifier** (``EmptyLineAfterAccessModifierStyle``) :versionbadge:`clang-format 13` :ref:`¶ <EmptyLineAfterAccessModifier>`
3809 Defines when to put an empty line after access modifiers.
3810 ``EmptyLineBeforeAccessModifier`` configuration handles the number of
3811 empty lines between two access modifiers.
3815 * ``ELAAMS_Never`` (in configuration: ``Never``)
3816 Remove all empty lines after access modifiers.
3832 * ``ELAAMS_Leave`` (in configuration: ``Leave``)
3833 Keep existing empty lines after access modifiers.
3834 MaxEmptyLinesToKeep is applied instead.
3836 * ``ELAAMS_Always`` (in configuration: ``Always``)
3837 Always add empty line after access modifiers if there are none.
3838 MaxEmptyLinesToKeep is applied also.
3861 .. _EmptyLineBeforeAccessModifier:
3863 **EmptyLineBeforeAccessModifier** (``EmptyLineBeforeAccessModifierStyle``) :versionbadge:`clang-format 12` :ref:`¶ <EmptyLineBeforeAccessModifier>`
3864 Defines in which cases to put empty line before access modifiers.
3868 * ``ELBAMS_Never`` (in configuration: ``Never``)
3869 Remove all empty lines before access modifiers.
3885 * ``ELBAMS_Leave`` (in configuration: ``Leave``)
3886 Keep existing empty lines before access modifiers.
3888 * ``ELBAMS_LogicalBlock`` (in configuration: ``LogicalBlock``)
3889 Add empty line only when access modifier starts a new logical block.
3890 Logical block is a group of one or more member fields or functions.
3908 * ``ELBAMS_Always`` (in configuration: ``Always``)
3909 Always add empty line before access modifiers unless access modifier
3910 is at the start of struct or class definition.
3932 .. _ExperimentalAutoDetectBinPacking:
3934 **ExperimentalAutoDetectBinPacking** (``Boolean``) :versionbadge:`clang-format 3.7` :ref:`¶ <ExperimentalAutoDetectBinPacking>`
3935 If ``true``, clang-format detects whether function calls and
3936 definitions are formatted with one parameter per line.
3938 Each call can be bin-packed, one-per-line or inconclusive. If it is
3939 inconclusive, e.g. completely on one line, but a decision needs to be
3940 made, clang-format analyzes whether there are other bin-packed cases in
3941 the input file and act accordingly.
3946 This is an experimental flag, that might go away or be renamed. Do
3947 not use this in config files, etc. Use at your own risk.
3949 .. _FixNamespaceComments:
3951 **FixNamespaceComments** (``Boolean``) :versionbadge:`clang-format 5` :ref:`¶ <FixNamespaceComments>`
3952 If ``true``, clang-format adds missing namespace end comments for
3953 namespaces and fixes invalid existing ones. This doesn't affect short
3954 namespaces, which are controlled by ``ShortNamespaceLines``.
3959 namespace longNamespace { vs. namespace longNamespace {
3960 void foo(); void foo();
3961 void bar(); void bar();
3963 namespace shortNamespace { namespace shortNamespace {
3964 void baz(); void baz();
3969 **ForEachMacros** (``List of Strings``) :versionbadge:`clang-format 3.7` :ref:`¶ <ForEachMacros>`
3970 A vector of macros that should be interpreted as foreach loops
3971 instead of as function calls.
3973 These are expected to be macros of the form:
3977 FOREACH(<variable-declaration>, ...)
3980 In the .clang-format configuration file, this can be configured like:
3982 .. code-block:: yaml
3984 ForEachMacros: [RANGES_FOR, FOREACH]
3986 For example: BOOST_FOREACH.
3990 **IfMacros** (``List of Strings``) :versionbadge:`clang-format 13` :ref:`¶ <IfMacros>`
3991 A vector of macros that should be interpreted as conditionals
3992 instead of as function calls.
3994 These are expected to be macros of the form:
4003 In the .clang-format configuration file, this can be configured like:
4005 .. code-block:: yaml
4009 For example: `KJ_IF_MAYBE
4010 <https://github.com/capnproto/capnproto/blob/master/kjdoc/tour.md#maybes>`_
4014 **IncludeBlocks** (``IncludeBlocksStyle``) :versionbadge:`clang-format 6` :ref:`¶ <IncludeBlocks>`
4015 Dependent on the value, multiple ``#include`` blocks can be sorted
4016 as one and divided based on category.
4020 * ``IBS_Preserve`` (in configuration: ``Preserve``)
4021 Sort each ``#include`` block separately.
4025 #include "b.h" into #include "b.h"
4027 #include <lib/main.h> #include "a.h"
4028 #include "a.h" #include <lib/main.h>
4030 * ``IBS_Merge`` (in configuration: ``Merge``)
4031 Merge multiple ``#include`` blocks together and sort as one.
4035 #include "b.h" into #include "a.h"
4037 #include <lib/main.h> #include <lib/main.h>
4040 * ``IBS_Regroup`` (in configuration: ``Regroup``)
4041 Merge multiple ``#include`` blocks together and sort as one.
4042 Then split into groups based on category priority. See
4043 ``IncludeCategories``.
4047 #include "b.h" into #include "a.h"
4049 #include <lib/main.h>
4050 #include "a.h" #include <lib/main.h>
4054 .. _IncludeCategories:
4056 **IncludeCategories** (``List of IncludeCategories``) :versionbadge:`clang-format 3.8` :ref:`¶ <IncludeCategories>`
4057 Regular expressions denoting the different ``#include`` categories
4058 used for ordering ``#includes``.
4061 <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html>`_
4062 regular expressions are supported.
4064 These regular expressions are matched against the filename of an include
4065 (including the <> or "") in order. The value belonging to the first
4066 matching regular expression is assigned and ``#includes`` are sorted first
4067 according to increasing category number and then alphabetically within
4070 If none of the regular expressions match, INT_MAX is assigned as
4071 category. The main header for a source file automatically gets category 0.
4072 so that it is generally kept at the beginning of the ``#includes``
4073 (https://llvm.org/docs/CodingStandards.html#include-style). However, you
4074 can also assign negative priorities if you have certain headers that
4075 always need to be first.
4077 There is a third and optional field ``SortPriority`` which can used while
4078 ``IncludeBlocks = IBS_Regroup`` to define the priority in which
4079 ``#includes`` should be ordered. The value of ``Priority`` defines the
4080 order of ``#include blocks`` and also allows the grouping of ``#includes``
4081 of different priority. ``SortPriority`` is set to the value of
4082 ``Priority`` as default if it is not assigned.
4084 Each regular expression can be marked as case sensitive with the field
4085 ``CaseSensitive``, per default it is not.
4087 To configure this in the .clang-format file, use:
4089 .. code-block:: yaml
4092 - Regex: '^"(llvm|llvm-c|clang|clang-c)/'
4096 - Regex: '^((<|")(gtest|gmock|isl|json)/)'
4098 - Regex: '<[[:alnum:].]+>'
4104 .. _IncludeIsMainRegex:
4106 **IncludeIsMainRegex** (``String``) :versionbadge:`clang-format 3.9` :ref:`¶ <IncludeIsMainRegex>`
4107 Specify a regular expression of suffixes that are allowed in the
4108 file-to-main-include mapping.
4110 When guessing whether a #include is the "main" include (to assign
4111 category 0, see above), use this regex of allowed suffixes to the header
4112 stem. A partial match is done, so that:
4113 * ``""`` means "arbitrary suffix"
4114 * ``"$"`` means "no suffix"
4116 For example, if configured to ``"(_test)?$"``, then a header a.h would be seen
4117 as the "main" include in both a.cc and a_test.cc.
4119 .. _IncludeIsMainSourceRegex:
4121 **IncludeIsMainSourceRegex** (``String``) :versionbadge:`clang-format 10` :ref:`¶ <IncludeIsMainSourceRegex>`
4122 Specify a regular expression for files being formatted
4123 that are allowed to be considered "main" in the
4124 file-to-main-include mapping.
4126 By default, clang-format considers files as "main" only when they end
4127 with: ``.c``, ``.cc``, ``.cpp``, ``.c++``, ``.cxx``, ``.m`` or ``.mm``
4129 For these files a guessing of "main" include takes place
4130 (to assign category 0, see above). This config option allows for
4131 additional suffixes and extensions for files to be considered as "main".
4133 For example, if this option is configured to ``(Impl\.hpp)$``,
4134 then a file ``ClassImpl.hpp`` is considered "main" (in addition to
4135 ``Class.c``, ``Class.cc``, ``Class.cpp`` and so on) and "main
4136 include file" logic will be executed (with *IncludeIsMainRegex* setting
4137 also being respected in later phase). Without this option set,
4138 ``ClassImpl.hpp`` would not have the main include file put on top
4139 before any other include.
4141 .. _IndentAccessModifiers:
4143 **IndentAccessModifiers** (``Boolean``) :versionbadge:`clang-format 13` :ref:`¶ <IndentAccessModifiers>`
4144 Specify whether access modifiers should have their own indentation level.
4146 When ``false``, access modifiers are indented (or outdented) relative to
4147 the record members, respecting the ``AccessModifierOffset``. Record
4148 members are indented one level below the record.
4149 When ``true``, access modifiers get their own indentation level. As a
4150 consequence, record members are always indented 2 levels below the record,
4151 regardless of the access modifier presence. Value of the
4152 ``AccessModifierOffset`` is ignored.
4157 class C { vs. class C {
4159 void bar(); void bar();
4160 protected: protected:
4166 void foo() { void foo() {
4170 .. _IndentCaseBlocks:
4172 **IndentCaseBlocks** (``Boolean``) :versionbadge:`clang-format 11` :ref:`¶ <IndentCaseBlocks>`
4173 Indent case label blocks one level from the case label.
4175 When ``false``, the block following the case label uses the same
4176 indentation level as for the case label, treating the case label the same
4178 When ``true``, the block gets indented as a scope block.
4183 switch (fool) { vs. switch (fool) {
4195 .. _IndentCaseLabels:
4197 **IndentCaseLabels** (``Boolean``) :versionbadge:`clang-format 3.3` :ref:`¶ <IndentCaseLabels>`
4198 Indent case labels one level from the switch statement.
4200 When ``false``, use the same indentation level as for the switch
4201 statement. Switch statement body is always indented one level more than
4202 case labels (except the first block following the case label, which
4203 itself indents the code - unless IndentCaseBlocks is enabled).
4208 switch (fool) { vs. switch (fool) {
4216 .. _IndentExportBlock:
4218 **IndentExportBlock** (``Boolean``) :versionbadge:`clang-format 20` :ref:`¶ <IndentExportBlock>`
4219 If ``true``, clang-format will indent the body of an ``export { ... }``
4220 block. This doesn't affect the formatting of anything else related to
4221 exported declarations.
4226 export { vs. export {
4227 void foo(); void foo();
4228 void bar(); void bar();
4231 .. _IndentExternBlock:
4233 **IndentExternBlock** (``IndentExternBlockStyle``) :versionbadge:`clang-format 11` :ref:`¶ <IndentExternBlock>`
4234 IndentExternBlockStyle is the type of indenting of extern blocks.
4238 * ``IEBS_AfterExternBlock`` (in configuration: ``AfterExternBlock``)
4239 Backwards compatible with AfterExternBlock's indenting.
4243 IndentExternBlock: AfterExternBlock
4244 BraceWrapping.AfterExternBlock: true
4253 IndentExternBlock: AfterExternBlock
4254 BraceWrapping.AfterExternBlock: false
4259 * ``IEBS_NoIndent`` (in configuration: ``NoIndent``)
4260 Does not indent extern blocks.
4268 * ``IEBS_Indent`` (in configuration: ``Indent``)
4269 Indents extern blocks.
4279 .. _IndentGotoLabels:
4281 **IndentGotoLabels** (``Boolean``) :versionbadge:`clang-format 10` :ref:`¶ <IndentGotoLabels>`
4284 When ``false``, goto labels are flushed left.
4289 int f() { vs. int f() {
4290 if (foo()) { if (foo()) {
4298 .. _IndentPPDirectives:
4300 **IndentPPDirectives** (``PPDirectiveIndentStyle``) :versionbadge:`clang-format 6` :ref:`¶ <IndentPPDirectives>`
4301 The preprocessor directive indenting style to use.
4305 * ``PPDIS_None`` (in configuration: ``None``)
4306 Does not indent any directives.
4316 * ``PPDIS_AfterHash`` (in configuration: ``AfterHash``)
4317 Indents directives after the hash.
4327 * ``PPDIS_BeforeHash`` (in configuration: ``BeforeHash``)
4328 Indents directives before the hash.
4340 .. _IndentRequiresClause:
4342 **IndentRequiresClause** (``Boolean``) :versionbadge:`clang-format 15` :ref:`¶ <IndentRequiresClause>`
4343 Indent the requires clause in a template. This only applies when
4344 ``RequiresClausePosition`` is ``OwnLine``, ``OwnLineWithBrace``,
4345 or ``WithFollowing``.
4347 In clang-format 12, 13 and 14 it was named ``IndentRequires``.
4352 template <typename It>
4353 requires Iterator<It>
4354 void sort(It begin, It end) {
4359 template <typename It>
4360 requires Iterator<It>
4361 void sort(It begin, It end) {
4367 **IndentWidth** (``Unsigned``) :versionbadge:`clang-format 3.7` :ref:`¶ <IndentWidth>`
4368 The number of columns to use for indentation.
4381 .. _IndentWrappedFunctionNames:
4383 **IndentWrappedFunctionNames** (``Boolean``) :versionbadge:`clang-format 3.7` :ref:`¶ <IndentWrappedFunctionNames>`
4384 Indent if a function definition or declaration is wrapped after the
4390 LoooooooooooooooooooooooooooooooooooooooongReturnType
4391 LoooooooooooooooooooooooooooooooongFunctionDeclaration();
4394 LoooooooooooooooooooooooooooooooooooooooongReturnType
4395 LoooooooooooooooooooooooooooooooongFunctionDeclaration();
4399 **InsertBraces** (``Boolean``) :versionbadge:`clang-format 15` :ref:`¶ <InsertBraces>`
4400 Insert braces after control statements (``if``, ``else``, ``for``, ``do``,
4401 and ``while``) in C++ unless the control statements are inside macro
4402 definitions or the braces would enclose preprocessor directives.
4406 Setting this option to ``true`` could lead to incorrect code formatting
4407 due to clang-format's lack of complete semantic information. As such,
4408 extra care should be taken to review code changes made by this option.
4414 if (isa<FunctionDecl>(D)) vs. if (isa<FunctionDecl>(D)) {
4415 handleFunctionDecl(D); handleFunctionDecl(D);
4416 else if (isa<VarDecl>(D)) } else if (isa<VarDecl>(D)) {
4417 handleVarDecl(D); handleVarDecl(D);
4422 while (i--) vs. while (i--) {
4423 for (auto *A : D.attrs()) for (auto *A : D.attrs()) {
4424 handleAttr(A); handleAttr(A);
4430 while (i); } while (i);
4432 .. _InsertNewlineAtEOF:
4434 **InsertNewlineAtEOF** (``Boolean``) :versionbadge:`clang-format 16` :ref:`¶ <InsertNewlineAtEOF>`
4435 Insert a newline at end of file if missing.
4437 .. _InsertTrailingCommas:
4439 **InsertTrailingCommas** (``TrailingCommaStyle``) :versionbadge:`clang-format 11` :ref:`¶ <InsertTrailingCommas>`
4440 If set to ``TCS_Wrapped`` will insert trailing commas in container
4441 literals (arrays and objects) that wrap across multiple lines.
4442 It is currently only available for JavaScript
4443 and disabled by default ``TCS_None``.
4444 ``InsertTrailingCommas`` cannot be used together with ``BinPackArguments``
4445 as inserting the comma disables bin-packing.
4451 aaaaaaaaaaaaaaaaaaaaaaaaaa,
4452 aaaaaaaaaaaaaaaaaaaaaaaaaa,
4453 aaaaaaaaaaaaaaaaaaaaaaaaaa,
4459 * ``TCS_None`` (in configuration: ``None``)
4460 Do not insert trailing commas.
4462 * ``TCS_Wrapped`` (in configuration: ``Wrapped``)
4463 Insert trailing commas in container literals that were wrapped over
4464 multiple lines. Note that this is conceptually incompatible with
4465 bin-packing, because the trailing comma is used as an indicator
4466 that a container should be formatted one-per-line (i.e. not bin-packed).
4467 So inserting a trailing comma counteracts bin-packing.
4471 .. _IntegerLiteralSeparator:
4473 **IntegerLiteralSeparator** (``IntegerLiteralSeparatorStyle``) :versionbadge:`clang-format 16` :ref:`¶ <IntegerLiteralSeparator>`
4474 Format integer literal separators (``'`` for C++ and ``_`` for C#, Java,
4477 Nested configuration flags:
4479 Separator format of integer literals of different bases.
4481 If negative, remove separators. If ``0``, leave the literal as is. If
4482 positive, insert separators between digits starting from the rightmost
4485 For example, the config below will leave separators in binary literals
4486 alone, insert separators in decimal literals to separate the digits into
4487 groups of 3, and remove separators in hexadecimal literals.
4491 IntegerLiteralSeparator:
4496 You can also specify a minimum number of digits (``BinaryMinDigits``,
4497 ``DecimalMinDigits``, and ``HexMinDigits``) the integer literal must
4498 have in order for the separators to be inserted.
4500 * ``int8_t Binary`` Format separators in binary literals.
4502 .. code-block:: text
4504 /* -1: */ b = 0b100111101101;
4505 /* 0: */ b = 0b10011'11'0110'1;
4506 /* 3: */ b = 0b100'111'101'101;
4507 /* 4: */ b = 0b1001'1110'1101;
4509 * ``int8_t BinaryMinDigits`` Format separators in binary literals with a minimum number of digits.
4511 .. code-block:: text
4514 // BinaryMinDigits: 7
4518 * ``int8_t Decimal`` Format separators in decimal literals.
4520 .. code-block:: text
4522 /* -1: */ d = 18446744073709550592ull;
4523 /* 0: */ d = 184467'440737'0'95505'92ull;
4524 /* 3: */ d = 18'446'744'073'709'550'592ull;
4526 * ``int8_t DecimalMinDigits`` Format separators in decimal literals with a minimum number of digits.
4528 .. code-block:: text
4531 // DecimalMinDigits: 5
4535 * ``int8_t Hex`` Format separators in hexadecimal literals.
4537 .. code-block:: text
4539 /* -1: */ h = 0xDEADBEEFDEADBEEFuz;
4540 /* 0: */ h = 0xDEAD'BEEF'DE'AD'BEE'Fuz;
4541 /* 2: */ h = 0xDE'AD'BE'EF'DE'AD'BE'EFuz;
4543 * ``int8_t HexMinDigits`` Format separators in hexadecimal literals with a minimum number of
4546 .. code-block:: text
4554 .. _JavaImportGroups:
4556 **JavaImportGroups** (``List of Strings``) :versionbadge:`clang-format 8` :ref:`¶ <JavaImportGroups>`
4557 A vector of prefixes ordered by the desired groups for Java imports.
4559 One group's prefix can be a subset of another - the longest prefix is
4560 always matched. Within a group, the imports are ordered lexicographically.
4561 Static imports are grouped separately and follow the same group rules.
4562 By default, static imports are placed before non-static imports,
4563 but this behavior is changed by another option,
4564 ``SortJavaStaticImport``.
4566 In the .clang-format configuration file, this can be configured like
4567 in the following yaml example. This will result in imports being
4568 formatted as in the Java example below.
4570 .. code-block:: yaml
4572 JavaImportGroups: [com.example, com, org]
4575 .. code-block:: java
4577 import static com.example.function1;
4579 import static com.test.function2;
4581 import static org.example.function3;
4583 import com.example.ClassA;
4584 import com.example.Test;
4585 import com.example.a.ClassB;
4587 import com.test.ClassC;
4589 import org.example.ClassD;
4591 .. _JavaScriptQuotes:
4593 **JavaScriptQuotes** (``JavaScriptQuoteStyle``) :versionbadge:`clang-format 3.9` :ref:`¶ <JavaScriptQuotes>`
4594 The JavaScriptQuoteStyle to use for JavaScript strings.
4598 * ``JSQS_Leave`` (in configuration: ``Leave``)
4599 Leave string quotes as they are.
4606 * ``JSQS_Single`` (in configuration: ``Single``)
4607 Always use single quotes.
4614 * ``JSQS_Double`` (in configuration: ``Double``)
4615 Always use double quotes.
4624 .. _JavaScriptWrapImports:
4626 **JavaScriptWrapImports** (``Boolean``) :versionbadge:`clang-format 3.9` :ref:`¶ <JavaScriptWrapImports>`
4627 Whether to wrap JavaScript import/export statements.
4633 VeryLongImportsAreAnnoying,
4634 VeryLongImportsAreAnnoying,
4635 VeryLongImportsAreAnnoying,
4636 } from "some/module.js"
4639 import {VeryLongImportsAreAnnoying, VeryLongImportsAreAnnoying, VeryLongImportsAreAnnoying,} from "some/module.js"
4643 **KeepEmptyLines** (``KeepEmptyLinesStyle``) :versionbadge:`clang-format 19` :ref:`¶ <KeepEmptyLines>`
4644 Which empty lines are kept. See ``MaxEmptyLinesToKeep`` for how many
4645 consecutive empty lines are kept.
4647 Nested configuration flags:
4649 Options regarding which empty lines are kept.
4651 For example, the config below will remove empty lines at start of the
4652 file, end of the file, and start of blocks.
4659 AtStartOfBlock: false
4660 AtStartOfFile: false
4662 * ``bool AtEndOfFile`` Keep empty lines at end of file.
4664 * ``bool AtStartOfBlock`` Keep empty lines at start of a block.
4669 if (foo) { vs. if (foo) {
4674 * ``bool AtStartOfFile`` Keep empty lines at start of file.
4677 .. _KeepEmptyLinesAtEOF:
4679 **KeepEmptyLinesAtEOF** (``Boolean``) :versionbadge:`clang-format 17` :ref:`¶ <KeepEmptyLinesAtEOF>`
4680 This option is **deprecated**. See ``AtEndOfFile`` of ``KeepEmptyLines``.
4682 .. _KeepEmptyLinesAtTheStartOfBlocks:
4684 **KeepEmptyLinesAtTheStartOfBlocks** (``Boolean``) :versionbadge:`clang-format 3.7` :ref:`¶ <KeepEmptyLinesAtTheStartOfBlocks>`
4685 This option is **deprecated**. See ``AtStartOfBlock`` of
4690 **KeepFormFeed** (``Boolean``) :versionbadge:`clang-format 20` :ref:`¶ <KeepFormFeed>`
4691 Keep the form feed character if it's immediately preceded and followed by
4692 a newline. Multiple form feeds and newlines within a whitespace range are
4693 replaced with a single newline and form feed followed by the remaining
4696 .. _LambdaBodyIndentation:
4698 **LambdaBodyIndentation** (``LambdaBodyIndentationKind``) :versionbadge:`clang-format 13` :ref:`¶ <LambdaBodyIndentation>`
4699 The indentation style of lambda bodies. ``Signature`` (the default)
4700 causes the lambda body to be indented one additional level relative to
4701 the indentation level of the signature. ``OuterScope`` forces the lambda
4702 body to be indented one additional level relative to the parent scope
4703 containing the lambda signature.
4707 * ``LBI_Signature`` (in configuration: ``Signature``)
4708 Align lambda body relative to the lambda signature. This is the default.
4713 [](SomeReallyLongLambdaSignatureArgument foo) {
4717 * ``LBI_OuterScope`` (in configuration: ``OuterScope``)
4718 For statements within block scope, align lambda body relative to the
4719 indentation level of the outer scope the lambda signature resides in.
4724 [](SomeReallyLongLambdaSignatureArgument foo) {
4728 someMethod(someOtherMethod(
4729 [](SomeReallyLongLambdaSignatureArgument foo) {
4737 **Language** (``LanguageKind``) :versionbadge:`clang-format 3.5` :ref:`¶ <Language>`
4738 Language, this format style is targeted at.
4742 * ``LK_None`` (in configuration: ``None``)
4745 * ``LK_Cpp`` (in configuration: ``Cpp``)
4746 Should be used for C, C++.
4748 * ``LK_CSharp`` (in configuration: ``CSharp``)
4749 Should be used for C#.
4751 * ``LK_Java`` (in configuration: ``Java``)
4752 Should be used for Java.
4754 * ``LK_JavaScript`` (in configuration: ``JavaScript``)
4755 Should be used for JavaScript.
4757 * ``LK_Json`` (in configuration: ``Json``)
4758 Should be used for JSON.
4760 * ``LK_ObjC`` (in configuration: ``ObjC``)
4761 Should be used for Objective-C, Objective-C++.
4763 * ``LK_Proto`` (in configuration: ``Proto``)
4764 Should be used for Protocol Buffers
4765 (https://developers.google.com/protocol-buffers/).
4767 * ``LK_TableGen`` (in configuration: ``TableGen``)
4768 Should be used for TableGen code.
4770 * ``LK_TextProto`` (in configuration: ``TextProto``)
4771 Should be used for Protocol Buffer messages in text format
4772 (https://developers.google.com/protocol-buffers/).
4774 * ``LK_Verilog`` (in configuration: ``Verilog``)
4775 Should be used for Verilog and SystemVerilog.
4776 https://standards.ieee.org/ieee/1800/6700/
4777 https://sci-hub.st/10.1109/IEEESTD.2018.8299595
4783 **LineEnding** (``LineEndingStyle``) :versionbadge:`clang-format 16` :ref:`¶ <LineEnding>`
4784 Line ending style (``\n`` or ``\r\n``) to use.
4788 * ``LE_LF`` (in configuration: ``LF``)
4791 * ``LE_CRLF`` (in configuration: ``CRLF``)
4794 * ``LE_DeriveLF`` (in configuration: ``DeriveLF``)
4795 Use ``\n`` unless the input has more lines ending in ``\r\n``.
4797 * ``LE_DeriveCRLF`` (in configuration: ``DeriveCRLF``)
4798 Use ``\r\n`` unless the input has more lines ending in ``\n``.
4802 .. _MacroBlockBegin:
4804 **MacroBlockBegin** (``String``) :versionbadge:`clang-format 3.7` :ref:`¶ <MacroBlockBegin>`
4805 A regular expression matching macros that start a block.
4810 MacroBlockBegin: "^NS_MAP_BEGIN|\
4835 **MacroBlockEnd** (``String``) :versionbadge:`clang-format 3.7` :ref:`¶ <MacroBlockEnd>`
4836 A regular expression matching macros that end a block.
4840 **Macros** (``List of Strings``) :versionbadge:`clang-format 17` :ref:`¶ <Macros>`
4841 A list of macros of the form ``<definition>=<expansion>`` .
4843 Code will be parsed with macros expanded, in order to determine how to
4844 interpret and format the macro arguments.
4846 For example, the code:
4852 will usually be interpreted as a call to a function A, and the
4853 multiplication expression will be formatted as ``a * b``.
4855 If we specify the macro definition:
4857 .. code-block:: yaml
4862 the code will now be parsed as a declaration of the variable b of type a*,
4863 and formatted as ``a* b`` (depending on pointer-binding rules).
4865 Features and restrictions:
4866 * Both function-like macros and object-like macros are supported.
4867 * Macro arguments must be used exactly once in the expansion.
4868 * No recursive expansion; macros referencing other macros will be
4870 * Overloading by arity is supported: for example, given the macro
4871 definitions A=x, A()=y, A(a)=a
4879 A(a, b); // will not be expanded.
4881 .. _MainIncludeChar:
4883 **MainIncludeChar** (``MainIncludeCharDiscriminator``) :versionbadge:`clang-format 19` :ref:`¶ <MainIncludeChar>`
4884 When guessing whether a #include is the "main" include, only the include
4885 directives that use the specified character are considered.
4889 * ``MICD_Quote`` (in configuration: ``Quote``)
4890 Main include uses quotes: ``#include "foo.hpp"`` (the default).
4892 * ``MICD_AngleBracket`` (in configuration: ``AngleBracket``)
4893 Main include uses angle brackets: ``#include <foo.hpp>``.
4895 * ``MICD_Any`` (in configuration: ``Any``)
4896 Main include uses either quotes or angle brackets.
4900 .. _MaxEmptyLinesToKeep:
4902 **MaxEmptyLinesToKeep** (``Unsigned``) :versionbadge:`clang-format 3.7` :ref:`¶ <MaxEmptyLinesToKeep>`
4903 The maximum number of consecutive empty lines to keep.
4907 MaxEmptyLinesToKeep: 1 vs. MaxEmptyLinesToKeep: 0
4911 i = foo(); return i;
4916 .. _NamespaceIndentation:
4918 **NamespaceIndentation** (``NamespaceIndentationKind``) :versionbadge:`clang-format 3.7` :ref:`¶ <NamespaceIndentation>`
4919 The indentation used for namespaces.
4923 * ``NI_None`` (in configuration: ``None``)
4924 Don't indent in namespaces.
4935 * ``NI_Inner`` (in configuration: ``Inner``)
4936 Indent only in inner namespaces (nested in other namespaces).
4947 * ``NI_All`` (in configuration: ``All``)
4948 Indent in all namespaces.
4961 .. _NamespaceMacros:
4963 **NamespaceMacros** (``List of Strings``) :versionbadge:`clang-format 9` :ref:`¶ <NamespaceMacros>`
4964 A vector of macros which are used to open namespace blocks.
4966 These are expected to be macros of the form:
4970 NAMESPACE(<namespace-name>, ...) {
4974 For example: TESTSUITE
4976 .. _ObjCBinPackProtocolList:
4978 **ObjCBinPackProtocolList** (``BinPackStyle``) :versionbadge:`clang-format 7` :ref:`¶ <ObjCBinPackProtocolList>`
4979 Controls bin-packing Objective-C protocol conformance list
4980 items into as few lines as possible when they go over ``ColumnLimit``.
4982 If ``Auto`` (the default), delegates to the value in
4983 ``BinPackParameters``. If that is ``BinPack``, bin-packs Objective-C
4984 protocol conformance list items into as few lines as possible
4985 whenever they go over ``ColumnLimit``.
4987 If ``Always``, always bin-packs Objective-C protocol conformance
4988 list items into as few lines as possible whenever they go over
4991 If ``Never``, lays out Objective-C protocol conformance list items
4992 onto individual lines whenever they go over ``ColumnLimit``.
4995 .. code-block:: objc
4997 Always (or Auto, if BinPackParameters==BinPack):
4998 @interface ccccccccccccc () <
4999 ccccccccccccc, ccccccccccccc,
5000 ccccccccccccc, ccccccccccccc> {
5003 Never (or Auto, if BinPackParameters!=BinPack):
5004 @interface ddddddddddddd () <
5013 * ``BPS_Auto`` (in configuration: ``Auto``)
5014 Automatically determine parameter bin-packing behavior.
5016 * ``BPS_Always`` (in configuration: ``Always``)
5017 Always bin-pack parameters.
5019 * ``BPS_Never`` (in configuration: ``Never``)
5020 Never bin-pack parameters.
5024 .. _ObjCBlockIndentWidth:
5026 **ObjCBlockIndentWidth** (``Unsigned``) :versionbadge:`clang-format 3.7` :ref:`¶ <ObjCBlockIndentWidth>`
5027 The number of characters to use for indentation of ObjC blocks.
5029 .. code-block:: objc
5031 ObjCBlockIndentWidth: 4
5033 [operation setCompletionBlock:^{
5034 [self onOperationDone];
5037 .. _ObjCBreakBeforeNestedBlockParam:
5039 **ObjCBreakBeforeNestedBlockParam** (``Boolean``) :versionbadge:`clang-format 11` :ref:`¶ <ObjCBreakBeforeNestedBlockParam>`
5040 Break parameters list into lines when there is nested block
5041 parameters in a function call.
5048 [self.test1 t:self w:self callback:^(typeof(self) self, NSNumber
5058 callback:^(typeof(self) self, NSNumber *u, NSNumber *v) {
5063 .. _ObjCPropertyAttributeOrder:
5065 **ObjCPropertyAttributeOrder** (``List of Strings``) :versionbadge:`clang-format 18` :ref:`¶ <ObjCPropertyAttributeOrder>`
5066 The order in which ObjC property attributes should appear.
5068 Attributes in code will be sorted in the order specified. Any attributes
5069 encountered that are not mentioned in this array will be sorted last, in
5070 stable order. Comments between attributes will leave the attributes
5075 Using this option could lead to incorrect code formatting due to
5076 clang-format's lack of complete semantic information. As such, extra
5077 care should be taken to review code changes made by this option.
5079 .. code-block:: yaml
5081 ObjCPropertyAttributeOrder: [
5084 assign, retain, strong, copy, weak, unsafe_unretained,
5085 readonly, readwrite, getter, setter,
5086 nullable, nonnull, null_resettable, null_unspecified
5089 .. _ObjCSpaceAfterProperty:
5091 **ObjCSpaceAfterProperty** (``Boolean``) :versionbadge:`clang-format 3.7` :ref:`¶ <ObjCSpaceAfterProperty>`
5092 Add a space after ``@property`` in Objective-C, i.e. use
5093 ``@property (readonly)`` instead of ``@property(readonly)``.
5095 .. _ObjCSpaceBeforeProtocolList:
5097 **ObjCSpaceBeforeProtocolList** (``Boolean``) :versionbadge:`clang-format 3.7` :ref:`¶ <ObjCSpaceBeforeProtocolList>`
5098 Add a space in front of an Objective-C protocol list, i.e. use
5099 ``Foo <Protocol>`` instead of ``Foo<Protocol>``.
5103 **PPIndentWidth** (``Integer``) :versionbadge:`clang-format 13` :ref:`¶ <PPIndentWidth>`
5104 The number of columns to use for indentation of preprocessor statements.
5105 When set to -1 (default) ``IndentWidth`` is used also for preprocessor
5118 .. _PackConstructorInitializers:
5120 **PackConstructorInitializers** (``PackConstructorInitializersStyle``) :versionbadge:`clang-format 14` :ref:`¶ <PackConstructorInitializers>`
5121 The pack constructor initializers style to use.
5125 * ``PCIS_Never`` (in configuration: ``Never``)
5126 Always put each constructor initializer on its own line.
5134 * ``PCIS_BinPack`` (in configuration: ``BinPack``)
5135 Bin-pack constructor initializers.
5140 : aaaaaaaaaaaaaaaaaaaa(), bbbbbbbbbbbbbbbbbbbb(),
5141 cccccccccccccccccccc()
5143 * ``PCIS_CurrentLine`` (in configuration: ``CurrentLine``)
5144 Put all constructor initializers on the current line if they fit.
5145 Otherwise, put each one on its own line.
5149 Constructor() : a(), b()
5152 : aaaaaaaaaaaaaaaaaaaa(),
5153 bbbbbbbbbbbbbbbbbbbb(),
5156 * ``PCIS_NextLine`` (in configuration: ``NextLine``)
5157 Same as ``PCIS_CurrentLine`` except that if all constructor initializers
5158 do not fit on the current line, try to fit them on the next line.
5162 Constructor() : a(), b()
5165 : aaaaaaaaaaaaaaaaaaaa(), bbbbbbbbbbbbbbbbbbbb(), ddddddddddddd()
5168 : aaaaaaaaaaaaaaaaaaaa(),
5169 bbbbbbbbbbbbbbbbbbbb(),
5170 cccccccccccccccccccc()
5172 * ``PCIS_NextLineOnly`` (in configuration: ``NextLineOnly``)
5173 Put all constructor initializers on the next line if they fit.
5174 Otherwise, put each one on its own line.
5182 : aaaaaaaaaaaaaaaaaaaa(), bbbbbbbbbbbbbbbbbbbb(), ddddddddddddd()
5185 : aaaaaaaaaaaaaaaaaaaa(),
5186 bbbbbbbbbbbbbbbbbbbb(),
5187 cccccccccccccccccccc()
5191 .. _PenaltyBreakAssignment:
5193 **PenaltyBreakAssignment** (``Unsigned``) :versionbadge:`clang-format 5` :ref:`¶ <PenaltyBreakAssignment>`
5194 The penalty for breaking around an assignment operator.
5196 .. _PenaltyBreakBeforeFirstCallParameter:
5198 **PenaltyBreakBeforeFirstCallParameter** (``Unsigned``) :versionbadge:`clang-format 3.7` :ref:`¶ <PenaltyBreakBeforeFirstCallParameter>`
5199 The penalty for breaking a function call after ``call(``.
5201 .. _PenaltyBreakBeforeMemberAccess:
5203 **PenaltyBreakBeforeMemberAccess** (``Unsigned``) :versionbadge:`clang-format 20` :ref:`¶ <PenaltyBreakBeforeMemberAccess>`
5204 The penalty for breaking before a member access operator (``.``, ``->``).
5206 .. _PenaltyBreakComment:
5208 **PenaltyBreakComment** (``Unsigned``) :versionbadge:`clang-format 3.7` :ref:`¶ <PenaltyBreakComment>`
5209 The penalty for each line break introduced inside a comment.
5211 .. _PenaltyBreakFirstLessLess:
5213 **PenaltyBreakFirstLessLess** (``Unsigned``) :versionbadge:`clang-format 3.7` :ref:`¶ <PenaltyBreakFirstLessLess>`
5214 The penalty for breaking before the first ``<<``.
5216 .. _PenaltyBreakOpenParenthesis:
5218 **PenaltyBreakOpenParenthesis** (``Unsigned``) :versionbadge:`clang-format 14` :ref:`¶ <PenaltyBreakOpenParenthesis>`
5219 The penalty for breaking after ``(``.
5221 .. _PenaltyBreakScopeResolution:
5223 **PenaltyBreakScopeResolution** (``Unsigned``) :versionbadge:`clang-format 18` :ref:`¶ <PenaltyBreakScopeResolution>`
5224 The penalty for breaking after ``::``.
5226 .. _PenaltyBreakString:
5228 **PenaltyBreakString** (``Unsigned``) :versionbadge:`clang-format 3.7` :ref:`¶ <PenaltyBreakString>`
5229 The penalty for each line break introduced inside a string literal.
5231 .. _PenaltyBreakTemplateDeclaration:
5233 **PenaltyBreakTemplateDeclaration** (``Unsigned``) :versionbadge:`clang-format 7` :ref:`¶ <PenaltyBreakTemplateDeclaration>`
5234 The penalty for breaking after template declaration.
5236 .. _PenaltyExcessCharacter:
5238 **PenaltyExcessCharacter** (``Unsigned``) :versionbadge:`clang-format 3.7` :ref:`¶ <PenaltyExcessCharacter>`
5239 The penalty for each character outside of the column limit.
5241 .. _PenaltyIndentedWhitespace:
5243 **PenaltyIndentedWhitespace** (``Unsigned``) :versionbadge:`clang-format 12` :ref:`¶ <PenaltyIndentedWhitespace>`
5244 Penalty for each character of whitespace indentation
5245 (counted relative to leading non-whitespace column).
5247 .. _PenaltyReturnTypeOnItsOwnLine:
5249 **PenaltyReturnTypeOnItsOwnLine** (``Unsigned``) :versionbadge:`clang-format 3.7` :ref:`¶ <PenaltyReturnTypeOnItsOwnLine>`
5250 Penalty for putting the return type of a function onto its own line.
5252 .. _PointerAlignment:
5254 **PointerAlignment** (``PointerAlignmentStyle``) :versionbadge:`clang-format 3.7` :ref:`¶ <PointerAlignment>`
5255 Pointer and reference alignment style.
5259 * ``PAS_Left`` (in configuration: ``Left``)
5260 Align pointer to the left.
5266 * ``PAS_Right`` (in configuration: ``Right``)
5267 Align pointer to the right.
5273 * ``PAS_Middle`` (in configuration: ``Middle``)
5274 Align pointer in the middle.
5282 .. _QualifierAlignment:
5284 **QualifierAlignment** (``QualifierAlignmentStyle``) :versionbadge:`clang-format 14` :ref:`¶ <QualifierAlignment>`
5285 Different ways to arrange specifiers and qualifiers (e.g. const/volatile).
5289 Setting ``QualifierAlignment`` to something other than ``Leave``, COULD
5290 lead to incorrect code formatting due to incorrect decisions made due to
5291 clang-formats lack of complete semantic information.
5292 As such extra care should be taken to review code changes made by the use
5297 * ``QAS_Leave`` (in configuration: ``Leave``)
5298 Don't change specifiers/qualifiers to either Left or Right alignment
5306 * ``QAS_Left`` (in configuration: ``Left``)
5307 Change specifiers/qualifiers to be left-aligned.
5314 * ``QAS_Right`` (in configuration: ``Right``)
5315 Change specifiers/qualifiers to be right-aligned.
5322 * ``QAS_Custom`` (in configuration: ``Custom``)
5323 Change specifiers/qualifiers to be aligned based on ``QualifierOrder``.
5326 .. code-block:: yaml
5328 QualifierOrder: [inline, static, type, const]
5341 **QualifierOrder** (``List of Strings``) :versionbadge:`clang-format 14` :ref:`¶ <QualifierOrder>`
5342 The order in which the qualifiers appear.
5343 The order is an array that can contain any of the following:
5357 It must contain ``type``.
5359 Items to the left of ``type`` will be placed to the left of the type and
5360 aligned in the order supplied. Items to the right of ``type`` will be
5361 placed to the right of the type and aligned in the order supplied.
5364 .. code-block:: yaml
5366 QualifierOrder: [inline, static, type, const, volatile]
5368 .. _RawStringFormats:
5370 **RawStringFormats** (``List of RawStringFormats``) :versionbadge:`clang-format 6` :ref:`¶ <RawStringFormats>`
5371 Defines hints for detecting supported languages code blocks in raw
5374 A raw string with a matching delimiter or a matching enclosing function
5375 name will be reformatted assuming the specified language based on the
5376 style for that language defined in the .clang-format file. If no style has
5377 been defined in the .clang-format file for the specific language, a
5378 predefined style given by ``BasedOnStyle`` is used. If ``BasedOnStyle`` is
5379 not found, the formatting is based on ``LLVM`` style. A matching delimiter
5380 takes precedence over a matching enclosing function name for determining
5381 the language of the raw string contents.
5383 If a canonical delimiter is specified, occurrences of other delimiters for
5384 the same language will be updated to the canonical if possible.
5386 There should be at most one specification per language and each delimiter
5387 and enclosing function should not occur in multiple specifications.
5389 To configure this in the .clang-format file, use:
5391 .. code-block:: yaml
5394 - Language: TextProto
5400 BasedOnStyle: google
5406 CanonicalDelimiter: cc
5408 .. _ReferenceAlignment:
5410 **ReferenceAlignment** (``ReferenceAlignmentStyle``) :versionbadge:`clang-format 13` :ref:`¶ <ReferenceAlignment>`
5411 Reference alignment style (overrides ``PointerAlignment`` for
5416 * ``RAS_Pointer`` (in configuration: ``Pointer``)
5417 Align reference like ``PointerAlignment``.
5419 * ``RAS_Left`` (in configuration: ``Left``)
5420 Align reference to the left.
5426 * ``RAS_Right`` (in configuration: ``Right``)
5427 Align reference to the right.
5433 * ``RAS_Middle`` (in configuration: ``Middle``)
5434 Align reference in the middle.
5444 **ReflowComments** (``ReflowCommentsStyle``) :versionbadge:`clang-format 3.8` :ref:`¶ <ReflowComments>`
5445 Comment reformatting style.
5449 * ``RCS_Never`` (in configuration: ``Never``)
5450 Leave comments untouched.
5454 // veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of information
5455 /* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of information */
5456 /* third veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of information
5457 * and a misaligned second line */
5459 * ``RCS_IndentOnly`` (in configuration: ``IndentOnly``)
5460 Only apply indentation rules, moving comments left or right, without
5461 changing formatting inside the comments.
5465 // veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of information
5466 /* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of information */
5467 /* third veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of information
5468 * and a misaligned second line */
5470 * ``RCS_Always`` (in configuration: ``Always``)
5471 Apply indentation rules and reflow long comments into new lines, trying
5472 to obey the ``ColumnLimit``.
5476 // veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of
5478 /* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of
5480 /* third veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of
5481 * information and a misaligned second line */
5485 .. _RemoveBracesLLVM:
5487 **RemoveBracesLLVM** (``Boolean``) :versionbadge:`clang-format 14` :ref:`¶ <RemoveBracesLLVM>`
5488 Remove optional braces of control statements (``if``, ``else``, ``for``,
5489 and ``while``) in C++ according to the LLVM coding style.
5493 This option will be renamed and expanded to support other styles.
5497 Setting this option to ``true`` could lead to incorrect code formatting
5498 due to clang-format's lack of complete semantic information. As such,
5499 extra care should be taken to review code changes made by this option.
5505 if (isa<FunctionDecl>(D)) { vs. if (isa<FunctionDecl>(D))
5506 handleFunctionDecl(D); handleFunctionDecl(D);
5507 } else if (isa<VarDecl>(D)) { else if (isa<VarDecl>(D))
5508 handleVarDecl(D); handleVarDecl(D);
5511 if (isa<VarDecl>(D)) { vs. if (isa<VarDecl>(D)) {
5512 for (auto *A : D.attrs()) { for (auto *A : D.attrs())
5513 if (shouldProcessAttr(A)) { if (shouldProcessAttr(A))
5514 handleAttr(A); handleAttr(A);
5519 if (isa<FunctionDecl>(D)) { vs. if (isa<FunctionDecl>(D))
5520 for (auto *A : D.attrs()) { for (auto *A : D.attrs())
5521 handleAttr(A); handleAttr(A);
5525 if (auto *D = (T)(D)) { vs. if (auto *D = (T)(D)) {
5526 if (shouldProcess(D)) { if (shouldProcess(D))
5527 handleVarDecl(D); handleVarDecl(D);
5529 markAsIgnored(D); markAsIgnored(D);
5535 } else { else if (c)
5543 .. _RemoveEmptyLinesInUnwrappedLines:
5545 **RemoveEmptyLinesInUnwrappedLines** (``Boolean``) :versionbadge:`clang-format 20` :ref:`¶ <RemoveEmptyLinesInUnwrappedLines>`
5546 Remove empty lines within unwrapped lines.
5552 int c vs. int c = a + b;
5556 enum : unsigned vs. enum : unsigned {
5563 while ( vs. while (true) {
5568 .. _RemoveParentheses:
5570 **RemoveParentheses** (``RemoveParenthesesStyle``) :versionbadge:`clang-format 17` :ref:`¶ <RemoveParentheses>`
5571 Remove redundant parentheses.
5575 Setting this option to any value other than ``Leave`` could lead to
5576 incorrect code formatting due to clang-format's lack of complete semantic
5577 information. As such, extra care should be taken to review code changes
5578 made by this option.
5582 * ``RPS_Leave`` (in configuration: ``Leave``)
5583 Do not remove parentheses.
5587 class __declspec((dllimport)) X {};
5589 return ((a + b) - ((c + d)));
5591 * ``RPS_MultipleParentheses`` (in configuration: ``MultipleParentheses``)
5592 Replace multiple parentheses with single parentheses.
5596 class __declspec(dllimport) X {};
5598 return ((a + b) - (c + d));
5600 * ``RPS_ReturnStatement`` (in configuration: ``ReturnStatement``)
5601 Also remove parentheses enclosing the expression in a
5602 ``return``/``co_return`` statement.
5606 class __declspec(dllimport) X {};
5608 return (a + b) - (c + d);
5612 .. _RemoveSemicolon:
5614 **RemoveSemicolon** (``Boolean``) :versionbadge:`clang-format 16` :ref:`¶ <RemoveSemicolon>`
5615 Remove semicolons after the closing braces of functions and
5616 constructors/destructors.
5620 Setting this option to ``true`` could lead to incorrect code formatting
5621 due to clang-format's lack of complete semantic information. As such,
5622 extra care should be taken to review code changes made by this option.
5628 int max(int a, int b) { int max(int a, int b) {
5629 return a > b ? a : b; return a > b ? a : b;
5632 .. _RequiresClausePosition:
5634 **RequiresClausePosition** (``RequiresClausePositionStyle``) :versionbadge:`clang-format 15` :ref:`¶ <RequiresClausePosition>`
5635 The position of the ``requires`` clause.
5639 * ``RCPS_OwnLine`` (in configuration: ``OwnLine``)
5640 Always put the ``requires`` clause on its own line (possibly followed by
5645 template <typename T>
5649 template <typename T>
5653 template <typename T>
5657 template <typename T>
5662 * ``RCPS_OwnLineWithBrace`` (in configuration: ``OwnLineWithBrace``)
5663 As with ``OwnLine``, except, unless otherwise prohibited, place a
5664 following open brace (of a function definition) to follow on the same
5677 template <typename T>
5682 * ``RCPS_WithPreceding`` (in configuration: ``WithPreceding``)
5683 Try to put the clause together with the preceding part of a declaration.
5684 For class templates: stick to the template declaration.
5685 For function templates: stick to the template declaration.
5686 For function declaration followed by a requires clause: stick to the
5691 template <typename T> requires C<T>
5694 template <typename T> requires C<T>
5697 template <typename T>
5698 void baz(T t) requires C<T>
5701 * ``RCPS_WithFollowing`` (in configuration: ``WithFollowing``)
5702 Try to put the ``requires`` clause together with the class or function
5707 template <typename T>
5708 requires C<T> struct Foo {...
5710 template <typename T>
5711 requires C<T> void bar(T t) {...
5713 template <typename T>
5717 * ``RCPS_SingleLine`` (in configuration: ``SingleLine``)
5718 Try to put everything in the same line if possible. Otherwise normal
5719 line breaking rules take over.
5724 template <typename T> requires C<T> struct Foo {...
5726 template <typename T> requires C<T> void bar(T t) {...
5728 template <typename T> void bar(T t) requires C<T> {...
5730 // Not fitting, one possible example:
5731 template <typename LongName>
5732 requires C<LongName>
5735 template <typename LongName>
5736 requires C<LongName>
5737 void bar(LongName ln) {
5739 template <typename LongName>
5740 void bar(LongName ln)
5741 requires C<LongName> {
5745 .. _RequiresExpressionIndentation:
5747 **RequiresExpressionIndentation** (``RequiresExpressionIndentationKind``) :versionbadge:`clang-format 16` :ref:`¶ <RequiresExpressionIndentation>`
5748 The indentation used for requires expression bodies.
5752 * ``REI_OuterScope`` (in configuration: ``OuterScope``)
5753 Align requires expression body relative to the indentation level of the
5754 outer scope the requires expression resides in.
5755 This is the default.
5759 template <typename T>
5760 concept C = requires(T t) {
5764 * ``REI_Keyword`` (in configuration: ``Keyword``)
5765 Align requires expression body relative to the ``requires`` keyword.
5769 template <typename T>
5770 concept C = requires(T t) {
5776 .. _SeparateDefinitionBlocks:
5778 **SeparateDefinitionBlocks** (``SeparateDefinitionStyle``) :versionbadge:`clang-format 14` :ref:`¶ <SeparateDefinitionBlocks>`
5779 Specifies the use of empty lines to separate definition blocks, including
5780 classes, structs, enums, and functions.
5785 #include <cstring> #include <cstring>
5787 int a, b, c; struct Foo {
5791 public: namespace Ns {
5792 struct Foobar { class Bar {
5794 int b; struct Foobar {
5802 ITEM1, int method1() {
5805 template<typename T>
5806 int method2(T x) { enum List {
5810 int method3(int par) {
5811 // ... template<typename T>
5812 } int method2(T x) {
5818 int method3(int par) {
5828 * ``SDS_Leave`` (in configuration: ``Leave``)
5829 Leave definition blocks as they are.
5831 * ``SDS_Always`` (in configuration: ``Always``)
5832 Insert an empty line between definition blocks.
5834 * ``SDS_Never`` (in configuration: ``Never``)
5835 Remove any empty line between definition blocks.
5839 .. _ShortNamespaceLines:
5841 **ShortNamespaceLines** (``Unsigned``) :versionbadge:`clang-format 13` :ref:`¶ <ShortNamespaceLines>`
5842 The maximal number of unwrapped lines that a short namespace spans.
5845 This determines the maximum length of short namespaces by counting
5846 unwrapped lines (i.e. containing neither opening nor closing
5847 namespace brace) and makes ``FixNamespaceComments`` omit adding
5848 end comments for those.
5852 ShortNamespaceLines: 1 vs. ShortNamespaceLines: 0
5853 namespace a { namespace a {
5857 ShortNamespaceLines: 1 vs. ShortNamespaceLines: 0
5858 namespace b { namespace b {
5861 } // namespace b } // namespace b
5863 .. _SkipMacroDefinitionBody:
5865 **SkipMacroDefinitionBody** (``Boolean``) :versionbadge:`clang-format 18` :ref:`¶ <SkipMacroDefinitionBody>`
5866 Do not format macro definition body.
5870 **SortIncludes** (``SortIncludesOptions``) :versionbadge:`clang-format 3.8` :ref:`¶ <SortIncludes>`
5871 Controls if and how clang-format will sort ``#includes``.
5875 * ``SI_Never`` (in configuration: ``Never``)
5876 Includes are never sorted.
5886 * ``SI_CaseSensitive`` (in configuration: ``CaseSensitive``)
5887 Includes are sorted in an ASCIIbetical or case sensitive fashion.
5897 * ``SI_CaseInsensitive`` (in configuration: ``CaseInsensitive``)
5898 Includes are sorted in an alphabetical or case insensitive fashion.
5910 .. _SortJavaStaticImport:
5912 **SortJavaStaticImport** (``SortJavaStaticImportOptions``) :versionbadge:`clang-format 12` :ref:`¶ <SortJavaStaticImport>`
5913 When sorting Java imports, by default static imports are placed before
5914 non-static imports. If ``JavaStaticImportAfterImport`` is ``After``,
5915 static imports are placed after non-static imports.
5919 * ``SJSIO_Before`` (in configuration: ``Before``)
5920 Static imports are placed before non-static imports.
5922 .. code-block:: java
5924 import static org.example.function1;
5926 import org.example.ClassA;
5928 * ``SJSIO_After`` (in configuration: ``After``)
5929 Static imports are placed after non-static imports.
5931 .. code-block:: java
5933 import org.example.ClassA;
5935 import static org.example.function1;
5939 .. _SortUsingDeclarations:
5941 **SortUsingDeclarations** (``SortUsingDeclarationsOptions``) :versionbadge:`clang-format 5` :ref:`¶ <SortUsingDeclarations>`
5942 Controls if and how clang-format will sort using declarations.
5946 * ``SUD_Never`` (in configuration: ``Never``)
5947 Using declarations are never sorted.
5951 using std::chrono::duration_cast;
5954 using boost::regex_constants::icase;
5957 * ``SUD_Lexicographic`` (in configuration: ``Lexicographic``)
5958 Using declarations are sorted in the order defined as follows:
5959 Split the strings by ``::`` and discard any initial empty strings. Sort
5960 the lists of names lexicographically, and within those groups, names are
5961 in case-insensitive lexicographic order.
5966 using boost::regex_constants::icase;
5967 using std::chrono::duration_cast;
5971 * ``SUD_LexicographicNumeric`` (in configuration: ``LexicographicNumeric``)
5972 Using declarations are sorted in the order defined as follows:
5973 Split the strings by ``::`` and discard any initial empty strings. The
5974 last element of each list is a non-namespace name; all others are
5975 namespace names. Sort the lists of names lexicographically, where the
5976 sort order of individual names is that all non-namespace names come
5977 before all namespace names, and within those groups, names are in
5978 case-insensitive lexicographic order.
5983 using boost::regex_constants::icase;
5986 using std::chrono::duration_cast;
5990 .. _SpaceAfterCStyleCast:
5992 **SpaceAfterCStyleCast** (``Boolean``) :versionbadge:`clang-format 3.5` :ref:`¶ <SpaceAfterCStyleCast>`
5993 If ``true``, a space is inserted after C style casts.
5998 (int) i; vs. (int)i;
6000 .. _SpaceAfterLogicalNot:
6002 **SpaceAfterLogicalNot** (``Boolean``) :versionbadge:`clang-format 9` :ref:`¶ <SpaceAfterLogicalNot>`
6003 If ``true``, a space is inserted after the logical not operator (``!``).
6008 ! someExpression(); vs. !someExpression();
6010 .. _SpaceAfterTemplateKeyword:
6012 **SpaceAfterTemplateKeyword** (``Boolean``) :versionbadge:`clang-format 4` :ref:`¶ <SpaceAfterTemplateKeyword>`
6013 If ``true``, a space will be inserted after the ``template`` keyword.
6018 template <int> void foo(); vs. template<int> void foo();
6020 .. _SpaceAroundPointerQualifiers:
6022 **SpaceAroundPointerQualifiers** (``SpaceAroundPointerQualifiersStyle``) :versionbadge:`clang-format 12` :ref:`¶ <SpaceAroundPointerQualifiers>`
6023 Defines in which cases to put a space before or after pointer qualifiers
6027 * ``SAPQ_Default`` (in configuration: ``Default``)
6028 Don't ensure spaces around pointer qualifiers and use PointerAlignment
6033 PointerAlignment: Left PointerAlignment: Right
6034 void* const* x = NULL; vs. void *const *x = NULL;
6036 * ``SAPQ_Before`` (in configuration: ``Before``)
6037 Ensure that there is a space before pointer qualifiers.
6041 PointerAlignment: Left PointerAlignment: Right
6042 void* const* x = NULL; vs. void * const *x = NULL;
6044 * ``SAPQ_After`` (in configuration: ``After``)
6045 Ensure that there is a space after pointer qualifiers.
6049 PointerAlignment: Left PointerAlignment: Right
6050 void* const * x = NULL; vs. void *const *x = NULL;
6052 * ``SAPQ_Both`` (in configuration: ``Both``)
6053 Ensure that there is a space both before and after pointer qualifiers.
6057 PointerAlignment: Left PointerAlignment: Right
6058 void* const * x = NULL; vs. void * const *x = NULL;
6062 .. _SpaceBeforeAssignmentOperators:
6064 **SpaceBeforeAssignmentOperators** (``Boolean``) :versionbadge:`clang-format 3.7` :ref:`¶ <SpaceBeforeAssignmentOperators>`
6065 If ``false``, spaces will be removed before assignment operators.
6070 int a = 5; vs. int a= 5;
6073 .. _SpaceBeforeCaseColon:
6075 **SpaceBeforeCaseColon** (``Boolean``) :versionbadge:`clang-format 12` :ref:`¶ <SpaceBeforeCaseColon>`
6076 If ``false``, spaces will be removed before case colon.
6081 switch (x) { vs. switch (x) {
6082 case 1 : break; case 1: break;
6085 .. _SpaceBeforeCpp11BracedList:
6087 **SpaceBeforeCpp11BracedList** (``Boolean``) :versionbadge:`clang-format 7` :ref:`¶ <SpaceBeforeCpp11BracedList>`
6088 If ``true``, a space will be inserted before a C++11 braced list
6089 used to initialize an object (after the preceding identifier or type).
6094 Foo foo { bar }; vs. Foo foo{ bar };
6096 vector<int> { 1, 2, 3 }; vector<int>{ 1, 2, 3 };
6097 new int[3] { 1, 2, 3 }; new int[3]{ 1, 2, 3 };
6099 .. _SpaceBeforeCtorInitializerColon:
6101 **SpaceBeforeCtorInitializerColon** (``Boolean``) :versionbadge:`clang-format 7` :ref:`¶ <SpaceBeforeCtorInitializerColon>`
6102 If ``false``, spaces will be removed before constructor initializer
6108 Foo::Foo() : a(a) {} Foo::Foo(): a(a) {}
6110 .. _SpaceBeforeInheritanceColon:
6112 **SpaceBeforeInheritanceColon** (``Boolean``) :versionbadge:`clang-format 7` :ref:`¶ <SpaceBeforeInheritanceColon>`
6113 If ``false``, spaces will be removed before inheritance colon.
6118 class Foo : Bar {} vs. class Foo: Bar {}
6120 .. _SpaceBeforeJsonColon:
6122 **SpaceBeforeJsonColon** (``Boolean``) :versionbadge:`clang-format 17` :ref:`¶ <SpaceBeforeJsonColon>`
6123 If ``true``, a space will be added before a JSON colon. For other
6124 languages, e.g. JavaScript, use ``SpacesInContainerLiterals`` instead.
6130 "key" : "value" vs. "key": "value"
6133 .. _SpaceBeforeParens:
6135 **SpaceBeforeParens** (``SpaceBeforeParensStyle``) :versionbadge:`clang-format 3.5` :ref:`¶ <SpaceBeforeParens>`
6136 Defines in which cases to put a space before opening parentheses.
6140 * ``SBPO_Never`` (in configuration: ``Never``)
6141 This is **deprecated** and replaced by ``Custom`` below, with all
6142 ``SpaceBeforeParensOptions`` but ``AfterPlacementOperator`` set to
6145 * ``SBPO_ControlStatements`` (in configuration: ``ControlStatements``)
6146 Put a space before opening parentheses only after control statement
6147 keywords (``for/if/while...``).
6157 * ``SBPO_ControlStatementsExceptControlMacros`` (in configuration: ``ControlStatementsExceptControlMacros``)
6158 Same as ``SBPO_ControlStatements`` except this option doesn't apply to
6159 ForEach and If macros. This is useful in projects where ForEach/If
6160 macros are treated as function calls instead of control statements.
6161 ``SBPO_ControlStatementsExceptForEachMacros`` remains an alias for
6162 backward compatibility.
6172 * ``SBPO_NonEmptyParentheses`` (in configuration: ``NonEmptyParentheses``)
6173 Put a space before opening parentheses only if the parentheses are not
6185 * ``SBPO_Always`` (in configuration: ``Always``)
6186 Always put a space before opening parentheses, except when it's
6187 prohibited by the syntax rules (in function-like macro definitions) or
6188 when determined by other style rules (after unary operators, opening
6199 * ``SBPO_Custom`` (in configuration: ``Custom``)
6200 Configure each individual space before parentheses in
6201 ``SpaceBeforeParensOptions``.
6205 .. _SpaceBeforeParensOptions:
6207 **SpaceBeforeParensOptions** (``SpaceBeforeParensCustom``) :versionbadge:`clang-format 14` :ref:`¶ <SpaceBeforeParensOptions>`
6208 Control of individual space before parentheses.
6210 If ``SpaceBeforeParens`` is set to ``Custom``, use this to specify
6211 how each individual space before parentheses case should be handled.
6212 Otherwise, this is ignored.
6214 .. code-block:: yaml
6217 SpaceBeforeParens: Custom
6218 SpaceBeforeParensOptions:
6219 AfterControlStatements: true
6220 AfterFunctionDefinitionName: true
6222 Nested configuration flags:
6224 Precise control over the spacing before parentheses.
6228 # Should be declared this way:
6229 SpaceBeforeParens: Custom
6230 SpaceBeforeParensOptions:
6231 AfterControlStatements: true
6232 AfterFunctionDefinitionName: true
6234 * ``bool AfterControlStatements`` If ``true``, put space between control statement keywords
6235 (for/if/while...) and opening parentheses.
6240 if (...) {} vs. if(...) {}
6242 * ``bool AfterForeachMacros`` If ``true``, put space between foreach macros and opening parentheses.
6247 FOREACH (...) vs. FOREACH(...)
6248 <loop-body> <loop-body>
6250 * ``bool AfterFunctionDeclarationName`` If ``true``, put a space between function declaration name and opening
6256 void f (); vs. void f();
6258 * ``bool AfterFunctionDefinitionName`` If ``true``, put a space between function definition name and opening
6264 void f () {} vs. void f() {}
6266 * ``bool AfterIfMacros`` If ``true``, put space between if macros and opening parentheses.
6271 IF (...) vs. IF(...)
6272 <conditional-body> <conditional-body>
6274 * ``bool AfterOverloadedOperator`` If ``true``, put a space between operator overloading and opening
6280 void operator++ (int a); vs. void operator++(int a);
6281 object.operator++ (10); object.operator++(10);
6283 * ``bool AfterPlacementOperator`` If ``true``, put a space between operator ``new``/``delete`` and opening
6289 new (buf) T; vs. new(buf) T;
6290 delete (buf) T; delete(buf) T;
6292 * ``bool AfterRequiresInClause`` If ``true``, put space between requires keyword in a requires clause and
6293 opening parentheses, if there is one.
6298 template<typename T> vs. template<typename T>
6299 requires (A<T> && B<T>) requires(A<T> && B<T>)
6302 * ``bool AfterRequiresInExpression`` If ``true``, put space between requires keyword in a requires expression
6303 and opening parentheses.
6308 template<typename T> vs. template<typename T>
6309 concept C = requires (T t) { concept C = requires(T t) {
6313 * ``bool BeforeNonEmptyParentheses`` If ``true``, put a space before opening parentheses only if the
6314 parentheses are not empty.
6319 void f (int a); vs. void f();
6323 .. _SpaceBeforeRangeBasedForLoopColon:
6325 **SpaceBeforeRangeBasedForLoopColon** (``Boolean``) :versionbadge:`clang-format 7` :ref:`¶ <SpaceBeforeRangeBasedForLoopColon>`
6326 If ``false``, spaces will be removed before range-based for loop
6332 for (auto v : values) {} vs. for(auto v: values) {}
6334 .. _SpaceBeforeSquareBrackets:
6336 **SpaceBeforeSquareBrackets** (``Boolean``) :versionbadge:`clang-format 10` :ref:`¶ <SpaceBeforeSquareBrackets>`
6337 If ``true``, spaces will be before ``[``.
6338 Lambdas will not be affected. Only the first ``[`` will get a space added.
6343 int a [5]; vs. int a[5];
6344 int a [5][5]; vs. int a[5][5];
6346 .. _SpaceInEmptyBlock:
6348 **SpaceInEmptyBlock** (``Boolean``) :versionbadge:`clang-format 10` :ref:`¶ <SpaceInEmptyBlock>`
6349 If ``true``, spaces will be inserted into ``{}``.
6354 void f() { } vs. void f() {}
6355 while (true) { } while (true) {}
6357 .. _SpaceInEmptyParentheses:
6359 **SpaceInEmptyParentheses** (``Boolean``) :versionbadge:`clang-format 3.7` :ref:`¶ <SpaceInEmptyParentheses>`
6360 If ``true``, spaces may be inserted into ``()``.
6361 This option is **deprecated**. See ``InEmptyParentheses`` of
6362 ``SpacesInParensOptions``.
6364 .. _SpacesBeforeTrailingComments:
6366 **SpacesBeforeTrailingComments** (``Unsigned``) :versionbadge:`clang-format 3.7` :ref:`¶ <SpacesBeforeTrailingComments>`
6367 The number of spaces before trailing line comments
6368 (``//`` - comments).
6370 This does not affect trailing block comments (``/*`` - comments) as those
6371 commonly have different usage patterns and a number of special cases. In
6372 the case of Verilog, it doesn't affect a comment right after the opening
6373 parenthesis in the port or parameter list in a module header, because it
6374 is probably for the port on the following line instead of the parenthesis
6379 SpacesBeforeTrailingComments: 3
6388 **SpacesInAngles** (``SpacesInAnglesStyle``) :versionbadge:`clang-format 3.4` :ref:`¶ <SpacesInAngles>`
6389 The SpacesInAnglesStyle to use for template argument lists.
6393 * ``SIAS_Never`` (in configuration: ``Never``)
6394 Remove spaces after ``<`` and before ``>``.
6398 static_cast<int>(arg);
6399 std::function<void(int)> fct;
6401 * ``SIAS_Always`` (in configuration: ``Always``)
6402 Add spaces after ``<`` and before ``>``.
6406 static_cast< int >(arg);
6407 std::function< void(int) > fct;
6409 * ``SIAS_Leave`` (in configuration: ``Leave``)
6410 Keep a single space after ``<`` and before ``>`` if any spaces were
6411 present. Option ``Standard: Cpp03`` takes precedence.
6415 .. _SpacesInCStyleCastParentheses:
6417 **SpacesInCStyleCastParentheses** (``Boolean``) :versionbadge:`clang-format 3.7` :ref:`¶ <SpacesInCStyleCastParentheses>`
6418 If ``true``, spaces may be inserted into C style casts.
6419 This option is **deprecated**. See ``InCStyleCasts`` of
6420 ``SpacesInParensOptions``.
6422 .. _SpacesInConditionalStatement:
6424 **SpacesInConditionalStatement** (``Boolean``) :versionbadge:`clang-format 10` :ref:`¶ <SpacesInConditionalStatement>`
6425 If ``true``, spaces will be inserted around if/for/switch/while
6427 This option is **deprecated**. See ``InConditionalStatements`` of
6428 ``SpacesInParensOptions``.
6430 .. _SpacesInContainerLiterals:
6432 **SpacesInContainerLiterals** (``Boolean``) :versionbadge:`clang-format 3.7` :ref:`¶ <SpacesInContainerLiterals>`
6433 If ``true``, spaces are inserted inside container literals (e.g. ObjC and
6434 Javascript array and dict literals). For JSON, use
6435 ``SpaceBeforeJsonColon`` instead.
6440 var arr = [ 1, 2, 3 ]; vs. var arr = [1, 2, 3];
6441 f({a : 1, b : 2, c : 3}); f({a: 1, b: 2, c: 3});
6443 .. _SpacesInLineCommentPrefix:
6445 **SpacesInLineCommentPrefix** (``SpacesInLineComment``) :versionbadge:`clang-format 13` :ref:`¶ <SpacesInLineCommentPrefix>`
6446 How many spaces are allowed at the start of a line comment. To disable the
6447 maximum set it to ``-1``, apart from that the maximum takes precedence
6454 // One space is forced
6456 // but more spaces are possible
6460 //Forces to start every comment directly after the slashes
6462 Note that in line comment sections the relative indent of the subsequent
6463 lines is kept, that means the following:
6469 //if (b) { // if (b) {
6470 // return true; // return true;
6478 This option has only effect if ``ReflowComments`` is set to ``true``.
6480 Nested configuration flags:
6482 Control of spaces within a single line comment.
6484 * ``unsigned Minimum`` The minimum number of spaces at the start of the comment.
6486 * ``unsigned Maximum`` The maximum number of spaces at the start of the comment.
6491 **SpacesInParens** (``SpacesInParensStyle``) :versionbadge:`clang-format 17` :ref:`¶ <SpacesInParens>`
6492 Defines in which cases spaces will be inserted after ``(`` and before
6497 * ``SIPO_Never`` (in configuration: ``Never``)
6498 Never put a space in parentheses.
6508 * ``SIPO_Custom`` (in configuration: ``Custom``)
6509 Configure each individual space in parentheses in
6510 `SpacesInParensOptions`.
6514 .. _SpacesInParensOptions:
6516 **SpacesInParensOptions** (``SpacesInParensCustom``) :versionbadge:`clang-format 17` :ref:`¶ <SpacesInParensOptions>`
6517 Control of individual spaces in parentheses.
6519 If ``SpacesInParens`` is set to ``Custom``, use this to specify
6520 how each individual space in parentheses case should be handled.
6521 Otherwise, this is ignored.
6523 .. code-block:: yaml
6526 SpacesInParens: Custom
6527 SpacesInParensOptions:
6528 ExceptDoubleParentheses: false
6529 InConditionalStatements: true
6530 InEmptyParentheses: true
6532 Nested configuration flags:
6534 Precise control over the spacing in parentheses.
6538 # Should be declared this way:
6539 SpacesInParens: Custom
6540 SpacesInParensOptions:
6541 ExceptDoubleParentheses: false
6542 InConditionalStatements: true
6545 * ``bool ExceptDoubleParentheses`` Override any of the following options to prevent addition of space
6546 when both opening and closing parentheses use multiple parentheses.
6551 __attribute__(( noreturn ))
6555 Uses the applicable option.
6557 * ``bool InConditionalStatements`` Put a space in parentheses only inside conditional statements
6558 (``for/if/while/switch...``).
6563 if ( a ) { ... } vs. if (a) { ... }
6564 while ( i < 5 ) { ... } while (i < 5) { ... }
6566 * ``bool InCStyleCasts`` Put a space in C style casts.
6571 x = ( int32 )y vs. x = (int32)y
6572 y = (( int (*)(int) )foo)(x); y = ((int (*)(int))foo)(x);
6574 * ``bool InEmptyParentheses`` Insert a space in empty parentheses, i.e. ``()``.
6579 void f( ) { vs. void f() {
6580 int x[] = {foo( ), bar( )}; int x[] = {foo(), bar()};
6581 if (true) { if (true) {
6586 * ``bool Other`` Put a space in parentheses not covered by preceding options.
6591 t f( Deleted & ) & = delete; vs. t f(Deleted &) & = delete;
6594 .. _SpacesInParentheses:
6596 **SpacesInParentheses** (``Boolean``) :versionbadge:`clang-format 3.7` :ref:`¶ <SpacesInParentheses>`
6597 If ``true``, spaces will be inserted after ``(`` and before ``)``.
6598 This option is **deprecated**. The previous behavior is preserved by using
6599 ``SpacesInParens`` with ``Custom`` and by setting all
6600 ``SpacesInParensOptions`` to ``true`` except for ``InCStyleCasts`` and
6601 ``InEmptyParentheses``.
6603 .. _SpacesInSquareBrackets:
6605 **SpacesInSquareBrackets** (``Boolean``) :versionbadge:`clang-format 3.7` :ref:`¶ <SpacesInSquareBrackets>`
6606 If ``true``, spaces will be inserted after ``[`` and before ``]``.
6607 Lambdas without arguments or unspecified size array declarations will not
6613 int a[ 5 ]; vs. int a[5];
6614 std::unique_ptr<int[]> foo() {} // Won't be affected
6618 **Standard** (``LanguageStandard``) :versionbadge:`clang-format 3.7` :ref:`¶ <Standard>`
6619 Parse and format C++ constructs compatible with this standard.
6624 vector<set<int> > x; vs. vector<set<int>> x;
6628 * ``LS_Cpp03`` (in configuration: ``c++03``)
6629 Parse and format as C++03.
6630 ``Cpp03`` is a deprecated alias for ``c++03``
6632 * ``LS_Cpp11`` (in configuration: ``c++11``)
6633 Parse and format as C++11.
6635 * ``LS_Cpp14`` (in configuration: ``c++14``)
6636 Parse and format as C++14.
6638 * ``LS_Cpp17`` (in configuration: ``c++17``)
6639 Parse and format as C++17.
6641 * ``LS_Cpp20`` (in configuration: ``c++20``)
6642 Parse and format as C++20.
6644 * ``LS_Latest`` (in configuration: ``Latest``)
6645 Parse and format using the latest supported language version.
6646 ``Cpp11`` is a deprecated alias for ``Latest``
6648 * ``LS_Auto`` (in configuration: ``Auto``)
6649 Automatic detection based on the input.
6653 .. _StatementAttributeLikeMacros:
6655 **StatementAttributeLikeMacros** (``List of Strings``) :versionbadge:`clang-format 12` :ref:`¶ <StatementAttributeLikeMacros>`
6656 Macros which are ignored in front of a statement, as if they were an
6657 attribute. So that they are not parsed as identifier, for example for Qts
6662 AlignConsecutiveDeclarations: true
6663 StatementAttributeLikeMacros: []
6664 unsigned char data = 'x';
6665 emit signal(data); // This is parsed as variable declaration.
6667 AlignConsecutiveDeclarations: true
6668 StatementAttributeLikeMacros: [emit]
6669 unsigned char data = 'x';
6670 emit signal(data); // Now it's fine again.
6672 .. _StatementMacros:
6674 **StatementMacros** (``List of Strings``) :versionbadge:`clang-format 8` :ref:`¶ <StatementMacros>`
6675 A vector of macros that should be interpreted as complete statements.
6677 Typical macros are expressions and require a semicolon to be added.
6678 Sometimes this is not the case, and this allows to make clang-format aware
6681 For example: Q_UNUSED
6685 **TabWidth** (``Unsigned``) :versionbadge:`clang-format 3.7` :ref:`¶ <TabWidth>`
6686 The number of columns used for tab stops.
6688 .. _TableGenBreakInsideDAGArg:
6690 **TableGenBreakInsideDAGArg** (``DAGArgStyle``) :versionbadge:`clang-format 19` :ref:`¶ <TableGenBreakInsideDAGArg>`
6691 The styles of the line break inside the DAGArg in TableGen.
6695 * ``DAS_DontBreak`` (in configuration: ``DontBreak``)
6696 Never break inside DAGArg.
6700 let DAGArgIns = (ins i32:$src1, i32:$src2);
6702 * ``DAS_BreakElements`` (in configuration: ``BreakElements``)
6703 Break inside DAGArg after each list element but for the last.
6704 This aligns to the first element.
6708 let DAGArgIns = (ins i32:$src1,
6711 * ``DAS_BreakAll`` (in configuration: ``BreakAll``)
6712 Break inside DAGArg after the operator and the all elements.
6716 let DAGArgIns = (ins
6723 .. _TableGenBreakingDAGArgOperators:
6725 **TableGenBreakingDAGArgOperators** (``List of Strings``) :versionbadge:`clang-format 19` :ref:`¶ <TableGenBreakingDAGArgOperators>`
6726 Works only when TableGenBreakInsideDAGArg is not DontBreak.
6727 The string list needs to consist of identifiers in TableGen.
6728 If any identifier is specified, this limits the line breaks by
6729 TableGenBreakInsideDAGArg option only on DAGArg values beginning with
6730 the specified identifiers.
6732 For example the configuration,
6734 .. code-block:: yaml
6736 TableGenBreakInsideDAGArg: BreakAll
6737 TableGenBreakingDAGArgOperators: [ins, outs]
6739 makes the line break only occurs inside DAGArgs beginning with the
6740 specified identifiers ``ins`` and ``outs``.
6745 let DAGArgIns = (ins
6749 let DAGArgOtherID = (other i32:$other1, i32:$other2);
6750 let DAGArgBang = (!cast<SomeType>("Some") i32:$src1, i32:$src2)
6754 **TemplateNames** (``List of Strings``) :versionbadge:`clang-format 20` :ref:`¶ <TemplateNames>`
6755 A vector of non-keyword identifiers that should be interpreted as template
6758 A ``<`` after a template name is annotated as a template opener instead of
6763 **TypeNames** (``List of Strings``) :versionbadge:`clang-format 17` :ref:`¶ <TypeNames>`
6764 A vector of non-keyword identifiers that should be interpreted as type
6767 A ``*``, ``&``, or ``&&`` between a type name and another non-keyword
6768 identifier is annotated as a pointer or reference token instead of a
6773 **TypenameMacros** (``List of Strings``) :versionbadge:`clang-format 9` :ref:`¶ <TypenameMacros>`
6774 A vector of macros that should be interpreted as type declarations
6775 instead of as function calls.
6777 These are expected to be macros of the form:
6783 In the .clang-format configuration file, this can be configured like:
6785 .. code-block:: yaml
6787 TypenameMacros: [STACK_OF, LIST]
6789 For example: OpenSSL STACK_OF, BSD LIST_ENTRY.
6793 **UseCRLF** (``Boolean``) :versionbadge:`clang-format 10` :ref:`¶ <UseCRLF>`
6794 This option is **deprecated**. See ``LF`` and ``CRLF`` of ``LineEnding``.
6798 **UseTab** (``UseTabStyle``) :versionbadge:`clang-format 3.7` :ref:`¶ <UseTab>`
6799 The way to use tab characters in the resulting file.
6803 * ``UT_Never`` (in configuration: ``Never``)
6806 * ``UT_ForIndentation`` (in configuration: ``ForIndentation``)
6807 Use tabs only for indentation.
6809 * ``UT_ForContinuationAndIndentation`` (in configuration: ``ForContinuationAndIndentation``)
6810 Fill all leading whitespace with tabs, and use spaces for alignment that
6811 appears within a line (e.g. consecutive assignments and declarations).
6813 * ``UT_AlignWithSpaces`` (in configuration: ``AlignWithSpaces``)
6814 Use tabs for line continuation and indentation, and spaces for
6817 * ``UT_Always`` (in configuration: ``Always``)
6818 Use tabs whenever we need to fill whitespace that spans at least from
6819 one tab stop to the next one.
6823 .. _VariableTemplates:
6825 **VariableTemplates** (``List of Strings``) :versionbadge:`clang-format 20` :ref:`¶ <VariableTemplates>`
6826 A vector of non-keyword identifiers that should be interpreted as variable
6829 A ``)`` after a variable template instantiation is **not** annotated as
6830 the closing parenthesis of C-style cast operator.
6832 .. _VerilogBreakBetweenInstancePorts:
6834 **VerilogBreakBetweenInstancePorts** (``Boolean``) :versionbadge:`clang-format 17` :ref:`¶ <VerilogBreakBetweenInstancePorts>`
6835 For Verilog, put each port on its own line in module instantiations.
6846 ffnand ff1(.q(), .qbar(out1), .clear(in1), .preset(in2));
6848 .. _WhitespaceSensitiveMacros:
6850 **WhitespaceSensitiveMacros** (``List of Strings``) :versionbadge:`clang-format 11` :ref:`¶ <WhitespaceSensitiveMacros>`
6851 A vector of macros which are whitespace-sensitive and should not
6854 These are expected to be macros of the form:
6860 In the .clang-format configuration file, this can be configured like:
6862 .. code-block:: yaml
6864 WhitespaceSensitiveMacros: [STRINGIZE, PP_STRINGIZE]
6866 For example: BOOST_PP_STRINGIZE
6868 .. _WrapNamespaceBodyWithEmptyLines:
6870 **WrapNamespaceBodyWithEmptyLines** (``WrapNamespaceBodyWithEmptyLinesStyle``) :versionbadge:`clang-format 20` :ref:`¶ <WrapNamespaceBodyWithEmptyLines>`
6871 Wrap namespace body with empty lines.
6875 * ``WNBWELS_Never`` (in configuration: ``Never``)
6876 Remove all empty lines at the beginning and the end of namespace body.
6886 * ``WNBWELS_Always`` (in configuration: ``Always``)
6887 Always have at least one empty line at the beginning and the end of
6888 namespace body except that the number of empty lines between consecutive
6889 nested namespace definitions is not increased.
6901 * ``WNBWELS_Leave`` (in configuration: ``Leave``)
6902 Keep existing newlines at the beginning and the end of namespace body.
6903 ``MaxEmptyLinesToKeep`` still applies.
6907 .. END_FORMAT_STYLE_OPTIONS
6909 Adding additional style options
6910 ===============================
6912 Each additional style option adds costs to the clang-format project. Some of
6913 these costs affect the clang-format development itself, as we need to make
6914 sure that any given combination of options work and that new features don't
6915 break any of the existing options in any way. There are also costs for end users
6916 as options become less discoverable and people have to think about and make a
6917 decision on options they don't really care about.
6919 The goal of the clang-format project is more on the side of supporting a
6920 limited set of styles really well as opposed to supporting every single style
6921 used by a codebase somewhere in the wild. Of course, we do want to support all
6922 major projects and thus have established the following bar for adding style
6923 options. Each new style option must:
6925 * be used in a project of significant size (have dozens of contributors)
6926 * have a publicly accessible style guide
6927 * have a person willing to contribute and maintain patches
6932 A style similar to the `Linux Kernel style
6933 <https://www.kernel.org/doc/html/latest/process/coding-style.html>`_:
6935 .. code-block:: yaml
6940 BreakBeforeBraces: Linux
6941 AllowShortIfStatementsOnASingleLine: false
6942 IndentCaseLabels: false
6944 The result is (imagine that tabs are used for indentation here):
6956 do_something_else();
6962 do_something_completely_different();
6973 A style similar to the default Visual Studio formatting style:
6975 .. code-block:: yaml
6979 BreakBeforeBraces: Allman
6980 AllowShortIfStatementsOnASingleLine: false
6981 IndentCaseLabels: false
6997 do_something_else();
7003 do_something_completely_different();