[Clang][SME2] Fix PSEL builtin predicates (#77097)
[llvm-project.git] / clang / docs / ClangFormatStyleOptions.rst
blob8bc13e45bf2f5faa54bc3138d487e289dac934a7
1 ..
2   !!!!NOTE!!!!
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.
7 .. raw:: html
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"; }
11       </style>
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:
47 .. code-block:: yaml
49   key1: value1
50   key2: value2
51   # A comment.
52   ...
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
60 default section.
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
66 language.
68 An example of a configuration file for multiple languages:
70 .. code-block:: yaml
72   ---
73   # We'll use defaults from the LLVM style, but with 4 columns indentation.
74   BasedOnStyle: LLVM
75   IndentWidth: 4
76   ---
77   Language: Cpp
78   # Force pointers to the type for C++.
79   DerivePointerAlignment: false
80   PointerAlignment: Left
81   ---
82   Language: JavaScript
83   # Use 100 columns for JS.
84   ColumnLimit: 100
85   ---
86   Language: Proto
87   # Don't format .proto files.
88   DisableFormat: true
89   ---
90   Language: CSharp
91   # Use 100 columns for C#.
92   ColumnLimit: 100
93   ...
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.
121 .. code-block:: c++
123   int formatted_code;
124   // clang-format off
125       void    unformatted_code  ;
126   // clang-format on
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>`_
136 structure.
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``).
147 .. _BasedOnStyle:
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).
155   Possible values:
157   * ``LLVM``
158     A style complying with the `LLVM coding standards
159     <https://llvm.org/docs/CodingStandards.html>`_
160   * ``Google``
161     A style complying with `Google's C++ style guide
162     <https://google.github.io/styleguide/cppguide.html>`_
163   * ``Chromium``
164     A style complying with `Chromium's style guide
165     <https://chromium.googlesource.com/chromium/src/+/refs/heads/main/styleguide/styleguide.md>`_
166   * ``Mozilla``
167     A style complying with `Mozilla's style guide
168     <https://firefox-source-docs.mozilla.org/code-quality/coding-style/index.html>`_
169   * ``WebKit``
170     A style complying with `WebKit's style guide
171     <https://www.webkit.org/coding/coding-style.html>`_
172   * ``Microsoft``
173     A style complying with `Microsoft's style guide
174     <https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference>`_
175   * ``GNU``
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
182     to that.
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
201   brackets.
203   Possible values:
205   * ``BAS_Align`` (in configuration: ``Align``)
206     Align parameters on the open bracket, e.g.:
208     .. code-block:: c++
210       someLongFunction(argument1,
211                        argument2);
213   * ``BAS_DontAlign`` (in configuration: ``DontAlign``)
214     Don't align, instead use ``ContinuationIndentWidth``, e.g.:
216     .. code-block:: c++
218       someLongFunction(argument1,
219           argument2);
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.:
225     .. code-block:: c++
227       someLongFunction(
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.
233     E.g.:
235     .. code-block:: c++
237       someLongFunction(
238           argument1, argument2
239       )
242     .. note::
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.
256   .. note::
258    As of clang-format 15 this option only applied to arrays with equal
259    number of columns per row.
261   Possible values:
263   * ``AIAS_Left`` (in configuration: ``Left``)
264     Align array column and left justify the columns e.g.:
266     .. code-block:: c++
268       struct test demo[] =
269       {
270           {56, 23,    "hello"},
271           {-1, 93463, "world"},
272           {7,  5,     "!!"   }
273       };
275   * ``AIAS_Right`` (in configuration: ``Right``)
276     Align array column and right justify the columns e.g.:
278     .. code-block:: c++
280       struct test demo[] =
281       {
282           {56,    23, "hello"},
283           {-1, 93463, "world"},
284           { 7,     5,    "!!"}
285       };
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:
299   .. code-block:: c++
301     int a            = 1;
302     int somelongname = 2;
303     double c         = 3;
305   Nested configuration flags:
307   Alignment options.
309   They can also be read as a whole for compatibility. The choices are:
310   - None
311   - Consecutive
312   - AcrossEmptyLines
313   - AcrossComments
314   - AcrossEmptyLinesAndComments
316   For example, to align across empty lines and not across comments, either
317   of these work.
319   .. code-block:: c++
321     AlignConsecutiveMacros: AcrossEmptyLines
323     AlignConsecutiveMacros:
324       Enabled: true
325       AcrossEmptyLines: true
326       AcrossComments: false
328   * ``bool Enabled`` Whether aligning is enabled.
330     .. code-block:: c++
332       #define SHORT_NAME       42
333       #define LONGER_NAME      0x007f
334       #define EVEN_LONGER_NAME (2)
335       #define foo(x)           (x * x)
336       #define bar(y, z)        (y + z)
338       int a            = 1;
339       int somelongname = 2;
340       double c         = 3;
342       int aaaa : 1;
343       int b    : 12;
344       int ccc  : 8;
346       int         aaaa = 12;
347       float       b = 23;
348       std::string ccc;
350   * ``bool AcrossEmptyLines`` Whether to align across empty lines.
352     .. code-block:: c++
354       true:
355       int a            = 1;
356       int somelongname = 2;
357       double c         = 3;
359       int d            = 3;
361       false:
362       int a            = 1;
363       int somelongname = 2;
364       double c         = 3;
366       int d = 3;
368   * ``bool AcrossComments`` Whether to align across comments.
370     .. code-block:: c++
372       true:
373       int d    = 3;
374       /* A comment. */
375       double e = 4;
377       false:
378       int d = 3;
379       /* A comment. */
380       double e = 4;
382   * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``.  Whether compound assignments
383     like ``+=`` are aligned along with ``=``.
385     .. code-block:: c++
387       true:
388       a   &= 2;
389       bbb  = 2;
391       false:
392       a &= 2;
393       bbb = 2;
395   * ``bool AlignFunctionPointers`` Only for ``AlignConsecutiveDeclarations``. Whether function pointers are
396     aligned.
398     .. code-block:: c++
400       true:
401       unsigned i;
402       int     &r;
403       int     *p;
404       int      (*f)();
406       false:
407       unsigned i;
408       int     &r;
409       int     *p;
410       int (*f)();
412   * ``bool PadOperators`` Only for ``AlignConsecutiveAssignments``.  Whether short assignment
413     operators are left-padded to the same length as long ones in order to
414     put all assignment operators to the right of the left hand side.
416     .. code-block:: c++
418       true:
419       a   >>= 2;
420       bbb   = 2;
422       a     = 2;
423       bbb >>= 2;
425       false:
426       a >>= 2;
427       bbb = 2;
429       a     = 2;
430       bbb >>= 2;
433 .. _AlignConsecutiveBitFields:
435 **AlignConsecutiveBitFields** (``AlignConsecutiveStyle``) :versionbadge:`clang-format 11` :ref:`¶ <AlignConsecutiveBitFields>`
436   Style of aligning consecutive bit fields.
438   ``Consecutive`` will align the bitfield separators of consecutive lines.
439   This will result in formattings like:
441   .. code-block:: c++
443     int aaaa : 1;
444     int b    : 12;
445     int ccc  : 8;
447   Nested configuration flags:
449   Alignment options.
451   They can also be read as a whole for compatibility. The choices are:
452   - None
453   - Consecutive
454   - AcrossEmptyLines
455   - AcrossComments
456   - AcrossEmptyLinesAndComments
458   For example, to align across empty lines and not across comments, either
459   of these work.
461   .. code-block:: c++
463     AlignConsecutiveMacros: AcrossEmptyLines
465     AlignConsecutiveMacros:
466       Enabled: true
467       AcrossEmptyLines: true
468       AcrossComments: false
470   * ``bool Enabled`` Whether aligning is enabled.
472     .. code-block:: c++
474       #define SHORT_NAME       42
475       #define LONGER_NAME      0x007f
476       #define EVEN_LONGER_NAME (2)
477       #define foo(x)           (x * x)
478       #define bar(y, z)        (y + z)
480       int a            = 1;
481       int somelongname = 2;
482       double c         = 3;
484       int aaaa : 1;
485       int b    : 12;
486       int ccc  : 8;
488       int         aaaa = 12;
489       float       b = 23;
490       std::string ccc;
492   * ``bool AcrossEmptyLines`` Whether to align across empty lines.
494     .. code-block:: c++
496       true:
497       int a            = 1;
498       int somelongname = 2;
499       double c         = 3;
501       int d            = 3;
503       false:
504       int a            = 1;
505       int somelongname = 2;
506       double c         = 3;
508       int d = 3;
510   * ``bool AcrossComments`` Whether to align across comments.
512     .. code-block:: c++
514       true:
515       int d    = 3;
516       /* A comment. */
517       double e = 4;
519       false:
520       int d = 3;
521       /* A comment. */
522       double e = 4;
524   * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``.  Whether compound assignments
525     like ``+=`` are aligned along with ``=``.
527     .. code-block:: c++
529       true:
530       a   &= 2;
531       bbb  = 2;
533       false:
534       a &= 2;
535       bbb = 2;
537   * ``bool AlignFunctionPointers`` Only for ``AlignConsecutiveDeclarations``. Whether function pointers are
538     aligned.
540     .. code-block:: c++
542       true:
543       unsigned i;
544       int     &r;
545       int     *p;
546       int      (*f)();
548       false:
549       unsigned i;
550       int     &r;
551       int     *p;
552       int (*f)();
554   * ``bool PadOperators`` Only for ``AlignConsecutiveAssignments``.  Whether short assignment
555     operators are left-padded to the same length as long ones in order to
556     put all assignment operators to the right of the left hand side.
558     .. code-block:: c++
560       true:
561       a   >>= 2;
562       bbb   = 2;
564       a     = 2;
565       bbb >>= 2;
567       false:
568       a >>= 2;
569       bbb = 2;
571       a     = 2;
572       bbb >>= 2;
575 .. _AlignConsecutiveDeclarations:
577 **AlignConsecutiveDeclarations** (``AlignConsecutiveStyle``) :versionbadge:`clang-format 3.8` :ref:`¶ <AlignConsecutiveDeclarations>`
578   Style of aligning consecutive declarations.
580   ``Consecutive`` will align the declaration names of consecutive lines.
581   This will result in formattings like:
583   .. code-block:: c++
585     int         aaaa = 12;
586     float       b = 23;
587     std::string ccc;
589   Nested configuration flags:
591   Alignment options.
593   They can also be read as a whole for compatibility. The choices are:
594   - None
595   - Consecutive
596   - AcrossEmptyLines
597   - AcrossComments
598   - AcrossEmptyLinesAndComments
600   For example, to align across empty lines and not across comments, either
601   of these work.
603   .. code-block:: c++
605     AlignConsecutiveMacros: AcrossEmptyLines
607     AlignConsecutiveMacros:
608       Enabled: true
609       AcrossEmptyLines: true
610       AcrossComments: false
612   * ``bool Enabled`` Whether aligning is enabled.
614     .. code-block:: c++
616       #define SHORT_NAME       42
617       #define LONGER_NAME      0x007f
618       #define EVEN_LONGER_NAME (2)
619       #define foo(x)           (x * x)
620       #define bar(y, z)        (y + z)
622       int a            = 1;
623       int somelongname = 2;
624       double c         = 3;
626       int aaaa : 1;
627       int b    : 12;
628       int ccc  : 8;
630       int         aaaa = 12;
631       float       b = 23;
632       std::string ccc;
634   * ``bool AcrossEmptyLines`` Whether to align across empty lines.
636     .. code-block:: c++
638       true:
639       int a            = 1;
640       int somelongname = 2;
641       double c         = 3;
643       int d            = 3;
645       false:
646       int a            = 1;
647       int somelongname = 2;
648       double c         = 3;
650       int d = 3;
652   * ``bool AcrossComments`` Whether to align across comments.
654     .. code-block:: c++
656       true:
657       int d    = 3;
658       /* A comment. */
659       double e = 4;
661       false:
662       int d = 3;
663       /* A comment. */
664       double e = 4;
666   * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``.  Whether compound assignments
667     like ``+=`` are aligned along with ``=``.
669     .. code-block:: c++
671       true:
672       a   &= 2;
673       bbb  = 2;
675       false:
676       a &= 2;
677       bbb = 2;
679   * ``bool AlignFunctionPointers`` Only for ``AlignConsecutiveDeclarations``. Whether function pointers are
680     aligned.
682     .. code-block:: c++
684       true:
685       unsigned i;
686       int     &r;
687       int     *p;
688       int      (*f)();
690       false:
691       unsigned i;
692       int     &r;
693       int     *p;
694       int (*f)();
696   * ``bool PadOperators`` Only for ``AlignConsecutiveAssignments``.  Whether short assignment
697     operators are left-padded to the same length as long ones in order to
698     put all assignment operators to the right of the left hand side.
700     .. code-block:: c++
702       true:
703       a   >>= 2;
704       bbb   = 2;
706       a     = 2;
707       bbb >>= 2;
709       false:
710       a >>= 2;
711       bbb = 2;
713       a     = 2;
714       bbb >>= 2;
717 .. _AlignConsecutiveMacros:
719 **AlignConsecutiveMacros** (``AlignConsecutiveStyle``) :versionbadge:`clang-format 9` :ref:`¶ <AlignConsecutiveMacros>`
720   Style of aligning consecutive macro definitions.
722   ``Consecutive`` will result in formattings like:
724   .. code-block:: c++
726     #define SHORT_NAME       42
727     #define LONGER_NAME      0x007f
728     #define EVEN_LONGER_NAME (2)
729     #define foo(x)           (x * x)
730     #define bar(y, z)        (y + z)
732   Nested configuration flags:
734   Alignment options.
736   They can also be read as a whole for compatibility. The choices are:
737   - None
738   - Consecutive
739   - AcrossEmptyLines
740   - AcrossComments
741   - AcrossEmptyLinesAndComments
743   For example, to align across empty lines and not across comments, either
744   of these work.
746   .. code-block:: c++
748     AlignConsecutiveMacros: AcrossEmptyLines
750     AlignConsecutiveMacros:
751       Enabled: true
752       AcrossEmptyLines: true
753       AcrossComments: false
755   * ``bool Enabled`` Whether aligning is enabled.
757     .. code-block:: c++
759       #define SHORT_NAME       42
760       #define LONGER_NAME      0x007f
761       #define EVEN_LONGER_NAME (2)
762       #define foo(x)           (x * x)
763       #define bar(y, z)        (y + z)
765       int a            = 1;
766       int somelongname = 2;
767       double c         = 3;
769       int aaaa : 1;
770       int b    : 12;
771       int ccc  : 8;
773       int         aaaa = 12;
774       float       b = 23;
775       std::string ccc;
777   * ``bool AcrossEmptyLines`` Whether to align across empty lines.
779     .. code-block:: c++
781       true:
782       int a            = 1;
783       int somelongname = 2;
784       double c         = 3;
786       int d            = 3;
788       false:
789       int a            = 1;
790       int somelongname = 2;
791       double c         = 3;
793       int d = 3;
795   * ``bool AcrossComments`` Whether to align across comments.
797     .. code-block:: c++
799       true:
800       int d    = 3;
801       /* A comment. */
802       double e = 4;
804       false:
805       int d = 3;
806       /* A comment. */
807       double e = 4;
809   * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``.  Whether compound assignments
810     like ``+=`` are aligned along with ``=``.
812     .. code-block:: c++
814       true:
815       a   &= 2;
816       bbb  = 2;
818       false:
819       a &= 2;
820       bbb = 2;
822   * ``bool AlignFunctionPointers`` Only for ``AlignConsecutiveDeclarations``. Whether function pointers are
823     aligned.
825     .. code-block:: c++
827       true:
828       unsigned i;
829       int     &r;
830       int     *p;
831       int      (*f)();
833       false:
834       unsigned i;
835       int     &r;
836       int     *p;
837       int (*f)();
839   * ``bool PadOperators`` Only for ``AlignConsecutiveAssignments``.  Whether short assignment
840     operators are left-padded to the same length as long ones in order to
841     put all assignment operators to the right of the left hand side.
843     .. code-block:: c++
845       true:
846       a   >>= 2;
847       bbb   = 2;
849       a     = 2;
850       bbb >>= 2;
852       false:
853       a >>= 2;
854       bbb = 2;
856       a     = 2;
857       bbb >>= 2;
860 .. _AlignConsecutiveShortCaseStatements:
862 **AlignConsecutiveShortCaseStatements** (``ShortCaseStatementsAlignmentStyle``) :versionbadge:`clang-format 17` :ref:`¶ <AlignConsecutiveShortCaseStatements>`
863   Style of aligning consecutive short case labels.
864   Only applies if ``AllowShortCaseLabelsOnASingleLine`` is ``true``.
867   .. code-block:: yaml
869     # Example of usage:
870     AlignConsecutiveShortCaseStatements:
871       Enabled: true
872       AcrossEmptyLines: true
873       AcrossComments: true
874       AlignCaseColons: false
876   Nested configuration flags:
878   Alignment options.
880   * ``bool Enabled`` Whether aligning is enabled.
882     .. code-block:: c++
884       true:
885       switch (level) {
886       case log::info:    return "info:";
887       case log::warning: return "warning:";
888       default:           return "";
889       }
891       false:
892       switch (level) {
893       case log::info: return "info:";
894       case log::warning: return "warning:";
895       default: return "";
896       }
898   * ``bool AcrossEmptyLines`` Whether to align across empty lines.
900     .. code-block:: c++
902       true:
903       switch (level) {
904       case log::info:    return "info:";
905       case log::warning: return "warning:";
907       default:           return "";
908       }
910       false:
911       switch (level) {
912       case log::info:    return "info:";
913       case log::warning: return "warning:";
915       default: return "";
916       }
918   * ``bool AcrossComments`` Whether to align across comments.
920     .. code-block:: c++
922       true:
923       switch (level) {
924       case log::info:    return "info:";
925       case log::warning: return "warning:";
926       /* A comment. */
927       default:           return "";
928       }
930       false:
931       switch (level) {
932       case log::info:    return "info:";
933       case log::warning: return "warning:";
934       /* A comment. */
935       default: return "";
936       }
938   * ``bool AlignCaseColons`` Whether aligned case labels are aligned on the colon, or on the
939     , or on the tokens after the colon.
941     .. code-block:: c++
943       true:
944       switch (level) {
945       case log::info   : return "info:";
946       case log::warning: return "warning:";
947       default          : return "";
948       }
950       false:
951       switch (level) {
952       case log::info:    return "info:";
953       case log::warning: return "warning:";
954       default:           return "";
955       }
958 .. _AlignEscapedNewlines:
960 **AlignEscapedNewlines** (``EscapedNewlineAlignmentStyle``) :versionbadge:`clang-format 5` :ref:`¶ <AlignEscapedNewlines>`
961   Options for aligning backslashes in escaped newlines.
963   Possible values:
965   * ``ENAS_DontAlign`` (in configuration: ``DontAlign``)
966     Don't align escaped newlines.
968     .. code-block:: c++
970       #define A \
971         int aaaa; \
972         int b; \
973         int dddddddddd;
975   * ``ENAS_Left`` (in configuration: ``Left``)
976     Align escaped newlines as far left as possible.
978     .. code-block:: c++
980       true:
981       #define A   \
982         int aaaa; \
983         int b;    \
984         int dddddddddd;
986       false:
988   * ``ENAS_Right`` (in configuration: ``Right``)
989     Align escaped newlines in the right-most column.
991     .. code-block:: c++
993       #define A                                                                      \
994         int aaaa;                                                                    \
995         int b;                                                                       \
996         int dddddddddd;
1000 .. _AlignOperands:
1002 **AlignOperands** (``OperandAlignmentStyle``) :versionbadge:`clang-format 3.5` :ref:`¶ <AlignOperands>`
1003   If ``true``, horizontally align operands of binary and ternary
1004   expressions.
1006   Possible values:
1008   * ``OAS_DontAlign`` (in configuration: ``DontAlign``)
1009     Do not align operands of binary and ternary expressions.
1010     The wrapped lines are indented ``ContinuationIndentWidth`` spaces from
1011     the start of the line.
1013   * ``OAS_Align`` (in configuration: ``Align``)
1014     Horizontally align operands of binary and ternary expressions.
1016     Specifically, this aligns operands of a single expression that needs
1017     to be split over multiple lines, e.g.:
1019     .. code-block:: c++
1021       int aaa = bbbbbbbbbbbbbbb +
1022                 ccccccccccccccc;
1024     When ``BreakBeforeBinaryOperators`` is set, the wrapped operator is
1025     aligned with the operand on the first line.
1027     .. code-block:: c++
1029       int aaa = bbbbbbbbbbbbbbb
1030                 + ccccccccccccccc;
1032   * ``OAS_AlignAfterOperator`` (in configuration: ``AlignAfterOperator``)
1033     Horizontally align operands of binary and ternary expressions.
1035     This is similar to ``AO_Align``, except when
1036     ``BreakBeforeBinaryOperators`` is set, the operator is un-indented so
1037     that the wrapped operand is aligned with the operand on the first line.
1039     .. code-block:: c++
1041       int aaa = bbbbbbbbbbbbbbb
1042               + ccccccccccccccc;
1046 .. _AlignTrailingComments:
1048 **AlignTrailingComments** (``TrailingCommentsAlignmentStyle``) :versionbadge:`clang-format 3.7` :ref:`¶ <AlignTrailingComments>`
1049   Control of trailing comments.
1051   The alignment stops at closing braces after a line break, and only
1052   followed by other closing braces, a (``do-``) ``while``, a lambda call, or
1053   a semicolon.
1056   .. note::
1058    As of clang-format 16 this option is not a bool but can be set
1059    to the options. Conventional bool options still can be parsed as before.
1062   .. code-block:: yaml
1064     # Example of usage:
1065     AlignTrailingComments:
1066       Kind: Always
1067       OverEmptyLines: 2
1069   Nested configuration flags:
1071   Alignment options
1073   * ``TrailingCommentsAlignmentKinds Kind``
1074     Specifies the way to align trailing comments.
1076     Possible values:
1078     * ``TCAS_Leave`` (in configuration: ``Leave``)
1079       Leave trailing comments as they are.
1081       .. code-block:: c++
1083         int a;    // comment
1084         int ab;       // comment
1086         int abc;  // comment
1087         int abcd;     // comment
1089     * ``TCAS_Always`` (in configuration: ``Always``)
1090       Align trailing comments.
1092       .. code-block:: c++
1094         int a;  // comment
1095         int ab; // comment
1097         int abc;  // comment
1098         int abcd; // comment
1100     * ``TCAS_Never`` (in configuration: ``Never``)
1101       Don't align trailing comments but other formatter applies.
1103       .. code-block:: c++
1105         int a; // comment
1106         int ab; // comment
1108         int abc; // comment
1109         int abcd; // comment
1112   * ``unsigned OverEmptyLines`` How many empty lines to apply alignment.
1113     When both ``MaxEmptyLinesToKeep`` and ``OverEmptyLines`` are set to 2,
1114     it formats like below.
1116     .. code-block:: c++
1118       int a;      // all these
1120       int ab;     // comments are
1123       int abcdef; // aligned
1125     When ``MaxEmptyLinesToKeep`` is set to 2 and ``OverEmptyLines`` is set
1126     to 1, it formats like below.
1128     .. code-block:: c++
1130       int a;  // these are
1132       int ab; // aligned
1135       int abcdef; // but this isn't
1138 .. _AllowAllArgumentsOnNextLine:
1140 **AllowAllArgumentsOnNextLine** (``Boolean``) :versionbadge:`clang-format 9` :ref:`¶ <AllowAllArgumentsOnNextLine>`
1141   If a function call or braced initializer list doesn't fit on a
1142   line, allow putting all arguments onto the next line, even if
1143   ``BinPackArguments`` is ``false``.
1145   .. code-block:: c++
1147     true:
1148     callFunction(
1149         a, b, c, d);
1151     false:
1152     callFunction(a,
1153                  b,
1154                  c,
1155                  d);
1157 .. _AllowAllConstructorInitializersOnNextLine:
1159 **AllowAllConstructorInitializersOnNextLine** (``Boolean``) :versionbadge:`clang-format 9` :ref:`¶ <AllowAllConstructorInitializersOnNextLine>`
1160   This option is **deprecated**. See ``NextLine`` of
1161   ``PackConstructorInitializers``.
1163 .. _AllowAllParametersOfDeclarationOnNextLine:
1165 **AllowAllParametersOfDeclarationOnNextLine** (``Boolean``) :versionbadge:`clang-format 3.3` :ref:`¶ <AllowAllParametersOfDeclarationOnNextLine>`
1166   If the function declaration doesn't fit on a line,
1167   allow putting all parameters of a function declaration onto
1168   the next line even if ``BinPackParameters`` is ``false``.
1170   .. code-block:: c++
1172     true:
1173     void myFunction(
1174         int a, int b, int c, int d, int e);
1176     false:
1177     void myFunction(int a,
1178                     int b,
1179                     int c,
1180                     int d,
1181                     int e);
1183 .. _AllowBreakBeforeNoexceptSpecifier:
1185 **AllowBreakBeforeNoexceptSpecifier** (``BreakBeforeNoexceptSpecifierStyle``) :versionbadge:`clang-format 18` :ref:`¶ <AllowBreakBeforeNoexceptSpecifier>`
1186   Controls if there could be a line break before a ``noexcept`` specifier.
1188   Possible values:
1190   * ``BBNSS_Never`` (in configuration: ``Never``)
1191     No line break allowed.
1193     .. code-block:: c++
1195       void foo(int arg1,
1196                double arg2) noexcept;
1198       void bar(int arg1, double arg2) noexcept(
1199           noexcept(baz(arg1)) &&
1200           noexcept(baz(arg2)));
1202   * ``BBNSS_OnlyWithParen`` (in configuration: ``OnlyWithParen``)
1203     For a simple ``noexcept`` there is no line break allowed, but when we
1204     have a condition it is.
1206     .. code-block:: c++
1208       void foo(int arg1,
1209                double arg2) noexcept;
1211       void bar(int arg1, double arg2)
1212           noexcept(noexcept(baz(arg1)) &&
1213                    noexcept(baz(arg2)));
1215   * ``BBNSS_Always`` (in configuration: ``Always``)
1216     Line breaks are allowed. But note that because of the associated
1217     penalties ``clang-format`` often prefers not to break before the
1218     ``noexcept``.
1220     .. code-block:: c++
1222       void foo(int arg1,
1223                double arg2) noexcept;
1225       void bar(int arg1, double arg2)
1226           noexcept(noexcept(baz(arg1)) &&
1227                    noexcept(baz(arg2)));
1231 .. _AllowShortBlocksOnASingleLine:
1233 **AllowShortBlocksOnASingleLine** (``ShortBlockStyle``) :versionbadge:`clang-format 3.5` :ref:`¶ <AllowShortBlocksOnASingleLine>`
1234   Dependent on the value, ``while (true) { continue; }`` can be put on a
1235   single line.
1237   Possible values:
1239   * ``SBS_Never`` (in configuration: ``Never``)
1240     Never merge blocks into a single line.
1242     .. code-block:: c++
1244       while (true) {
1245       }
1246       while (true) {
1247         continue;
1248       }
1250   * ``SBS_Empty`` (in configuration: ``Empty``)
1251     Only merge empty blocks.
1253     .. code-block:: c++
1255       while (true) {}
1256       while (true) {
1257         continue;
1258       }
1260   * ``SBS_Always`` (in configuration: ``Always``)
1261     Always merge short blocks into a single line.
1263     .. code-block:: c++
1265       while (true) {}
1266       while (true) { continue; }
1270 .. _AllowShortCaseLabelsOnASingleLine:
1272 **AllowShortCaseLabelsOnASingleLine** (``Boolean``) :versionbadge:`clang-format 3.6` :ref:`¶ <AllowShortCaseLabelsOnASingleLine>`
1273   If ``true``, short case labels will be contracted to a single line.
1275   .. code-block:: c++
1277     true:                                   false:
1278     switch (a) {                    vs.     switch (a) {
1279     case 1: x = 1; break;                   case 1:
1280     case 2: return;                           x = 1;
1281     }                                         break;
1282                                             case 2:
1283                                               return;
1284                                             }
1286 .. _AllowShortCompoundRequirementOnASingleLine:
1288 **AllowShortCompoundRequirementOnASingleLine** (``Boolean``) :versionbadge:`clang-format 18` :ref:`¶ <AllowShortCompoundRequirementOnASingleLine>`
1289   Allow short compound requirement on a single line.
1291   .. code-block:: c++
1293     true:
1294     template <typename T>
1295     concept c = requires(T x) {
1296       { x + 1 } -> std::same_as<int>;
1297     };
1299     false:
1300     template <typename T>
1301     concept c = requires(T x) {
1302       {
1303         x + 1
1304       } -> std::same_as<int>;
1305     };
1307 .. _AllowShortEnumsOnASingleLine:
1309 **AllowShortEnumsOnASingleLine** (``Boolean``) :versionbadge:`clang-format 11` :ref:`¶ <AllowShortEnumsOnASingleLine>`
1310   Allow short enums on a single line.
1312   .. code-block:: c++
1314     true:
1315     enum { A, B } myEnum;
1317     false:
1318     enum {
1319       A,
1320       B
1321     } myEnum;
1323 .. _AllowShortFunctionsOnASingleLine:
1325 **AllowShortFunctionsOnASingleLine** (``ShortFunctionStyle``) :versionbadge:`clang-format 3.5` :ref:`¶ <AllowShortFunctionsOnASingleLine>`
1326   Dependent on the value, ``int f() { return 0; }`` can be put on a
1327   single line.
1329   Possible values:
1331   * ``SFS_None`` (in configuration: ``None``)
1332     Never merge functions into a single line.
1334   * ``SFS_InlineOnly`` (in configuration: ``InlineOnly``)
1335     Only merge functions defined inside a class. Same as "inline",
1336     except it does not implies "empty": i.e. top level empty functions
1337     are not merged either.
1339     .. code-block:: c++
1341       class Foo {
1342         void f() { foo(); }
1343       };
1344       void f() {
1345         foo();
1346       }
1347       void f() {
1348       }
1350   * ``SFS_Empty`` (in configuration: ``Empty``)
1351     Only merge empty functions.
1353     .. code-block:: c++
1355       void f() {}
1356       void f2() {
1357         bar2();
1358       }
1360   * ``SFS_Inline`` (in configuration: ``Inline``)
1361     Only merge functions defined inside a class. Implies "empty".
1363     .. code-block:: c++
1365       class Foo {
1366         void f() { foo(); }
1367       };
1368       void f() {
1369         foo();
1370       }
1371       void f() {}
1373   * ``SFS_All`` (in configuration: ``All``)
1374     Merge all functions fitting on a single line.
1376     .. code-block:: c++
1378       class Foo {
1379         void f() { foo(); }
1380       };
1381       void f() { bar(); }
1385 .. _AllowShortIfStatementsOnASingleLine:
1387 **AllowShortIfStatementsOnASingleLine** (``ShortIfStyle``) :versionbadge:`clang-format 3.3` :ref:`¶ <AllowShortIfStatementsOnASingleLine>`
1388   Dependent on the value, ``if (a) return;`` can be put on a single line.
1390   Possible values:
1392   * ``SIS_Never`` (in configuration: ``Never``)
1393     Never put short ifs on the same line.
1395     .. code-block:: c++
1397       if (a)
1398         return;
1400       if (b)
1401         return;
1402       else
1403         return;
1405       if (c)
1406         return;
1407       else {
1408         return;
1409       }
1411   * ``SIS_WithoutElse`` (in configuration: ``WithoutElse``)
1412     Put short ifs on the same line only if there is no else statement.
1414     .. code-block:: c++
1416       if (a) return;
1418       if (b)
1419         return;
1420       else
1421         return;
1423       if (c)
1424         return;
1425       else {
1426         return;
1427       }
1429   * ``SIS_OnlyFirstIf`` (in configuration: ``OnlyFirstIf``)
1430     Put short ifs, but not else ifs nor else statements, on the same line.
1432     .. code-block:: c++
1434       if (a) return;
1436       if (b) return;
1437       else if (b)
1438         return;
1439       else
1440         return;
1442       if (c) return;
1443       else {
1444         return;
1445       }
1447   * ``SIS_AllIfsAndElse`` (in configuration: ``AllIfsAndElse``)
1448     Always put short ifs, else ifs and else statements on the same
1449     line.
1451     .. code-block:: c++
1453       if (a) return;
1455       if (b) return;
1456       else return;
1458       if (c) return;
1459       else {
1460         return;
1461       }
1465 .. _AllowShortLambdasOnASingleLine:
1467 **AllowShortLambdasOnASingleLine** (``ShortLambdaStyle``) :versionbadge:`clang-format 9` :ref:`¶ <AllowShortLambdasOnASingleLine>`
1468   Dependent on the value, ``auto lambda []() { return 0; }`` can be put on a
1469   single line.
1471   Possible values:
1473   * ``SLS_None`` (in configuration: ``None``)
1474     Never merge lambdas into a single line.
1476   * ``SLS_Empty`` (in configuration: ``Empty``)
1477     Only merge empty lambdas.
1479     .. code-block:: c++
1481       auto lambda = [](int a) {};
1482       auto lambda2 = [](int a) {
1483           return a;
1484       };
1486   * ``SLS_Inline`` (in configuration: ``Inline``)
1487     Merge lambda into a single line if the lambda is argument of a function.
1489     .. code-block:: c++
1491       auto lambda = [](int x, int y) {
1492           return x < y;
1493       };
1494       sort(a.begin(), a.end(), [](int x, int y) { return x < y; });
1496   * ``SLS_All`` (in configuration: ``All``)
1497     Merge all lambdas fitting on a single line.
1499     .. code-block:: c++
1501       auto lambda = [](int a) {};
1502       auto lambda2 = [](int a) { return a; };
1506 .. _AllowShortLoopsOnASingleLine:
1508 **AllowShortLoopsOnASingleLine** (``Boolean``) :versionbadge:`clang-format 3.7` :ref:`¶ <AllowShortLoopsOnASingleLine>`
1509   If ``true``, ``while (true) continue;`` can be put on a single
1510   line.
1512 .. _AlwaysBreakAfterDefinitionReturnType:
1514 **AlwaysBreakAfterDefinitionReturnType** (``DefinitionReturnTypeBreakingStyle``) :versionbadge:`clang-format 3.7` :ref:`¶ <AlwaysBreakAfterDefinitionReturnType>`
1515   The function definition return type breaking style to use.  This
1516   option is **deprecated** and is retained for backwards compatibility.
1518   Possible values:
1520   * ``DRTBS_None`` (in configuration: ``None``)
1521     Break after return type automatically.
1522     ``PenaltyReturnTypeOnItsOwnLine`` is taken into account.
1524   * ``DRTBS_All`` (in configuration: ``All``)
1525     Always break after the return type.
1527   * ``DRTBS_TopLevel`` (in configuration: ``TopLevel``)
1528     Always break after the return types of top-level functions.
1532 .. _AlwaysBreakAfterReturnType:
1534 **AlwaysBreakAfterReturnType** (``ReturnTypeBreakingStyle``) :versionbadge:`clang-format 3.8` :ref:`¶ <AlwaysBreakAfterReturnType>`
1535   The function declaration return type breaking style to use.
1537   Possible values:
1539   * ``RTBS_None`` (in configuration: ``None``)
1540     Break after return type automatically.
1541     ``PenaltyReturnTypeOnItsOwnLine`` is taken into account.
1543     .. code-block:: c++
1545       class A {
1546         int f() { return 0; };
1547       };
1548       int f();
1549       int f() { return 1; }
1551   * ``RTBS_All`` (in configuration: ``All``)
1552     Always break after the return type.
1554     .. code-block:: c++
1556       class A {
1557         int
1558         f() {
1559           return 0;
1560         };
1561       };
1562       int
1563       f();
1564       int
1565       f() {
1566         return 1;
1567       }
1569   * ``RTBS_TopLevel`` (in configuration: ``TopLevel``)
1570     Always break after the return types of top-level functions.
1572     .. code-block:: c++
1574       class A {
1575         int f() { return 0; };
1576       };
1577       int
1578       f();
1579       int
1580       f() {
1581         return 1;
1582       }
1584   * ``RTBS_AllDefinitions`` (in configuration: ``AllDefinitions``)
1585     Always break after the return type of function definitions.
1587     .. code-block:: c++
1589       class A {
1590         int
1591         f() {
1592           return 0;
1593         };
1594       };
1595       int f();
1596       int
1597       f() {
1598         return 1;
1599       }
1601   * ``RTBS_TopLevelDefinitions`` (in configuration: ``TopLevelDefinitions``)
1602     Always break after the return type of top-level definitions.
1604     .. code-block:: c++
1606       class A {
1607         int f() { return 0; };
1608       };
1609       int f();
1610       int
1611       f() {
1612         return 1;
1613       }
1617 .. _AlwaysBreakBeforeMultilineStrings:
1619 **AlwaysBreakBeforeMultilineStrings** (``Boolean``) :versionbadge:`clang-format 3.4` :ref:`¶ <AlwaysBreakBeforeMultilineStrings>`
1620   If ``true``, always break before multiline string literals.
1622   This flag is mean to make cases where there are multiple multiline strings
1623   in a file look more consistent. Thus, it will only take effect if wrapping
1624   the string at that point leads to it being indented
1625   ``ContinuationIndentWidth`` spaces from the start of the line.
1627   .. code-block:: c++
1629      true:                                  false:
1630      aaaa =                         vs.     aaaa = "bbbb"
1631          "bbbb"                                    "cccc";
1632          "cccc";
1634 .. _AlwaysBreakTemplateDeclarations:
1636 **AlwaysBreakTemplateDeclarations** (``BreakTemplateDeclarationsStyle``) :versionbadge:`clang-format 3.4` :ref:`¶ <AlwaysBreakTemplateDeclarations>`
1637   The template declaration breaking style to use.
1639   Possible values:
1641   * ``BTDS_No`` (in configuration: ``No``)
1642     Do not force break before declaration.
1643     ``PenaltyBreakTemplateDeclaration`` is taken into account.
1645     .. code-block:: c++
1647        template <typename T> T foo() {
1648        }
1649        template <typename T> T foo(int aaaaaaaaaaaaaaaaaaaaa,
1650                                    int bbbbbbbbbbbbbbbbbbbbb) {
1651        }
1653   * ``BTDS_MultiLine`` (in configuration: ``MultiLine``)
1654     Force break after template declaration only when the following
1655     declaration spans multiple lines.
1657     .. code-block:: c++
1659        template <typename T> T foo() {
1660        }
1661        template <typename T>
1662        T foo(int aaaaaaaaaaaaaaaaaaaaa,
1663              int bbbbbbbbbbbbbbbbbbbbb) {
1664        }
1666   * ``BTDS_Yes`` (in configuration: ``Yes``)
1667     Always break after template declaration.
1669     .. code-block:: c++
1671        template <typename T>
1672        T foo() {
1673        }
1674        template <typename T>
1675        T foo(int aaaaaaaaaaaaaaaaaaaaa,
1676              int bbbbbbbbbbbbbbbbbbbbb) {
1677        }
1681 .. _AttributeMacros:
1683 **AttributeMacros** (``List of Strings``) :versionbadge:`clang-format 12` :ref:`¶ <AttributeMacros>`
1684   A vector of strings that should be interpreted as attributes/qualifiers
1685   instead of identifiers. This can be useful for language extensions or
1686   static analyzer annotations.
1688   For example:
1690   .. code-block:: c++
1692     x = (char *__capability)&y;
1693     int function(void) __unused;
1694     void only_writes_to_buffer(char *__output buffer);
1696   In the .clang-format configuration file, this can be configured like:
1698   .. code-block:: yaml
1700     AttributeMacros: ['__capability', '__output', '__unused']
1702 .. _BinPackArguments:
1704 **BinPackArguments** (``Boolean``) :versionbadge:`clang-format 3.7` :ref:`¶ <BinPackArguments>`
1705   If ``false``, a function call's arguments will either be all on the
1706   same line or will have one line each.
1708   .. code-block:: c++
1710     true:
1711     void f() {
1712       f(aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa,
1713         aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
1714     }
1716     false:
1717     void f() {
1718       f(aaaaaaaaaaaaaaaaaaaa,
1719         aaaaaaaaaaaaaaaaaaaa,
1720         aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
1721     }
1723 .. _BinPackParameters:
1725 **BinPackParameters** (``Boolean``) :versionbadge:`clang-format 3.7` :ref:`¶ <BinPackParameters>`
1726   If ``false``, a function declaration's or function definition's
1727   parameters will either all be on the same line or will have one line each.
1729   .. code-block:: c++
1731     true:
1732     void f(int aaaaaaaaaaaaaaaaaaaa, int aaaaaaaaaaaaaaaaaaaa,
1733            int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}
1735     false:
1736     void f(int aaaaaaaaaaaaaaaaaaaa,
1737            int aaaaaaaaaaaaaaaaaaaa,
1738            int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}
1740 .. _BitFieldColonSpacing:
1742 **BitFieldColonSpacing** (``BitFieldColonSpacingStyle``) :versionbadge:`clang-format 12` :ref:`¶ <BitFieldColonSpacing>`
1743   The BitFieldColonSpacingStyle to use for bitfields.
1745   Possible values:
1747   * ``BFCS_Both`` (in configuration: ``Both``)
1748     Add one space on each side of the ``:``
1750     .. code-block:: c++
1752       unsigned bf : 2;
1754   * ``BFCS_None`` (in configuration: ``None``)
1755     Add no space around the ``:`` (except when needed for
1756     ``AlignConsecutiveBitFields``).
1758     .. code-block:: c++
1760       unsigned bf:2;
1762   * ``BFCS_Before`` (in configuration: ``Before``)
1763     Add space before the ``:`` only
1765     .. code-block:: c++
1767       unsigned bf :2;
1769   * ``BFCS_After`` (in configuration: ``After``)
1770     Add space after the ``:`` only (space may be added before if
1771     needed for ``AlignConsecutiveBitFields``).
1773     .. code-block:: c++
1775       unsigned bf: 2;
1779 .. _BraceWrapping:
1781 **BraceWrapping** (``BraceWrappingFlags``) :versionbadge:`clang-format 3.8` :ref:`¶ <BraceWrapping>`
1782   Control of individual brace wrapping cases.
1784   If ``BreakBeforeBraces`` is set to ``BS_Custom``, use this to specify how
1785   each individual brace case should be handled. Otherwise, this is ignored.
1787   .. code-block:: yaml
1789     # Example of usage:
1790     BreakBeforeBraces: Custom
1791     BraceWrapping:
1792       AfterEnum: true
1793       AfterStruct: false
1794       SplitEmptyFunction: false
1796   Nested configuration flags:
1798   Precise control over the wrapping of braces.
1800   .. code-block:: c++
1802     # Should be declared this way:
1803     BreakBeforeBraces: Custom
1804     BraceWrapping:
1805         AfterClass: true
1807   * ``bool AfterCaseLabel`` Wrap case labels.
1809     .. code-block:: c++
1811       false:                                true:
1812       switch (foo) {                vs.     switch (foo) {
1813         case 1: {                             case 1:
1814           bar();                              {
1815           break;                                bar();
1816         }                                       break;
1817         default: {                            }
1818           plop();                             default:
1819         }                                     {
1820       }                                         plop();
1821                                               }
1822                                             }
1824   * ``bool AfterClass`` Wrap class definitions.
1826     .. code-block:: c++
1828       true:
1829       class foo
1830       {};
1832       false:
1833       class foo {};
1835   * ``BraceWrappingAfterControlStatementStyle AfterControlStatement``
1836     Wrap control statements (``if``/``for``/``while``/``switch``/..).
1838     Possible values:
1840     * ``BWACS_Never`` (in configuration: ``Never``)
1841       Never wrap braces after a control statement.
1843       .. code-block:: c++
1845         if (foo()) {
1846         } else {
1847         }
1848         for (int i = 0; i < 10; ++i) {
1849         }
1851     * ``BWACS_MultiLine`` (in configuration: ``MultiLine``)
1852       Only wrap braces after a multi-line control statement.
1854       .. code-block:: c++
1856         if (foo && bar &&
1857             baz)
1858         {
1859           quux();
1860         }
1861         while (foo || bar) {
1862         }
1864     * ``BWACS_Always`` (in configuration: ``Always``)
1865       Always wrap braces after a control statement.
1867       .. code-block:: c++
1869         if (foo())
1870         {
1871         } else
1872         {}
1873         for (int i = 0; i < 10; ++i)
1874         {}
1877   * ``bool AfterEnum`` Wrap enum definitions.
1879     .. code-block:: c++
1881       true:
1882       enum X : int
1883       {
1884         B
1885       };
1887       false:
1888       enum X : int { B };
1890   * ``bool AfterFunction`` Wrap function definitions.
1892     .. code-block:: c++
1894       true:
1895       void foo()
1896       {
1897         bar();
1898         bar2();
1899       }
1901       false:
1902       void foo() {
1903         bar();
1904         bar2();
1905       }
1907   * ``bool AfterNamespace`` Wrap namespace definitions.
1909     .. code-block:: c++
1911       true:
1912       namespace
1913       {
1914       int foo();
1915       int bar();
1916       }
1918       false:
1919       namespace {
1920       int foo();
1921       int bar();
1922       }
1924   * ``bool AfterObjCDeclaration`` Wrap ObjC definitions (interfaces, implementations...).
1926     .. note::
1928      @autoreleasepool and @synchronized blocks are wrapped
1929      according to ``AfterControlStatement`` flag.
1931   * ``bool AfterStruct`` Wrap struct definitions.
1933     .. code-block:: c++
1935       true:
1936       struct foo
1937       {
1938         int x;
1939       };
1941       false:
1942       struct foo {
1943         int x;
1944       };
1946   * ``bool AfterUnion`` Wrap union definitions.
1948     .. code-block:: c++
1950       true:
1951       union foo
1952       {
1953         int x;
1954       }
1956       false:
1957       union foo {
1958         int x;
1959       }
1961   * ``bool AfterExternBlock`` Wrap extern blocks.
1963     .. code-block:: c++
1965       true:
1966       extern "C"
1967       {
1968         int foo();
1969       }
1971       false:
1972       extern "C" {
1973       int foo();
1974       }
1976   * ``bool BeforeCatch`` Wrap before ``catch``.
1978     .. code-block:: c++
1980       true:
1981       try {
1982         foo();
1983       }
1984       catch () {
1985       }
1987       false:
1988       try {
1989         foo();
1990       } catch () {
1991       }
1993   * ``bool BeforeElse`` Wrap before ``else``.
1995     .. code-block:: c++
1997       true:
1998       if (foo()) {
1999       }
2000       else {
2001       }
2003       false:
2004       if (foo()) {
2005       } else {
2006       }
2008   * ``bool BeforeLambdaBody`` Wrap lambda block.
2010     .. code-block:: c++
2012       true:
2013       connect(
2014         []()
2015         {
2016           foo();
2017           bar();
2018         });
2020       false:
2021       connect([]() {
2022         foo();
2023         bar();
2024       });
2026   * ``bool BeforeWhile`` Wrap before ``while``.
2028     .. code-block:: c++
2030       true:
2031       do {
2032         foo();
2033       }
2034       while (1);
2036       false:
2037       do {
2038         foo();
2039       } while (1);
2041   * ``bool IndentBraces`` Indent the wrapped braces themselves.
2043   * ``bool SplitEmptyFunction`` If ``false``, empty function body can be put on a single line.
2044     This option is used only if the opening brace of the function has
2045     already been wrapped, i.e. the ``AfterFunction`` brace wrapping mode is
2046     set, and the function could/should not be put on a single line (as per
2047     ``AllowShortFunctionsOnASingleLine`` and constructor formatting
2048     options).
2050     .. code-block:: c++
2052       false:          true:
2053       int f()   vs.   int f()
2054       {}              {
2055                       }
2057   * ``bool SplitEmptyRecord`` If ``false``, empty record (e.g. class, struct or union) body
2058     can be put on a single line. This option is used only if the opening
2059     brace of the record has already been wrapped, i.e. the ``AfterClass``
2060     (for classes) brace wrapping mode is set.
2062     .. code-block:: c++
2064       false:           true:
2065       class Foo   vs.  class Foo
2066       {}               {
2067                        }
2069   * ``bool SplitEmptyNamespace`` If ``false``, empty namespace body can be put on a single line.
2070     This option is used only if the opening brace of the namespace has
2071     already been wrapped, i.e. the ``AfterNamespace`` brace wrapping mode is
2072     set.
2074     .. code-block:: c++
2076       false:               true:
2077       namespace Foo   vs.  namespace Foo
2078       {}                   {
2079                            }
2082 .. _BracedInitializerIndentWidth:
2084 **BracedInitializerIndentWidth** (``Unsigned``) :versionbadge:`clang-format 17` :ref:`¶ <BracedInitializerIndentWidth>`
2085   The number of columns to use to indent the contents of braced init lists.
2086   If unset, ``ContinuationIndentWidth`` is used.
2088   .. code-block:: c++
2090     AlignAfterOpenBracket: AlwaysBreak
2091     BracedInitializerIndentWidth: 2
2093     void f() {
2094       SomeClass c{
2095         "foo",
2096         "bar",
2097         "baz",
2098       };
2099       auto s = SomeStruct{
2100         .foo = "foo",
2101         .bar = "bar",
2102         .baz = "baz",
2103       };
2104       SomeArrayT a[3] = {
2105         {
2106           foo,
2107           bar,
2108         },
2109         {
2110           foo,
2111           bar,
2112         },
2113         SomeArrayT{},
2114       };
2115     }
2117 .. _BreakAdjacentStringLiterals:
2119 **BreakAdjacentStringLiterals** (``Boolean``) :versionbadge:`clang-format 18` :ref:`¶ <BreakAdjacentStringLiterals>`
2120   Break between adjacent string literals.
2122   .. code-block:: c++
2124      true:
2125      return "Code"
2126             "\0\52\26\55\55\0"
2127             "x013"
2128             "\02\xBA";
2129      false:
2130      return "Code" "\0\52\26\55\55\0" "x013" "\02\xBA";
2132 .. _BreakAfterAttributes:
2134 **BreakAfterAttributes** (``AttributeBreakingStyle``) :versionbadge:`clang-format 16` :ref:`¶ <BreakAfterAttributes>`
2135   Break after a group of C++11 attributes before variable or function
2136   (including constructor/destructor) declaration/definition names or before
2137   control statements, i.e. ``if``, ``switch`` (including ``case`` and
2138   ``default`` labels), ``for``, and ``while`` statements.
2140   Possible values:
2142   * ``ABS_Always`` (in configuration: ``Always``)
2143     Always break after attributes.
2145     .. code-block:: c++
2147       [[maybe_unused]]
2148       const int i;
2149       [[gnu::const]] [[maybe_unused]]
2150       int j;
2152       [[nodiscard]]
2153       inline int f();
2154       [[gnu::const]] [[nodiscard]]
2155       int g();
2157       [[likely]]
2158       if (a)
2159         f();
2160       else
2161         g();
2163       switch (b) {
2164       [[unlikely]]
2165       case 1:
2166         ++b;
2167         break;
2168       [[likely]]
2169       default:
2170         return;
2171       }
2173   * ``ABS_Leave`` (in configuration: ``Leave``)
2174     Leave the line breaking after attributes as is.
2176     .. code-block:: c++
2178       [[maybe_unused]] const int i;
2179       [[gnu::const]] [[maybe_unused]]
2180       int j;
2182       [[nodiscard]] inline int f();
2183       [[gnu::const]] [[nodiscard]]
2184       int g();
2186       [[likely]] if (a)
2187         f();
2188       else
2189         g();
2191       switch (b) {
2192       [[unlikely]] case 1:
2193         ++b;
2194         break;
2195       [[likely]]
2196       default:
2197         return;
2198       }
2200   * ``ABS_Never`` (in configuration: ``Never``)
2201     Never break after attributes.
2203     .. code-block:: c++
2205       [[maybe_unused]] const int i;
2206       [[gnu::const]] [[maybe_unused]] int j;
2208       [[nodiscard]] inline int f();
2209       [[gnu::const]] [[nodiscard]] int g();
2211       [[likely]] if (a)
2212         f();
2213       else
2214         g();
2216       switch (b) {
2217       [[unlikely]] case 1:
2218         ++b;
2219         break;
2220       [[likely]] default:
2221         return;
2222       }
2226 .. _BreakAfterJavaFieldAnnotations:
2228 **BreakAfterJavaFieldAnnotations** (``Boolean``) :versionbadge:`clang-format 3.8` :ref:`¶ <BreakAfterJavaFieldAnnotations>`
2229   Break after each annotation on a field in Java files.
2231   .. code-block:: java
2233      true:                                  false:
2234      @Partial                       vs.     @Partial @Mock DataLoad loader;
2235      @Mock
2236      DataLoad loader;
2238 .. _BreakArrays:
2240 **BreakArrays** (``Boolean``) :versionbadge:`clang-format 16` :ref:`¶ <BreakArrays>`
2241   If ``true``, clang-format will always break after a Json array ``[``
2242   otherwise it will scan until the closing ``]`` to determine if it should
2243   add newlines between elements (prettier compatible).
2246   .. note::
2248    This is currently only for formatting JSON.
2250   .. code-block:: c++
2252      true:                                  false:
2253      [                          vs.      [1, 2, 3, 4]
2254        1,
2255        2,
2256        3,
2257        4
2258      ]
2260 .. _BreakBeforeBinaryOperators:
2262 **BreakBeforeBinaryOperators** (``BinaryOperatorStyle``) :versionbadge:`clang-format 3.6` :ref:`¶ <BreakBeforeBinaryOperators>`
2263   The way to wrap binary operators.
2265   Possible values:
2267   * ``BOS_None`` (in configuration: ``None``)
2268     Break after operators.
2270     .. code-block:: c++
2272        LooooooooooongType loooooooooooooooooooooongVariable =
2273            someLooooooooooooooooongFunction();
2275        bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
2276                             aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ==
2277                         aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &&
2278                     aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa >
2279                         ccccccccccccccccccccccccccccccccccccccccc;
2281   * ``BOS_NonAssignment`` (in configuration: ``NonAssignment``)
2282     Break before operators that aren't assignments.
2284     .. code-block:: c++
2286        LooooooooooongType loooooooooooooooooooooongVariable =
2287            someLooooooooooooooooongFunction();
2289        bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
2290                             + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
2291                         == aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
2292                     && aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
2293                            > ccccccccccccccccccccccccccccccccccccccccc;
2295   * ``BOS_All`` (in configuration: ``All``)
2296     Break before operators.
2298     .. code-block:: c++
2300        LooooooooooongType loooooooooooooooooooooongVariable
2301            = someLooooooooooooooooongFunction();
2303        bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
2304                             + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
2305                         == aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
2306                     && aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
2307                            > ccccccccccccccccccccccccccccccccccccccccc;
2311 .. _BreakBeforeBraces:
2313 **BreakBeforeBraces** (``BraceBreakingStyle``) :versionbadge:`clang-format 3.7` :ref:`¶ <BreakBeforeBraces>`
2314   The brace breaking style to use.
2316   Possible values:
2318   * ``BS_Attach`` (in configuration: ``Attach``)
2319     Always attach braces to surrounding context.
2321     .. code-block:: c++
2323       namespace N {
2324       enum E {
2325         E1,
2326         E2,
2327       };
2329       class C {
2330       public:
2331         C();
2332       };
2334       bool baz(int i) {
2335         try {
2336           do {
2337             switch (i) {
2338             case 1: {
2339               foobar();
2340               break;
2341             }
2342             default: {
2343               break;
2344             }
2345             }
2346           } while (--i);
2347           return true;
2348         } catch (...) {
2349           handleError();
2350           return false;
2351         }
2352       }
2354       void foo(bool b) {
2355         if (b) {
2356           baz(2);
2357         } else {
2358           baz(5);
2359         }
2360       }
2362       void bar() { foo(true); }
2363       } // namespace N
2365   * ``BS_Linux`` (in configuration: ``Linux``)
2366     Like ``Attach``, but break before braces on function, namespace and
2367     class definitions.
2369     .. code-block:: c++
2371       namespace N
2372       {
2373       enum E {
2374         E1,
2375         E2,
2376       };
2378       class C
2379       {
2380       public:
2381         C();
2382       };
2384       bool baz(int i)
2385       {
2386         try {
2387           do {
2388             switch (i) {
2389             case 1: {
2390               foobar();
2391               break;
2392             }
2393             default: {
2394               break;
2395             }
2396             }
2397           } while (--i);
2398           return true;
2399         } catch (...) {
2400           handleError();
2401           return false;
2402         }
2403       }
2405       void foo(bool b)
2406       {
2407         if (b) {
2408           baz(2);
2409         } else {
2410           baz(5);
2411         }
2412       }
2414       void bar() { foo(true); }
2415       } // namespace N
2417   * ``BS_Mozilla`` (in configuration: ``Mozilla``)
2418     Like ``Attach``, but break before braces on enum, function, and record
2419     definitions.
2421     .. code-block:: c++
2423       namespace N {
2424       enum E
2425       {
2426         E1,
2427         E2,
2428       };
2430       class C
2431       {
2432       public:
2433         C();
2434       };
2436       bool baz(int i)
2437       {
2438         try {
2439           do {
2440             switch (i) {
2441             case 1: {
2442               foobar();
2443               break;
2444             }
2445             default: {
2446               break;
2447             }
2448             }
2449           } while (--i);
2450           return true;
2451         } catch (...) {
2452           handleError();
2453           return false;
2454         }
2455       }
2457       void foo(bool b)
2458       {
2459         if (b) {
2460           baz(2);
2461         } else {
2462           baz(5);
2463         }
2464       }
2466       void bar() { foo(true); }
2467       } // namespace N
2469   * ``BS_Stroustrup`` (in configuration: ``Stroustrup``)
2470     Like ``Attach``, but break before function definitions, ``catch``, and
2471     ``else``.
2473     .. code-block:: c++
2475       namespace N {
2476       enum E {
2477         E1,
2478         E2,
2479       };
2481       class C {
2482       public:
2483         C();
2484       };
2486       bool baz(int i)
2487       {
2488         try {
2489           do {
2490             switch (i) {
2491             case 1: {
2492               foobar();
2493               break;
2494             }
2495             default: {
2496               break;
2497             }
2498             }
2499           } while (--i);
2500           return true;
2501         }
2502         catch (...) {
2503           handleError();
2504           return false;
2505         }
2506       }
2508       void foo(bool b)
2509       {
2510         if (b) {
2511           baz(2);
2512         }
2513         else {
2514           baz(5);
2515         }
2516       }
2518       void bar() { foo(true); }
2519       } // namespace N
2521   * ``BS_Allman`` (in configuration: ``Allman``)
2522     Always break before braces.
2524     .. code-block:: c++
2526       namespace N
2527       {
2528       enum E
2529       {
2530         E1,
2531         E2,
2532       };
2534       class C
2535       {
2536       public:
2537         C();
2538       };
2540       bool baz(int i)
2541       {
2542         try
2543         {
2544           do
2545           {
2546             switch (i)
2547             {
2548             case 1:
2549             {
2550               foobar();
2551               break;
2552             }
2553             default:
2554             {
2555               break;
2556             }
2557             }
2558           } while (--i);
2559           return true;
2560         }
2561         catch (...)
2562         {
2563           handleError();
2564           return false;
2565         }
2566       }
2568       void foo(bool b)
2569       {
2570         if (b)
2571         {
2572           baz(2);
2573         }
2574         else
2575         {
2576           baz(5);
2577         }
2578       }
2580       void bar() { foo(true); }
2581       } // namespace N
2583   * ``BS_Whitesmiths`` (in configuration: ``Whitesmiths``)
2584     Like ``Allman`` but always indent braces and line up code with braces.
2586     .. code-block:: c++
2588       namespace N
2589         {
2590       enum E
2591         {
2592         E1,
2593         E2,
2594         };
2596       class C
2597         {
2598       public:
2599         C();
2600         };
2602       bool baz(int i)
2603         {
2604         try
2605           {
2606           do
2607             {
2608             switch (i)
2609               {
2610               case 1:
2611               {
2612               foobar();
2613               break;
2614               }
2615               default:
2616               {
2617               break;
2618               }
2619               }
2620             } while (--i);
2621           return true;
2622           }
2623         catch (...)
2624           {
2625           handleError();
2626           return false;
2627           }
2628         }
2630       void foo(bool b)
2631         {
2632         if (b)
2633           {
2634           baz(2);
2635           }
2636         else
2637           {
2638           baz(5);
2639           }
2640         }
2642       void bar() { foo(true); }
2643         } // namespace N
2645   * ``BS_GNU`` (in configuration: ``GNU``)
2646     Always break before braces and add an extra level of indentation to
2647     braces of control statements, not to those of class, function
2648     or other definitions.
2650     .. code-block:: c++
2652       namespace N
2653       {
2654       enum E
2655       {
2656         E1,
2657         E2,
2658       };
2660       class C
2661       {
2662       public:
2663         C();
2664       };
2666       bool baz(int i)
2667       {
2668         try
2669           {
2670             do
2671               {
2672                 switch (i)
2673                   {
2674                   case 1:
2675                     {
2676                       foobar();
2677                       break;
2678                     }
2679                   default:
2680                     {
2681                       break;
2682                     }
2683                   }
2684               }
2685             while (--i);
2686             return true;
2687           }
2688         catch (...)
2689           {
2690             handleError();
2691             return false;
2692           }
2693       }
2695       void foo(bool b)
2696       {
2697         if (b)
2698           {
2699             baz(2);
2700           }
2701         else
2702           {
2703             baz(5);
2704           }
2705       }
2707       void bar() { foo(true); }
2708       } // namespace N
2710   * ``BS_WebKit`` (in configuration: ``WebKit``)
2711     Like ``Attach``, but break before functions.
2713     .. code-block:: c++
2715       namespace N {
2716       enum E {
2717         E1,
2718         E2,
2719       };
2721       class C {
2722       public:
2723         C();
2724       };
2726       bool baz(int i)
2727       {
2728         try {
2729           do {
2730             switch (i) {
2731             case 1: {
2732               foobar();
2733               break;
2734             }
2735             default: {
2736               break;
2737             }
2738             }
2739           } while (--i);
2740           return true;
2741         } catch (...) {
2742           handleError();
2743           return false;
2744         }
2745       }
2747       void foo(bool b)
2748       {
2749         if (b) {
2750           baz(2);
2751         } else {
2752           baz(5);
2753         }
2754       }
2756       void bar() { foo(true); }
2757       } // namespace N
2759   * ``BS_Custom`` (in configuration: ``Custom``)
2760     Configure each individual brace in ``BraceWrapping``.
2764 .. _BreakBeforeConceptDeclarations:
2766 **BreakBeforeConceptDeclarations** (``BreakBeforeConceptDeclarationsStyle``) :versionbadge:`clang-format 12` :ref:`¶ <BreakBeforeConceptDeclarations>`
2767   The concept declaration style to use.
2769   Possible values:
2771   * ``BBCDS_Never`` (in configuration: ``Never``)
2772     Keep the template declaration line together with ``concept``.
2774     .. code-block:: c++
2776       template <typename T> concept C = ...;
2778   * ``BBCDS_Allowed`` (in configuration: ``Allowed``)
2779     Breaking between template declaration and ``concept`` is allowed. The
2780     actual behavior depends on the content and line breaking rules and
2781     penalties.
2783   * ``BBCDS_Always`` (in configuration: ``Always``)
2784     Always break before ``concept``, putting it in the line after the
2785     template declaration.
2787     .. code-block:: c++
2789       template <typename T>
2790       concept C = ...;
2794 .. _BreakBeforeInlineASMColon:
2796 **BreakBeforeInlineASMColon** (``BreakBeforeInlineASMColonStyle``) :versionbadge:`clang-format 16` :ref:`¶ <BreakBeforeInlineASMColon>`
2797   The inline ASM colon style to use.
2799   Possible values:
2801   * ``BBIAS_Never`` (in configuration: ``Never``)
2802     No break before inline ASM colon.
2804     .. code-block:: c++
2806        asm volatile("string", : : val);
2808   * ``BBIAS_OnlyMultiline`` (in configuration: ``OnlyMultiline``)
2809     Break before inline ASM colon if the line length is longer than column
2810     limit.
2812     .. code-block:: c++
2814        asm volatile("string", : : val);
2815        asm("cmoveq %1, %2, %[result]"
2816            : [result] "=r"(result)
2817            : "r"(test), "r"(new), "[result]"(old));
2819   * ``BBIAS_Always`` (in configuration: ``Always``)
2820     Always break before inline ASM colon.
2822     .. code-block:: c++
2824        asm volatile("string",
2825                     :
2826                     : val);
2830 .. _BreakBeforeTernaryOperators:
2832 **BreakBeforeTernaryOperators** (``Boolean``) :versionbadge:`clang-format 3.7` :ref:`¶ <BreakBeforeTernaryOperators>`
2833   If ``true``, ternary operators will be placed after line breaks.
2835   .. code-block:: c++
2837      true:
2838      veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongDescription
2839          ? firstValue
2840          : SecondValueVeryVeryVeryVeryLong;
2842      false:
2843      veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongDescription ?
2844          firstValue :
2845          SecondValueVeryVeryVeryVeryLong;
2847 .. _BreakConstructorInitializers:
2849 **BreakConstructorInitializers** (``BreakConstructorInitializersStyle``) :versionbadge:`clang-format 5` :ref:`¶ <BreakConstructorInitializers>`
2850   The break constructor initializers style to use.
2852   Possible values:
2854   * ``BCIS_BeforeColon`` (in configuration: ``BeforeColon``)
2855     Break constructor initializers before the colon and after the commas.
2857     .. code-block:: c++
2859        Constructor()
2860            : initializer1(),
2861              initializer2()
2863   * ``BCIS_BeforeComma`` (in configuration: ``BeforeComma``)
2864     Break constructor initializers before the colon and commas, and align
2865     the commas with the colon.
2867     .. code-block:: c++
2869        Constructor()
2870            : initializer1()
2871            , initializer2()
2873   * ``BCIS_AfterColon`` (in configuration: ``AfterColon``)
2874     Break constructor initializers after the colon and commas.
2876     .. code-block:: c++
2878        Constructor() :
2879            initializer1(),
2880            initializer2()
2884 .. _BreakInheritanceList:
2886 **BreakInheritanceList** (``BreakInheritanceListStyle``) :versionbadge:`clang-format 7` :ref:`¶ <BreakInheritanceList>`
2887   The inheritance list style to use.
2889   Possible values:
2891   * ``BILS_BeforeColon`` (in configuration: ``BeforeColon``)
2892     Break inheritance list before the colon and after the commas.
2894     .. code-block:: c++
2896        class Foo
2897            : Base1,
2898              Base2
2899        {};
2901   * ``BILS_BeforeComma`` (in configuration: ``BeforeComma``)
2902     Break inheritance list before the colon and commas, and align
2903     the commas with the colon.
2905     .. code-block:: c++
2907        class Foo
2908            : Base1
2909            , Base2
2910        {};
2912   * ``BILS_AfterColon`` (in configuration: ``AfterColon``)
2913     Break inheritance list after the colon and commas.
2915     .. code-block:: c++
2917        class Foo :
2918            Base1,
2919            Base2
2920        {};
2922   * ``BILS_AfterComma`` (in configuration: ``AfterComma``)
2923     Break inheritance list only after the commas.
2925     .. code-block:: c++
2927        class Foo : Base1,
2928                    Base2
2929        {};
2933 .. _BreakStringLiterals:
2935 **BreakStringLiterals** (``Boolean``) :versionbadge:`clang-format 3.9` :ref:`¶ <BreakStringLiterals>`
2936   Allow breaking string literals when formatting.
2938   In C, C++, and Objective-C:
2940   .. code-block:: c++
2942      true:
2943      const char* x = "veryVeryVeryVeryVeryVe"
2944                      "ryVeryVeryVeryVeryVery"
2945                      "VeryLongString";
2947      false:
2948      const char* x =
2949          "veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongString";
2951   In C# and Java:
2953   .. code-block:: c++
2955      true:
2956      string x = "veryVeryVeryVeryVeryVe" +
2957                 "ryVeryVeryVeryVeryVery" +
2958                 "VeryLongString";
2960      false:
2961      string x =
2962          "veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongString";
2964   C# interpolated strings are not broken.
2966   In Verilog:
2968   .. code-block:: c++
2970      true:
2971      string x = {"veryVeryVeryVeryVeryVe",
2972                  "ryVeryVeryVeryVeryVery",
2973                  "VeryLongString"};
2975      false:
2976      string x =
2977          "veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongString";
2979 .. _ColumnLimit:
2981 **ColumnLimit** (``Unsigned``) :versionbadge:`clang-format 3.7` :ref:`¶ <ColumnLimit>`
2982   The column limit.
2984   A column limit of ``0`` means that there is no column limit. In this case,
2985   clang-format will respect the input's line breaking decisions within
2986   statements unless they contradict other rules.
2988 .. _CommentPragmas:
2990 **CommentPragmas** (``String``) :versionbadge:`clang-format 3.7` :ref:`¶ <CommentPragmas>`
2991   A regular expression that describes comments with special meaning,
2992   which should not be split into lines or otherwise changed.
2994   .. code-block:: c++
2996      // CommentPragmas: '^ FOOBAR pragma:'
2997      // Will leave the following line unaffected
2998      #include <vector> // FOOBAR pragma: keep
3000 .. _CompactNamespaces:
3002 **CompactNamespaces** (``Boolean``) :versionbadge:`clang-format 5` :ref:`¶ <CompactNamespaces>`
3003   If ``true``, consecutive namespace declarations will be on the same
3004   line. If ``false``, each namespace is declared on a new line.
3006   .. code-block:: c++
3008     true:
3009     namespace Foo { namespace Bar {
3010     }}
3012     false:
3013     namespace Foo {
3014     namespace Bar {
3015     }
3016     }
3018   If it does not fit on a single line, the overflowing namespaces get
3019   wrapped:
3021   .. code-block:: c++
3023     namespace Foo { namespace Bar {
3024     namespace Extra {
3025     }}}
3027 .. _ConstructorInitializerAllOnOneLineOrOnePerLine:
3029 **ConstructorInitializerAllOnOneLineOrOnePerLine** (``Boolean``) :versionbadge:`clang-format 3.7` :ref:`¶ <ConstructorInitializerAllOnOneLineOrOnePerLine>`
3030   This option is **deprecated**. See ``CurrentLine`` of
3031   ``PackConstructorInitializers``.
3033 .. _ConstructorInitializerIndentWidth:
3035 **ConstructorInitializerIndentWidth** (``Unsigned``) :versionbadge:`clang-format 3.7` :ref:`¶ <ConstructorInitializerIndentWidth>`
3036   The number of characters to use for indentation of constructor
3037   initializer lists as well as inheritance lists.
3039 .. _ContinuationIndentWidth:
3041 **ContinuationIndentWidth** (``Unsigned``) :versionbadge:`clang-format 3.7` :ref:`¶ <ContinuationIndentWidth>`
3042   Indent width for line continuations.
3044   .. code-block:: c++
3046      ContinuationIndentWidth: 2
3048      int i =         //  VeryVeryVeryVeryVeryLongComment
3049        longFunction( // Again a long comment
3050          arg);
3052 .. _Cpp11BracedListStyle:
3054 **Cpp11BracedListStyle** (``Boolean``) :versionbadge:`clang-format 3.4` :ref:`¶ <Cpp11BracedListStyle>`
3055   If ``true``, format braced lists as best suited for C++11 braced
3056   lists.
3058   Important differences:
3059   - No spaces inside the braced list.
3060   - No line break before the closing brace.
3061   - Indentation with the continuation indent, not with the block indent.
3063   Fundamentally, C++11 braced lists are formatted exactly like function
3064   calls would be formatted in their place. If the braced list follows a name
3065   (e.g. a type or variable name), clang-format formats as if the ``{}`` were
3066   the parentheses of a function call with that name. If there is no name,
3067   a zero-length name is assumed.
3069   .. code-block:: c++
3071      true:                                  false:
3072      vector<int> x{1, 2, 3, 4};     vs.     vector<int> x{ 1, 2, 3, 4 };
3073      vector<T> x{{}, {}, {}, {}};           vector<T> x{ {}, {}, {}, {} };
3074      f(MyMap[{composite, key}]);            f(MyMap[{ composite, key }]);
3075      new int[3]{1, 2, 3};                   new int[3]{ 1, 2, 3 };
3077 .. _DeriveLineEnding:
3079 **DeriveLineEnding** (``Boolean``) :versionbadge:`clang-format 10` :ref:`¶ <DeriveLineEnding>`
3080   This option is **deprecated**. See ``DeriveLF`` and ``DeriveCRLF`` of
3081   ``LineEnding``.
3083 .. _DerivePointerAlignment:
3085 **DerivePointerAlignment** (``Boolean``) :versionbadge:`clang-format 3.7` :ref:`¶ <DerivePointerAlignment>`
3086   If ``true``, analyze the formatted file for the most common
3087   alignment of ``&`` and ``*``.
3088   Pointer and reference alignment styles are going to be updated according
3089   to the preferences found in the file.
3090   ``PointerAlignment`` is then used only as fallback.
3092 .. _DisableFormat:
3094 **DisableFormat** (``Boolean``) :versionbadge:`clang-format 3.7` :ref:`¶ <DisableFormat>`
3095   Disables formatting completely.
3097 .. _EmptyLineAfterAccessModifier:
3099 **EmptyLineAfterAccessModifier** (``EmptyLineAfterAccessModifierStyle``) :versionbadge:`clang-format 13` :ref:`¶ <EmptyLineAfterAccessModifier>`
3100   Defines when to put an empty line after access modifiers.
3101   ``EmptyLineBeforeAccessModifier`` configuration handles the number of
3102   empty lines between two access modifiers.
3104   Possible values:
3106   * ``ELAAMS_Never`` (in configuration: ``Never``)
3107     Remove all empty lines after access modifiers.
3109     .. code-block:: c++
3111       struct foo {
3112       private:
3113         int i;
3114       protected:
3115         int j;
3116         /* comment */
3117       public:
3118         foo() {}
3119       private:
3120       protected:
3121       };
3123   * ``ELAAMS_Leave`` (in configuration: ``Leave``)
3124     Keep existing empty lines after access modifiers.
3125     MaxEmptyLinesToKeep is applied instead.
3127   * ``ELAAMS_Always`` (in configuration: ``Always``)
3128     Always add empty line after access modifiers if there are none.
3129     MaxEmptyLinesToKeep is applied also.
3131     .. code-block:: c++
3133       struct foo {
3134       private:
3136         int i;
3137       protected:
3139         int j;
3140         /* comment */
3141       public:
3143         foo() {}
3144       private:
3146       protected:
3148       };
3152 .. _EmptyLineBeforeAccessModifier:
3154 **EmptyLineBeforeAccessModifier** (``EmptyLineBeforeAccessModifierStyle``) :versionbadge:`clang-format 12` :ref:`¶ <EmptyLineBeforeAccessModifier>`
3155   Defines in which cases to put empty line before access modifiers.
3157   Possible values:
3159   * ``ELBAMS_Never`` (in configuration: ``Never``)
3160     Remove all empty lines before access modifiers.
3162     .. code-block:: c++
3164       struct foo {
3165       private:
3166         int i;
3167       protected:
3168         int j;
3169         /* comment */
3170       public:
3171         foo() {}
3172       private:
3173       protected:
3174       };
3176   * ``ELBAMS_Leave`` (in configuration: ``Leave``)
3177     Keep existing empty lines before access modifiers.
3179   * ``ELBAMS_LogicalBlock`` (in configuration: ``LogicalBlock``)
3180     Add empty line only when access modifier starts a new logical block.
3181     Logical block is a group of one or more member fields or functions.
3183     .. code-block:: c++
3185       struct foo {
3186       private:
3187         int i;
3189       protected:
3190         int j;
3191         /* comment */
3192       public:
3193         foo() {}
3195       private:
3196       protected:
3197       };
3199   * ``ELBAMS_Always`` (in configuration: ``Always``)
3200     Always add empty line before access modifiers unless access modifier
3201     is at the start of struct or class definition.
3203     .. code-block:: c++
3205       struct foo {
3206       private:
3207         int i;
3209       protected:
3210         int j;
3211         /* comment */
3213       public:
3214         foo() {}
3216       private:
3218       protected:
3219       };
3223 .. _ExperimentalAutoDetectBinPacking:
3225 **ExperimentalAutoDetectBinPacking** (``Boolean``) :versionbadge:`clang-format 3.7` :ref:`¶ <ExperimentalAutoDetectBinPacking>`
3226   If ``true``, clang-format detects whether function calls and
3227   definitions are formatted with one parameter per line.
3229   Each call can be bin-packed, one-per-line or inconclusive. If it is
3230   inconclusive, e.g. completely on one line, but a decision needs to be
3231   made, clang-format analyzes whether there are other bin-packed cases in
3232   the input file and act accordingly.
3235   .. note::
3237    This is an experimental flag, that might go away or be renamed. Do
3238    not use this in config files, etc. Use at your own risk.
3240 .. _FixNamespaceComments:
3242 **FixNamespaceComments** (``Boolean``) :versionbadge:`clang-format 5` :ref:`¶ <FixNamespaceComments>`
3243   If ``true``, clang-format adds missing namespace end comments for
3244   namespaces and fixes invalid existing ones. This doesn't affect short
3245   namespaces, which are controlled by ``ShortNamespaceLines``.
3247   .. code-block:: c++
3249      true:                                  false:
3250      namespace longNamespace {      vs.     namespace longNamespace {
3251      void foo();                            void foo();
3252      void bar();                            void bar();
3253      } // namespace a                       }
3254      namespace shortNamespace {             namespace shortNamespace {
3255      void baz();                            void baz();
3256      }                                      }
3258 .. _ForEachMacros:
3260 **ForEachMacros** (``List of Strings``) :versionbadge:`clang-format 3.7` :ref:`¶ <ForEachMacros>`
3261   A vector of macros that should be interpreted as foreach loops
3262   instead of as function calls.
3264   These are expected to be macros of the form:
3266   .. code-block:: c++
3268     FOREACH(<variable-declaration>, ...)
3269       <loop-body>
3271   In the .clang-format configuration file, this can be configured like:
3273   .. code-block:: yaml
3275     ForEachMacros: ['RANGES_FOR', 'FOREACH']
3277   For example: BOOST_FOREACH.
3279 .. _IfMacros:
3281 **IfMacros** (``List of Strings``) :versionbadge:`clang-format 13` :ref:`¶ <IfMacros>`
3282   A vector of macros that should be interpreted as conditionals
3283   instead of as function calls.
3285   These are expected to be macros of the form:
3287   .. code-block:: c++
3289     IF(...)
3290       <conditional-body>
3291     else IF(...)
3292       <conditional-body>
3294   In the .clang-format configuration file, this can be configured like:
3296   .. code-block:: yaml
3298     IfMacros: ['IF']
3300   For example: `KJ_IF_MAYBE
3301   <https://github.com/capnproto/capnproto/blob/master/kjdoc/tour.md#maybes>`_
3303 .. _IncludeBlocks:
3305 **IncludeBlocks** (``IncludeBlocksStyle``) :versionbadge:`clang-format 6` :ref:`¶ <IncludeBlocks>`
3306   Dependent on the value, multiple ``#include`` blocks can be sorted
3307   as one and divided based on category.
3309   Possible values:
3311   * ``IBS_Preserve`` (in configuration: ``Preserve``)
3312     Sort each ``#include`` block separately.
3314     .. code-block:: c++
3316        #include "b.h"               into      #include "b.h"
3318        #include <lib/main.h>                  #include "a.h"
3319        #include "a.h"                         #include <lib/main.h>
3321   * ``IBS_Merge`` (in configuration: ``Merge``)
3322     Merge multiple ``#include`` blocks together and sort as one.
3324     .. code-block:: c++
3326        #include "b.h"               into      #include "a.h"
3327                                               #include "b.h"
3328        #include <lib/main.h>                  #include <lib/main.h>
3329        #include "a.h"
3331   * ``IBS_Regroup`` (in configuration: ``Regroup``)
3332     Merge multiple ``#include`` blocks together and sort as one.
3333     Then split into groups based on category priority. See
3334     ``IncludeCategories``.
3336     .. code-block:: c++
3338        #include "b.h"               into      #include "a.h"
3339                                               #include "b.h"
3340        #include <lib/main.h>
3341        #include "a.h"                         #include <lib/main.h>
3345 .. _IncludeCategories:
3347 **IncludeCategories** (``List of IncludeCategories``) :versionbadge:`clang-format 3.8` :ref:`¶ <IncludeCategories>`
3348   Regular expressions denoting the different ``#include`` categories
3349   used for ordering ``#includes``.
3351   `POSIX extended
3352   <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html>`_
3353   regular expressions are supported.
3355   These regular expressions are matched against the filename of an include
3356   (including the <> or "") in order. The value belonging to the first
3357   matching regular expression is assigned and ``#includes`` are sorted first
3358   according to increasing category number and then alphabetically within
3359   each category.
3361   If none of the regular expressions match, INT_MAX is assigned as
3362   category. The main header for a source file automatically gets category 0.
3363   so that it is generally kept at the beginning of the ``#includes``
3364   (https://llvm.org/docs/CodingStandards.html#include-style). However, you
3365   can also assign negative priorities if you have certain headers that
3366   always need to be first.
3368   There is a third and optional field ``SortPriority`` which can used while
3369   ``IncludeBlocks = IBS_Regroup`` to define the priority in which
3370   ``#includes`` should be ordered. The value of ``Priority`` defines the
3371   order of ``#include blocks`` and also allows the grouping of ``#includes``
3372   of different priority. ``SortPriority`` is set to the value of
3373   ``Priority`` as default if it is not assigned.
3375   Each regular expression can be marked as case sensitive with the field
3376   ``CaseSensitive``, per default it is not.
3378   To configure this in the .clang-format file, use:
3380   .. code-block:: yaml
3382     IncludeCategories:
3383       - Regex:           '^"(llvm|llvm-c|clang|clang-c)/'
3384         Priority:        2
3385         SortPriority:    2
3386         CaseSensitive:   true
3387       - Regex:           '^((<|")(gtest|gmock|isl|json)/)'
3388         Priority:        3
3389       - Regex:           '<[[:alnum:].]+>'
3390         Priority:        4
3391       - Regex:           '.*'
3392         Priority:        1
3393         SortPriority:    0
3395 .. _IncludeIsMainRegex:
3397 **IncludeIsMainRegex** (``String``) :versionbadge:`clang-format 3.9` :ref:`¶ <IncludeIsMainRegex>`
3398   Specify a regular expression of suffixes that are allowed in the
3399   file-to-main-include mapping.
3401   When guessing whether a #include is the "main" include (to assign
3402   category 0, see above), use this regex of allowed suffixes to the header
3403   stem. A partial match is done, so that:
3404   - "" means "arbitrary suffix"
3405   - "$" means "no suffix"
3407   For example, if configured to "(_test)?$", then a header a.h would be seen
3408   as the "main" include in both a.cc and a_test.cc.
3410 .. _IncludeIsMainSourceRegex:
3412 **IncludeIsMainSourceRegex** (``String``) :versionbadge:`clang-format 10` :ref:`¶ <IncludeIsMainSourceRegex>`
3413   Specify a regular expression for files being formatted
3414   that are allowed to be considered "main" in the
3415   file-to-main-include mapping.
3417   By default, clang-format considers files as "main" only when they end
3418   with: ``.c``, ``.cc``, ``.cpp``, ``.c++``, ``.cxx``, ``.m`` or ``.mm``
3419   extensions.
3420   For these files a guessing of "main" include takes place
3421   (to assign category 0, see above). This config option allows for
3422   additional suffixes and extensions for files to be considered as "main".
3424   For example, if this option is configured to ``(Impl\.hpp)$``,
3425   then a file ``ClassImpl.hpp`` is considered "main" (in addition to
3426   ``Class.c``, ``Class.cc``, ``Class.cpp`` and so on) and "main
3427   include file" logic will be executed (with *IncludeIsMainRegex* setting
3428   also being respected in later phase). Without this option set,
3429   ``ClassImpl.hpp`` would not have the main include file put on top
3430   before any other include.
3432 .. _IndentAccessModifiers:
3434 **IndentAccessModifiers** (``Boolean``) :versionbadge:`clang-format 13` :ref:`¶ <IndentAccessModifiers>`
3435   Specify whether access modifiers should have their own indentation level.
3437   When ``false``, access modifiers are indented (or outdented) relative to
3438   the record members, respecting the ``AccessModifierOffset``. Record
3439   members are indented one level below the record.
3440   When ``true``, access modifiers get their own indentation level. As a
3441   consequence, record members are always indented 2 levels below the record,
3442   regardless of the access modifier presence. Value of the
3443   ``AccessModifierOffset`` is ignored.
3445   .. code-block:: c++
3447      false:                                 true:
3448      class C {                      vs.     class C {
3449        class D {                                class D {
3450          void bar();                                void bar();
3451        protected:                                 protected:
3452          D();                                       D();
3453        };                                       };
3454      public:                                  public:
3455        C();                                     C();
3456      };                                     };
3457      void foo() {                           void foo() {
3458        return 1;                              return 1;
3459      }                                      }
3461 .. _IndentCaseBlocks:
3463 **IndentCaseBlocks** (``Boolean``) :versionbadge:`clang-format 11` :ref:`¶ <IndentCaseBlocks>`
3464   Indent case label blocks one level from the case label.
3466   When ``false``, the block following the case label uses the same
3467   indentation level as for the case label, treating the case label the same
3468   as an if-statement.
3469   When ``true``, the block gets indented as a scope block.
3471   .. code-block:: c++
3473      false:                                 true:
3474      switch (fool) {                vs.     switch (fool) {
3475      case 1: {                              case 1:
3476        bar();                                 {
3477      } break;                                   bar();
3478      default: {                               }
3479        plop();                                break;
3480      }                                      default:
3481      }                                        {
3482                                                 plop();
3483                                               }
3484                                             }
3486 .. _IndentCaseLabels:
3488 **IndentCaseLabels** (``Boolean``) :versionbadge:`clang-format 3.3` :ref:`¶ <IndentCaseLabels>`
3489   Indent case labels one level from the switch statement.
3491   When ``false``, use the same indentation level as for the switch
3492   statement. Switch statement body is always indented one level more than
3493   case labels (except the first block following the case label, which
3494   itself indents the code - unless IndentCaseBlocks is enabled).
3496   .. code-block:: c++
3498      false:                                 true:
3499      switch (fool) {                vs.     switch (fool) {
3500      case 1:                                  case 1:
3501        bar();                                   bar();
3502        break;                                   break;
3503      default:                                 default:
3504        plop();                                  plop();
3505      }                                      }
3507 .. _IndentExternBlock:
3509 **IndentExternBlock** (``IndentExternBlockStyle``) :versionbadge:`clang-format 11` :ref:`¶ <IndentExternBlock>`
3510   IndentExternBlockStyle is the type of indenting of extern blocks.
3512   Possible values:
3514   * ``IEBS_AfterExternBlock`` (in configuration: ``AfterExternBlock``)
3515     Backwards compatible with AfterExternBlock's indenting.
3517     .. code-block:: c++
3519        IndentExternBlock: AfterExternBlock
3520        BraceWrapping.AfterExternBlock: true
3521        extern "C"
3522        {
3523            void foo();
3524        }
3527     .. code-block:: c++
3529        IndentExternBlock: AfterExternBlock
3530        BraceWrapping.AfterExternBlock: false
3531        extern "C" {
3532        void foo();
3533        }
3535   * ``IEBS_NoIndent`` (in configuration: ``NoIndent``)
3536     Does not indent extern blocks.
3538     .. code-block:: c++
3540         extern "C" {
3541         void foo();
3542         }
3544   * ``IEBS_Indent`` (in configuration: ``Indent``)
3545     Indents extern blocks.
3547     .. code-block:: c++
3549         extern "C" {
3550           void foo();
3551         }
3555 .. _IndentGotoLabels:
3557 **IndentGotoLabels** (``Boolean``) :versionbadge:`clang-format 10` :ref:`¶ <IndentGotoLabels>`
3558   Indent goto labels.
3560   When ``false``, goto labels are flushed left.
3562   .. code-block:: c++
3564      true:                                  false:
3565      int f() {                      vs.     int f() {
3566        if (foo()) {                           if (foo()) {
3567        label1:                              label1:
3568          bar();                                 bar();
3569        }                                      }
3570      label2:                                label2:
3571        return 1;                              return 1;
3572      }                                      }
3574 .. _IndentPPDirectives:
3576 **IndentPPDirectives** (``PPDirectiveIndentStyle``) :versionbadge:`clang-format 6` :ref:`¶ <IndentPPDirectives>`
3577   The preprocessor directive indenting style to use.
3579   Possible values:
3581   * ``PPDIS_None`` (in configuration: ``None``)
3582     Does not indent any directives.
3584     .. code-block:: c++
3586        #if FOO
3587        #if BAR
3588        #include <foo>
3589        #endif
3590        #endif
3592   * ``PPDIS_AfterHash`` (in configuration: ``AfterHash``)
3593     Indents directives after the hash.
3595     .. code-block:: c++
3597        #if FOO
3598        #  if BAR
3599        #    include <foo>
3600        #  endif
3601        #endif
3603   * ``PPDIS_BeforeHash`` (in configuration: ``BeforeHash``)
3604     Indents directives before the hash.
3606     .. code-block:: c++
3608        #if FOO
3609          #if BAR
3610            #include <foo>
3611          #endif
3612        #endif
3616 .. _IndentRequiresClause:
3618 **IndentRequiresClause** (``Boolean``) :versionbadge:`clang-format 15` :ref:`¶ <IndentRequiresClause>`
3619   Indent the requires clause in a template. This only applies when
3620   ``RequiresClausePosition`` is ``OwnLine``, or ``WithFollowing``.
3622   In clang-format 12, 13 and 14 it was named ``IndentRequires``.
3624   .. code-block:: c++
3626      true:
3627      template <typename It>
3628        requires Iterator<It>
3629      void sort(It begin, It end) {
3630        //....
3631      }
3633      false:
3634      template <typename It>
3635      requires Iterator<It>
3636      void sort(It begin, It end) {
3637        //....
3638      }
3640 .. _IndentWidth:
3642 **IndentWidth** (``Unsigned``) :versionbadge:`clang-format 3.7` :ref:`¶ <IndentWidth>`
3643   The number of columns to use for indentation.
3645   .. code-block:: c++
3647      IndentWidth: 3
3649      void f() {
3650         someFunction();
3651         if (true, false) {
3652            f();
3653         }
3654      }
3656 .. _IndentWrappedFunctionNames:
3658 **IndentWrappedFunctionNames** (``Boolean``) :versionbadge:`clang-format 3.7` :ref:`¶ <IndentWrappedFunctionNames>`
3659   Indent if a function definition or declaration is wrapped after the
3660   type.
3662   .. code-block:: c++
3664      true:
3665      LoooooooooooooooooooooooooooooooooooooooongReturnType
3666          LoooooooooooooooooooooooooooooooongFunctionDeclaration();
3668      false:
3669      LoooooooooooooooooooooooooooooooooooooooongReturnType
3670      LoooooooooooooooooooooooooooooooongFunctionDeclaration();
3672 .. _InsertBraces:
3674 **InsertBraces** (``Boolean``) :versionbadge:`clang-format 15` :ref:`¶ <InsertBraces>`
3675   Insert braces after control statements (``if``, ``else``, ``for``, ``do``,
3676   and ``while``) in C++ unless the control statements are inside macro
3677   definitions or the braces would enclose preprocessor directives.
3679   .. warning::
3681    Setting this option to ``true`` could lead to incorrect code formatting
3682    due to clang-format's lack of complete semantic information. As such,
3683    extra care should be taken to review code changes made by this option.
3685   .. code-block:: c++
3687     false:                                    true:
3689     if (isa<FunctionDecl>(D))        vs.      if (isa<FunctionDecl>(D)) {
3690       handleFunctionDecl(D);                    handleFunctionDecl(D);
3691     else if (isa<VarDecl>(D))                 } else if (isa<VarDecl>(D)) {
3692       handleVarDecl(D);                         handleVarDecl(D);
3693     else                                      } else {
3694       return;                                   return;
3695                                               }
3697     while (i--)                      vs.      while (i--) {
3698       for (auto *A : D.attrs())                 for (auto *A : D.attrs()) {
3699         handleAttr(A);                            handleAttr(A);
3700                                                 }
3701                                               }
3703     do                               vs.      do {
3704       --i;                                      --i;
3705     while (i);                                } while (i);
3707 .. _InsertNewlineAtEOF:
3709 **InsertNewlineAtEOF** (``Boolean``) :versionbadge:`clang-format 16` :ref:`¶ <InsertNewlineAtEOF>`
3710   Insert a newline at end of file if missing.
3712 .. _InsertTrailingCommas:
3714 **InsertTrailingCommas** (``TrailingCommaStyle``) :versionbadge:`clang-format 11` :ref:`¶ <InsertTrailingCommas>`
3715   If set to ``TCS_Wrapped`` will insert trailing commas in container
3716   literals (arrays and objects) that wrap across multiple lines.
3717   It is currently only available for JavaScript
3718   and disabled by default ``TCS_None``.
3719   ``InsertTrailingCommas`` cannot be used together with ``BinPackArguments``
3720   as inserting the comma disables bin-packing.
3722   .. code-block:: c++
3724     TSC_Wrapped:
3725     const someArray = [
3726     aaaaaaaaaaaaaaaaaaaaaaaaaa,
3727     aaaaaaaaaaaaaaaaaaaaaaaaaa,
3728     aaaaaaaaaaaaaaaaaaaaaaaaaa,
3729     //                        ^ inserted
3730     ]
3732   Possible values:
3734   * ``TCS_None`` (in configuration: ``None``)
3735     Do not insert trailing commas.
3737   * ``TCS_Wrapped`` (in configuration: ``Wrapped``)
3738     Insert trailing commas in container literals that were wrapped over
3739     multiple lines. Note that this is conceptually incompatible with
3740     bin-packing, because the trailing comma is used as an indicator
3741     that a container should be formatted one-per-line (i.e. not bin-packed).
3742     So inserting a trailing comma counteracts bin-packing.
3746 .. _IntegerLiteralSeparator:
3748 **IntegerLiteralSeparator** (``IntegerLiteralSeparatorStyle``) :versionbadge:`clang-format 16` :ref:`¶ <IntegerLiteralSeparator>`
3749   Format integer literal separators (``'`` for C++ and ``_`` for C#, Java,
3750   and JavaScript).
3752   Nested configuration flags:
3754   Separator format of integer literals of different bases.
3756   If negative, remove separators. If  ``0``, leave the literal as is. If
3757   positive, insert separators between digits starting from the rightmost
3758   digit.
3760   For example, the config below will leave separators in binary literals
3761   alone, insert separators in decimal literals to separate the digits into
3762   groups of 3, and remove separators in hexadecimal literals.
3764   .. code-block:: c++
3766     IntegerLiteralSeparator:
3767       Binary: 0
3768       Decimal: 3
3769       Hex: -1
3771   You can also specify a minimum number of digits (``BinaryMinDigits``,
3772   ``DecimalMinDigits``, and ``HexMinDigits``) the integer literal must
3773   have in order for the separators to be inserted.
3775   * ``int8_t Binary`` Format separators in binary literals.
3777     .. code-block:: text
3779       /* -1: */ b = 0b100111101101;
3780       /*  0: */ b = 0b10011'11'0110'1;
3781       /*  3: */ b = 0b100'111'101'101;
3782       /*  4: */ b = 0b1001'1110'1101;
3784   * ``int8_t BinaryMinDigits`` Format separators in binary literals with a minimum number of digits.
3786     .. code-block:: text
3788       // Binary: 3
3789       // BinaryMinDigits: 7
3790       b1 = 0b101101;
3791       b2 = 0b1'101'101;
3793   * ``int8_t Decimal`` Format separators in decimal literals.
3795     .. code-block:: text
3797       /* -1: */ d = 18446744073709550592ull;
3798       /*  0: */ d = 184467'440737'0'95505'92ull;
3799       /*  3: */ d = 18'446'744'073'709'550'592ull;
3801   * ``int8_t DecimalMinDigits`` Format separators in decimal literals with a minimum number of digits.
3803     .. code-block:: text
3805       // Decimal: 3
3806       // DecimalMinDigits: 5
3807       d1 = 2023;
3808       d2 = 10'000;
3810   * ``int8_t Hex`` Format separators in hexadecimal literals.
3812     .. code-block:: text
3814       /* -1: */ h = 0xDEADBEEFDEADBEEFuz;
3815       /*  0: */ h = 0xDEAD'BEEF'DE'AD'BEE'Fuz;
3816       /*  2: */ h = 0xDE'AD'BE'EF'DE'AD'BE'EFuz;
3818   * ``int8_t HexMinDigits`` Format separators in hexadecimal literals with a minimum number of
3819     digits.
3821     .. code-block:: text
3823       // Hex: 2
3824       // HexMinDigits: 6
3825       h1 = 0xABCDE;
3826       h2 = 0xAB'CD'EF;
3829 .. _JavaImportGroups:
3831 **JavaImportGroups** (``List of Strings``) :versionbadge:`clang-format 8` :ref:`¶ <JavaImportGroups>`
3832   A vector of prefixes ordered by the desired groups for Java imports.
3834   One group's prefix can be a subset of another - the longest prefix is
3835   always matched. Within a group, the imports are ordered lexicographically.
3836   Static imports are grouped separately and follow the same group rules.
3837   By default, static imports are placed before non-static imports,
3838   but this behavior is changed by another option,
3839   ``SortJavaStaticImport``.
3841   In the .clang-format configuration file, this can be configured like
3842   in the following yaml example. This will result in imports being
3843   formatted as in the Java example below.
3845   .. code-block:: yaml
3847     JavaImportGroups: ['com.example', 'com', 'org']
3850   .. code-block:: java
3852      import static com.example.function1;
3854      import static com.test.function2;
3856      import static org.example.function3;
3858      import com.example.ClassA;
3859      import com.example.Test;
3860      import com.example.a.ClassB;
3862      import com.test.ClassC;
3864      import org.example.ClassD;
3866 .. _JavaScriptQuotes:
3868 **JavaScriptQuotes** (``JavaScriptQuoteStyle``) :versionbadge:`clang-format 3.9` :ref:`¶ <JavaScriptQuotes>`
3869   The JavaScriptQuoteStyle to use for JavaScript strings.
3871   Possible values:
3873   * ``JSQS_Leave`` (in configuration: ``Leave``)
3874     Leave string quotes as they are.
3876     .. code-block:: js
3878        string1 = "foo";
3879        string2 = 'bar';
3881   * ``JSQS_Single`` (in configuration: ``Single``)
3882     Always use single quotes.
3884     .. code-block:: js
3886        string1 = 'foo';
3887        string2 = 'bar';
3889   * ``JSQS_Double`` (in configuration: ``Double``)
3890     Always use double quotes.
3892     .. code-block:: js
3894        string1 = "foo";
3895        string2 = "bar";
3899 .. _JavaScriptWrapImports:
3901 **JavaScriptWrapImports** (``Boolean``) :versionbadge:`clang-format 3.9` :ref:`¶ <JavaScriptWrapImports>`
3902   Whether to wrap JavaScript import/export statements.
3904   .. code-block:: js
3906      true:
3907      import {
3908          VeryLongImportsAreAnnoying,
3909          VeryLongImportsAreAnnoying,
3910          VeryLongImportsAreAnnoying,
3911      } from 'some/module.js'
3913      false:
3914      import {VeryLongImportsAreAnnoying, VeryLongImportsAreAnnoying, VeryLongImportsAreAnnoying,} from "some/module.js"
3916 .. _KeepEmptyLinesAtEOF:
3918 **KeepEmptyLinesAtEOF** (``Boolean``) :versionbadge:`clang-format 17` :ref:`¶ <KeepEmptyLinesAtEOF>`
3919   Keep empty lines (up to ``MaxEmptyLinesToKeep``) at end of file.
3921 .. _KeepEmptyLinesAtTheStartOfBlocks:
3923 **KeepEmptyLinesAtTheStartOfBlocks** (``Boolean``) :versionbadge:`clang-format 3.7` :ref:`¶ <KeepEmptyLinesAtTheStartOfBlocks>`
3924   If true, the empty line at the start of blocks is kept.
3926   .. code-block:: c++
3928      true:                                  false:
3929      if (foo) {                     vs.     if (foo) {
3930                                               bar();
3931        bar();                               }
3932      }
3934 .. _LambdaBodyIndentation:
3936 **LambdaBodyIndentation** (``LambdaBodyIndentationKind``) :versionbadge:`clang-format 13` :ref:`¶ <LambdaBodyIndentation>`
3937   The indentation style of lambda bodies. ``Signature`` (the default)
3938   causes the lambda body to be indented one additional level relative to
3939   the indentation level of the signature. ``OuterScope`` forces the lambda
3940   body to be indented one additional level relative to the parent scope
3941   containing the lambda signature.
3943   Possible values:
3945   * ``LBI_Signature`` (in configuration: ``Signature``)
3946     Align lambda body relative to the lambda signature. This is the default.
3948     .. code-block:: c++
3950        someMethod(
3951            [](SomeReallyLongLambdaSignatureArgument foo) {
3952              return;
3953            });
3955   * ``LBI_OuterScope`` (in configuration: ``OuterScope``)
3956     For statements within block scope, align lambda body relative to the
3957     indentation level of the outer scope the lambda signature resides in.
3959     .. code-block:: c++
3961        someMethod(
3962            [](SomeReallyLongLambdaSignatureArgument foo) {
3963          return;
3964        });
3966        someMethod(someOtherMethod(
3967            [](SomeReallyLongLambdaSignatureArgument foo) {
3968          return;
3969        }));
3973 .. _Language:
3975 **Language** (``LanguageKind``) :versionbadge:`clang-format 3.5` :ref:`¶ <Language>`
3976   Language, this format style is targeted at.
3978   Possible values:
3980   * ``LK_None`` (in configuration: ``None``)
3981     Do not use.
3983   * ``LK_Cpp`` (in configuration: ``Cpp``)
3984     Should be used for C, C++.
3986   * ``LK_CSharp`` (in configuration: ``CSharp``)
3987     Should be used for C#.
3989   * ``LK_Java`` (in configuration: ``Java``)
3990     Should be used for Java.
3992   * ``LK_JavaScript`` (in configuration: ``JavaScript``)
3993     Should be used for JavaScript.
3995   * ``LK_Json`` (in configuration: ``Json``)
3996     Should be used for JSON.
3998   * ``LK_ObjC`` (in configuration: ``ObjC``)
3999     Should be used for Objective-C, Objective-C++.
4001   * ``LK_Proto`` (in configuration: ``Proto``)
4002     Should be used for Protocol Buffers
4003     (https://developers.google.com/protocol-buffers/).
4005   * ``LK_TableGen`` (in configuration: ``TableGen``)
4006     Should be used for TableGen code.
4008   * ``LK_TextProto`` (in configuration: ``TextProto``)
4009     Should be used for Protocol Buffer messages in text format
4010     (https://developers.google.com/protocol-buffers/).
4012   * ``LK_Verilog`` (in configuration: ``Verilog``)
4013     Should be used for Verilog and SystemVerilog.
4014     https://standards.ieee.org/ieee/1800/6700/
4015     https://sci-hub.st/10.1109/IEEESTD.2018.8299595
4019 .. _LineEnding:
4021 **LineEnding** (``LineEndingStyle``) :versionbadge:`clang-format 16` :ref:`¶ <LineEnding>`
4022   Line ending style (``\n`` or ``\r\n``) to use.
4024   Possible values:
4026   * ``LE_LF`` (in configuration: ``LF``)
4027     Use ``\n``.
4029   * ``LE_CRLF`` (in configuration: ``CRLF``)
4030     Use ``\r\n``.
4032   * ``LE_DeriveLF`` (in configuration: ``DeriveLF``)
4033     Use ``\n`` unless the input has more lines ending in ``\r\n``.
4035   * ``LE_DeriveCRLF`` (in configuration: ``DeriveCRLF``)
4036     Use ``\r\n`` unless the input has more lines ending in ``\n``.
4040 .. _MacroBlockBegin:
4042 **MacroBlockBegin** (``String``) :versionbadge:`clang-format 3.7` :ref:`¶ <MacroBlockBegin>`
4043   A regular expression matching macros that start a block.
4045   .. code-block:: c++
4047      # With:
4048      MacroBlockBegin: "^NS_MAP_BEGIN|\
4049      NS_TABLE_HEAD$"
4050      MacroBlockEnd: "^\
4051      NS_MAP_END|\
4052      NS_TABLE_.*_END$"
4054      NS_MAP_BEGIN
4055        foo();
4056      NS_MAP_END
4058      NS_TABLE_HEAD
4059        bar();
4060      NS_TABLE_FOO_END
4062      # Without:
4063      NS_MAP_BEGIN
4064      foo();
4065      NS_MAP_END
4067      NS_TABLE_HEAD
4068      bar();
4069      NS_TABLE_FOO_END
4071 .. _MacroBlockEnd:
4073 **MacroBlockEnd** (``String``) :versionbadge:`clang-format 3.7` :ref:`¶ <MacroBlockEnd>`
4074   A regular expression matching macros that end a block.
4076 .. _Macros:
4078 **Macros** (``List of Strings``) :versionbadge:`clang-format 17` :ref:`¶ <Macros>`
4079   A list of macros of the form ``<definition>=<expansion>`` .
4081   Code will be parsed with macros expanded, in order to determine how to
4082   interpret and format the macro arguments.
4084   For example, the code:
4086   .. code-block:: c++
4088     A(a*b);
4090   will usually be interpreted as a call to a function A, and the
4091   multiplication expression will be formatted as ``a * b``.
4093   If we specify the macro definition:
4095   .. code-block:: yaml
4097     Macros:
4098     - A(x)=x
4100   the code will now be parsed as a declaration of the variable b of type a*,
4101   and formatted as ``a* b`` (depending on pointer-binding rules).
4103   Features and restrictions:
4104    * Both function-like macros and object-like macros are supported.
4105    * Macro arguments must be used exactly once in the expansion.
4106    * No recursive expansion; macros referencing other macros will be
4107      ignored.
4108    * Overloading by arity is supported: for example, given the macro
4109      definitions A=x, A()=y, A(a)=a
4112   .. code-block:: c++
4114      A; -> x;
4115      A(); -> y;
4116      A(z); -> z;
4117      A(a, b); // will not be expanded.
4119 .. _MaxEmptyLinesToKeep:
4121 **MaxEmptyLinesToKeep** (``Unsigned``) :versionbadge:`clang-format 3.7` :ref:`¶ <MaxEmptyLinesToKeep>`
4122   The maximum number of consecutive empty lines to keep.
4124   .. code-block:: c++
4126      MaxEmptyLinesToKeep: 1         vs.     MaxEmptyLinesToKeep: 0
4127      int f() {                              int f() {
4128        int = 1;                                 int i = 1;
4129                                                 i = foo();
4130        i = foo();                               return i;
4131                                             }
4132        return i;
4133      }
4135 .. _NamespaceIndentation:
4137 **NamespaceIndentation** (``NamespaceIndentationKind``) :versionbadge:`clang-format 3.7` :ref:`¶ <NamespaceIndentation>`
4138   The indentation used for namespaces.
4140   Possible values:
4142   * ``NI_None`` (in configuration: ``None``)
4143     Don't indent in namespaces.
4145     .. code-block:: c++
4147        namespace out {
4148        int i;
4149        namespace in {
4150        int i;
4151        }
4152        }
4154   * ``NI_Inner`` (in configuration: ``Inner``)
4155     Indent only in inner namespaces (nested in other namespaces).
4157     .. code-block:: c++
4159        namespace out {
4160        int i;
4161        namespace in {
4162          int i;
4163        }
4164        }
4166   * ``NI_All`` (in configuration: ``All``)
4167     Indent in all namespaces.
4169     .. code-block:: c++
4171        namespace out {
4172          int i;
4173          namespace in {
4174            int i;
4175          }
4176        }
4180 .. _NamespaceMacros:
4182 **NamespaceMacros** (``List of Strings``) :versionbadge:`clang-format 9` :ref:`¶ <NamespaceMacros>`
4183   A vector of macros which are used to open namespace blocks.
4185   These are expected to be macros of the form:
4187   .. code-block:: c++
4189     NAMESPACE(<namespace-name>, ...) {
4190       <namespace-content>
4191     }
4193   For example: TESTSUITE
4195 .. _ObjCBinPackProtocolList:
4197 **ObjCBinPackProtocolList** (``BinPackStyle``) :versionbadge:`clang-format 7` :ref:`¶ <ObjCBinPackProtocolList>`
4198   Controls bin-packing Objective-C protocol conformance list
4199   items into as few lines as possible when they go over ``ColumnLimit``.
4201   If ``Auto`` (the default), delegates to the value in
4202   ``BinPackParameters``. If that is ``true``, bin-packs Objective-C
4203   protocol conformance list items into as few lines as possible
4204   whenever they go over ``ColumnLimit``.
4206   If ``Always``, always bin-packs Objective-C protocol conformance
4207   list items into as few lines as possible whenever they go over
4208   ``ColumnLimit``.
4210   If ``Never``, lays out Objective-C protocol conformance list items
4211   onto individual lines whenever they go over ``ColumnLimit``.
4214   .. code-block:: objc
4216      Always (or Auto, if BinPackParameters=true):
4217      @interface ccccccccccccc () <
4218          ccccccccccccc, ccccccccccccc,
4219          ccccccccccccc, ccccccccccccc> {
4220      }
4222      Never (or Auto, if BinPackParameters=false):
4223      @interface ddddddddddddd () <
4224          ddddddddddddd,
4225          ddddddddddddd,
4226          ddddddddddddd,
4227          ddddddddddddd> {
4228      }
4230   Possible values:
4232   * ``BPS_Auto`` (in configuration: ``Auto``)
4233     Automatically determine parameter bin-packing behavior.
4235   * ``BPS_Always`` (in configuration: ``Always``)
4236     Always bin-pack parameters.
4238   * ``BPS_Never`` (in configuration: ``Never``)
4239     Never bin-pack parameters.
4243 .. _ObjCBlockIndentWidth:
4245 **ObjCBlockIndentWidth** (``Unsigned``) :versionbadge:`clang-format 3.7` :ref:`¶ <ObjCBlockIndentWidth>`
4246   The number of characters to use for indentation of ObjC blocks.
4248   .. code-block:: objc
4250      ObjCBlockIndentWidth: 4
4252      [operation setCompletionBlock:^{
4253          [self onOperationDone];
4254      }];
4256 .. _ObjCBreakBeforeNestedBlockParam:
4258 **ObjCBreakBeforeNestedBlockParam** (``Boolean``) :versionbadge:`clang-format 11` :ref:`¶ <ObjCBreakBeforeNestedBlockParam>`
4259   Break parameters list into lines when there is nested block
4260   parameters in a function call.
4262   .. code-block:: c++
4264     false:
4265      - (void)_aMethod
4266      {
4267          [self.test1 t:self w:self callback:^(typeof(self) self, NSNumber
4268          *u, NSNumber *v) {
4269              u = c;
4270          }]
4271      }
4272      true:
4273      - (void)_aMethod
4274      {
4275         [self.test1 t:self
4276                      w:self
4277             callback:^(typeof(self) self, NSNumber *u, NSNumber *v) {
4278                  u = c;
4279              }]
4280      }
4282 .. _ObjCPropertyAttributeOrder:
4284 **ObjCPropertyAttributeOrder** (``List of Strings``) :versionbadge:`clang-format 18` :ref:`¶ <ObjCPropertyAttributeOrder>`
4285   The order in which ObjC property attributes should appear.
4287   Attributes in code will be sorted in the order specified. Any attributes
4288   encountered that are not mentioned in this array will be sorted last, in
4289   stable order. Comments between attributes will leave the attributes
4290   untouched.
4292   .. warning::
4294    Using this option could lead to incorrect code formatting due to
4295    clang-format's lack of complete semantic information. As such, extra
4296    care should be taken to review code changes made by this option.
4298   .. code-block:: yaml
4300     ObjCPropertyAttributeOrder: [
4301         class, direct,
4302         atomic, nonatomic,
4303         assign, retain, strong, copy, weak, unsafe_unretained,
4304         readonly, readwrite, getter, setter,
4305         nullable, nonnull, null_resettable, null_unspecified
4306     ]
4308 .. _ObjCSpaceAfterProperty:
4310 **ObjCSpaceAfterProperty** (``Boolean``) :versionbadge:`clang-format 3.7` :ref:`¶ <ObjCSpaceAfterProperty>`
4311   Add a space after ``@property`` in Objective-C, i.e. use
4312   ``@property (readonly)`` instead of ``@property(readonly)``.
4314 .. _ObjCSpaceBeforeProtocolList:
4316 **ObjCSpaceBeforeProtocolList** (``Boolean``) :versionbadge:`clang-format 3.7` :ref:`¶ <ObjCSpaceBeforeProtocolList>`
4317   Add a space in front of an Objective-C protocol list, i.e. use
4318   ``Foo <Protocol>`` instead of ``Foo<Protocol>``.
4320 .. _PPIndentWidth:
4322 **PPIndentWidth** (``Integer``) :versionbadge:`clang-format 13` :ref:`¶ <PPIndentWidth>`
4323   The number of columns to use for indentation of preprocessor statements.
4324   When set to -1 (default) ``IndentWidth`` is used also for preprocessor
4325   statements.
4327   .. code-block:: c++
4329      PPIndentWidth: 1
4331      #ifdef __linux__
4332      # define FOO
4333      #else
4334      # define BAR
4335      #endif
4337 .. _PackConstructorInitializers:
4339 **PackConstructorInitializers** (``PackConstructorInitializersStyle``) :versionbadge:`clang-format 14` :ref:`¶ <PackConstructorInitializers>`
4340   The pack constructor initializers style to use.
4342   Possible values:
4344   * ``PCIS_Never`` (in configuration: ``Never``)
4345     Always put each constructor initializer on its own line.
4347     .. code-block:: c++
4349        Constructor()
4350            : a(),
4351              b()
4353   * ``PCIS_BinPack`` (in configuration: ``BinPack``)
4354     Bin-pack constructor initializers.
4356     .. code-block:: c++
4358        Constructor()
4359            : aaaaaaaaaaaaaaaaaaaa(), bbbbbbbbbbbbbbbbbbbb(),
4360              cccccccccccccccccccc()
4362   * ``PCIS_CurrentLine`` (in configuration: ``CurrentLine``)
4363     Put all constructor initializers on the current line if they fit.
4364     Otherwise, put each one on its own line.
4366     .. code-block:: c++
4368        Constructor() : a(), b()
4370        Constructor()
4371            : aaaaaaaaaaaaaaaaaaaa(),
4372              bbbbbbbbbbbbbbbbbbbb(),
4373              ddddddddddddd()
4375   * ``PCIS_NextLine`` (in configuration: ``NextLine``)
4376     Same as ``PCIS_CurrentLine`` except that if all constructor initializers
4377     do not fit on the current line, try to fit them on the next line.
4379     .. code-block:: c++
4381        Constructor() : a(), b()
4383        Constructor()
4384            : aaaaaaaaaaaaaaaaaaaa(), bbbbbbbbbbbbbbbbbbbb(), ddddddddddddd()
4386        Constructor()
4387            : aaaaaaaaaaaaaaaaaaaa(),
4388              bbbbbbbbbbbbbbbbbbbb(),
4389              cccccccccccccccccccc()
4391   * ``PCIS_NextLineOnly`` (in configuration: ``NextLineOnly``)
4392     Put all constructor initializers on the next line if they fit.
4393     Otherwise, put each one on its own line.
4395     .. code-block:: c++
4397        Constructor()
4398            : a(), b()
4400        Constructor()
4401            : aaaaaaaaaaaaaaaaaaaa(), bbbbbbbbbbbbbbbbbbbb(), ddddddddddddd()
4403        Constructor()
4404            : aaaaaaaaaaaaaaaaaaaa(),
4405              bbbbbbbbbbbbbbbbbbbb(),
4406              cccccccccccccccccccc()
4410 .. _PenaltyBreakAssignment:
4412 **PenaltyBreakAssignment** (``Unsigned``) :versionbadge:`clang-format 5` :ref:`¶ <PenaltyBreakAssignment>`
4413   The penalty for breaking around an assignment operator.
4415 .. _PenaltyBreakBeforeFirstCallParameter:
4417 **PenaltyBreakBeforeFirstCallParameter** (``Unsigned``) :versionbadge:`clang-format 3.7` :ref:`¶ <PenaltyBreakBeforeFirstCallParameter>`
4418   The penalty for breaking a function call after ``call(``.
4420 .. _PenaltyBreakComment:
4422 **PenaltyBreakComment** (``Unsigned``) :versionbadge:`clang-format 3.7` :ref:`¶ <PenaltyBreakComment>`
4423   The penalty for each line break introduced inside a comment.
4425 .. _PenaltyBreakFirstLessLess:
4427 **PenaltyBreakFirstLessLess** (``Unsigned``) :versionbadge:`clang-format 3.7` :ref:`¶ <PenaltyBreakFirstLessLess>`
4428   The penalty for breaking before the first ``<<``.
4430 .. _PenaltyBreakOpenParenthesis:
4432 **PenaltyBreakOpenParenthesis** (``Unsigned``) :versionbadge:`clang-format 14` :ref:`¶ <PenaltyBreakOpenParenthesis>`
4433   The penalty for breaking after ``(``.
4435 .. _PenaltyBreakScopeResolution:
4437 **PenaltyBreakScopeResolution** (``Unsigned``) :versionbadge:`clang-format 18` :ref:`¶ <PenaltyBreakScopeResolution>`
4438   The penalty for breaking after ``::``.
4440 .. _PenaltyBreakString:
4442 **PenaltyBreakString** (``Unsigned``) :versionbadge:`clang-format 3.7` :ref:`¶ <PenaltyBreakString>`
4443   The penalty for each line break introduced inside a string literal.
4445 .. _PenaltyBreakTemplateDeclaration:
4447 **PenaltyBreakTemplateDeclaration** (``Unsigned``) :versionbadge:`clang-format 7` :ref:`¶ <PenaltyBreakTemplateDeclaration>`
4448   The penalty for breaking after template declaration.
4450 .. _PenaltyExcessCharacter:
4452 **PenaltyExcessCharacter** (``Unsigned``) :versionbadge:`clang-format 3.7` :ref:`¶ <PenaltyExcessCharacter>`
4453   The penalty for each character outside of the column limit.
4455 .. _PenaltyIndentedWhitespace:
4457 **PenaltyIndentedWhitespace** (``Unsigned``) :versionbadge:`clang-format 12` :ref:`¶ <PenaltyIndentedWhitespace>`
4458   Penalty for each character of whitespace indentation
4459   (counted relative to leading non-whitespace column).
4461 .. _PenaltyReturnTypeOnItsOwnLine:
4463 **PenaltyReturnTypeOnItsOwnLine** (``Unsigned``) :versionbadge:`clang-format 3.7` :ref:`¶ <PenaltyReturnTypeOnItsOwnLine>`
4464   Penalty for putting the return type of a function onto its own line.
4466 .. _PointerAlignment:
4468 **PointerAlignment** (``PointerAlignmentStyle``) :versionbadge:`clang-format 3.7` :ref:`¶ <PointerAlignment>`
4469   Pointer and reference alignment style.
4471   Possible values:
4473   * ``PAS_Left`` (in configuration: ``Left``)
4474     Align pointer to the left.
4476     .. code-block:: c++
4478       int* a;
4480   * ``PAS_Right`` (in configuration: ``Right``)
4481     Align pointer to the right.
4483     .. code-block:: c++
4485       int *a;
4487   * ``PAS_Middle`` (in configuration: ``Middle``)
4488     Align pointer in the middle.
4490     .. code-block:: c++
4492       int * a;
4496 .. _QualifierAlignment:
4498 **QualifierAlignment** (``QualifierAlignmentStyle``) :versionbadge:`clang-format 14` :ref:`¶ <QualifierAlignment>`
4499   Different ways to arrange specifiers and qualifiers (e.g. const/volatile).
4501   .. warning::
4503    Setting ``QualifierAlignment``  to something other than ``Leave``, COULD
4504    lead to incorrect code formatting due to incorrect decisions made due to
4505    clang-formats lack of complete semantic information.
4506    As such extra care should be taken to review code changes made by the use
4507    of this option.
4509   Possible values:
4511   * ``QAS_Leave`` (in configuration: ``Leave``)
4512     Don't change specifiers/qualifiers to either Left or Right alignment
4513     (default).
4515     .. code-block:: c++
4517        int const a;
4518        const int *a;
4520   * ``QAS_Left`` (in configuration: ``Left``)
4521     Change specifiers/qualifiers to be left-aligned.
4523     .. code-block:: c++
4525        const int a;
4526        const int *a;
4528   * ``QAS_Right`` (in configuration: ``Right``)
4529     Change specifiers/qualifiers to be right-aligned.
4531     .. code-block:: c++
4533        int const a;
4534        int const *a;
4536   * ``QAS_Custom`` (in configuration: ``Custom``)
4537     Change specifiers/qualifiers to be aligned based on ``QualifierOrder``.
4538     With:
4540     .. code-block:: yaml
4542       QualifierOrder: ['inline', 'static', 'type', 'const']
4545     .. code-block:: c++
4548        int const a;
4549        int const *a;
4553 .. _QualifierOrder:
4555 **QualifierOrder** (``List of Strings``) :versionbadge:`clang-format 14` :ref:`¶ <QualifierOrder>`
4556   The order in which the qualifiers appear.
4557   Order is an array that can contain any of the following:
4559     * const
4560     * inline
4561     * static
4562     * friend
4563     * constexpr
4564     * volatile
4565     * restrict
4566     * type
4569   .. note::
4571    it MUST contain 'type'.
4573   Items to the left of 'type' will be placed to the left of the type and
4574   aligned in the order supplied. Items to the right of 'type' will be
4575   placed to the right of the type and aligned in the order supplied.
4578   .. code-block:: yaml
4580     QualifierOrder: ['inline', 'static', 'type', 'const', 'volatile' ]
4582 .. _RawStringFormats:
4584 **RawStringFormats** (``List of RawStringFormats``) :versionbadge:`clang-format 6` :ref:`¶ <RawStringFormats>`
4585   Defines hints for detecting supported languages code blocks in raw
4586   strings.
4588   A raw string with a matching delimiter or a matching enclosing function
4589   name will be reformatted assuming the specified language based on the
4590   style for that language defined in the .clang-format file. If no style has
4591   been defined in the .clang-format file for the specific language, a
4592   predefined style given by 'BasedOnStyle' is used. If 'BasedOnStyle' is not
4593   found, the formatting is based on llvm style. A matching delimiter takes
4594   precedence over a matching enclosing function name for determining the
4595   language of the raw string contents.
4597   If a canonical delimiter is specified, occurrences of other delimiters for
4598   the same language will be updated to the canonical if possible.
4600   There should be at most one specification per language and each delimiter
4601   and enclosing function should not occur in multiple specifications.
4603   To configure this in the .clang-format file, use:
4605   .. code-block:: yaml
4607     RawStringFormats:
4608       - Language: TextProto
4609           Delimiters:
4610             - 'pb'
4611             - 'proto'
4612           EnclosingFunctions:
4613             - 'PARSE_TEXT_PROTO'
4614           BasedOnStyle: google
4615       - Language: Cpp
4616           Delimiters:
4617             - 'cc'
4618             - 'cpp'
4619           BasedOnStyle: llvm
4620           CanonicalDelimiter: 'cc'
4622 .. _ReferenceAlignment:
4624 **ReferenceAlignment** (``ReferenceAlignmentStyle``) :versionbadge:`clang-format 13` :ref:`¶ <ReferenceAlignment>`
4625   Reference alignment style (overrides ``PointerAlignment`` for
4626   references).
4628   Possible values:
4630   * ``RAS_Pointer`` (in configuration: ``Pointer``)
4631     Align reference like ``PointerAlignment``.
4633   * ``RAS_Left`` (in configuration: ``Left``)
4634     Align reference to the left.
4636     .. code-block:: c++
4638       int& a;
4640   * ``RAS_Right`` (in configuration: ``Right``)
4641     Align reference to the right.
4643     .. code-block:: c++
4645       int &a;
4647   * ``RAS_Middle`` (in configuration: ``Middle``)
4648     Align reference in the middle.
4650     .. code-block:: c++
4652       int & a;
4656 .. _ReflowComments:
4658 **ReflowComments** (``Boolean``) :versionbadge:`clang-format 3.8` :ref:`¶ <ReflowComments>`
4659   If ``true``, clang-format will attempt to re-flow comments. That is it
4660   will touch a comment and *reflow* long comments into new lines, trying to
4661   obey the ``ColumnLimit``.
4663   .. code-block:: c++
4665      false:
4666      // veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of information
4667      /* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of information */
4669      true:
4670      // veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of
4671      // information
4672      /* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of
4673       * information */
4675 .. _RemoveBracesLLVM:
4677 **RemoveBracesLLVM** (``Boolean``) :versionbadge:`clang-format 14` :ref:`¶ <RemoveBracesLLVM>`
4678   Remove optional braces of control statements (``if``, ``else``, ``for``,
4679   and ``while``) in C++ according to the LLVM coding style.
4681   .. warning::
4683    This option will be renamed and expanded to support other styles.
4685   .. warning::
4687    Setting this option to ``true`` could lead to incorrect code formatting
4688    due to clang-format's lack of complete semantic information. As such,
4689    extra care should be taken to review code changes made by this option.
4691   .. code-block:: c++
4693     false:                                     true:
4695     if (isa<FunctionDecl>(D)) {        vs.     if (isa<FunctionDecl>(D))
4696       handleFunctionDecl(D);                     handleFunctionDecl(D);
4697     } else if (isa<VarDecl>(D)) {              else if (isa<VarDecl>(D))
4698       handleVarDecl(D);                          handleVarDecl(D);
4699     }
4701     if (isa<VarDecl>(D)) {             vs.     if (isa<VarDecl>(D)) {
4702       for (auto *A : D.attrs()) {                for (auto *A : D.attrs())
4703         if (shouldProcessAttr(A)) {                if (shouldProcessAttr(A))
4704           handleAttr(A);                             handleAttr(A);
4705         }                                      }
4706       }
4707     }
4709     if (isa<FunctionDecl>(D)) {        vs.     if (isa<FunctionDecl>(D))
4710       for (auto *A : D.attrs()) {                for (auto *A : D.attrs())
4711         handleAttr(A);                             handleAttr(A);
4712       }
4713     }
4715     if (auto *D = (T)(D)) {            vs.     if (auto *D = (T)(D)) {
4716       if (shouldProcess(D)) {                    if (shouldProcess(D))
4717         handleVarDecl(D);                          handleVarDecl(D);
4718       } else {                                   else
4719         markAsIgnored(D);                          markAsIgnored(D);
4720       }                                        }
4721     }
4723     if (a) {                           vs.     if (a)
4724       b();                                       b();
4725     } else {                                   else if (c)
4726       if (c) {                                   d();
4727         d();                                   else
4728       } else {                                   e();
4729         e();
4730       }
4731     }
4733 .. _RemoveParentheses:
4735 **RemoveParentheses** (``RemoveParenthesesStyle``) :versionbadge:`clang-format 17` :ref:`¶ <RemoveParentheses>`
4736   Remove redundant parentheses.
4738   .. warning::
4740    Setting this option to any value other than ``Leave`` could lead to
4741    incorrect code formatting due to clang-format's lack of complete semantic
4742    information. As such, extra care should be taken to review code changes
4743    made by this option.
4745   Possible values:
4747   * ``RPS_Leave`` (in configuration: ``Leave``)
4748     Do not remove parentheses.
4750     .. code-block:: c++
4752       class __declspec((dllimport)) X {};
4753       co_return (((0)));
4754       return ((a + b) - ((c + d)));
4756   * ``RPS_MultipleParentheses`` (in configuration: ``MultipleParentheses``)
4757     Replace multiple parentheses with single parentheses.
4759     .. code-block:: c++
4761       class __declspec(dllimport) X {};
4762       co_return (0);
4763       return ((a + b) - (c + d));
4765   * ``RPS_ReturnStatement`` (in configuration: ``ReturnStatement``)
4766     Also remove parentheses enclosing the expression in a
4767     ``return``/``co_return`` statement.
4769     .. code-block:: c++
4771       class __declspec(dllimport) X {};
4772       co_return 0;
4773       return (a + b) - (c + d);
4777 .. _RemoveSemicolon:
4779 **RemoveSemicolon** (``Boolean``) :versionbadge:`clang-format 16` :ref:`¶ <RemoveSemicolon>`
4780   Remove semicolons after the closing brace of a non-empty function.
4782   .. warning::
4784    Setting this option to ``true`` could lead to incorrect code formatting
4785    due to clang-format's lack of complete semantic information. As such,
4786    extra care should be taken to review code changes made by this option.
4788   .. code-block:: c++
4790     false:                                     true:
4792     int max(int a, int b) {                    int max(int a, int b) {
4793       return a > b ? a : b;                      return a > b ? a : b;
4794     };                                         }
4796 .. _RequiresClausePosition:
4798 **RequiresClausePosition** (``RequiresClausePositionStyle``) :versionbadge:`clang-format 15` :ref:`¶ <RequiresClausePosition>`
4799   The position of the ``requires`` clause.
4801   Possible values:
4803   * ``RCPS_OwnLine`` (in configuration: ``OwnLine``)
4804     Always put the ``requires`` clause on its own line.
4806     .. code-block:: c++
4808       template <typename T>
4809       requires C<T>
4810       struct Foo {...
4812       template <typename T>
4813       requires C<T>
4814       void bar(T t) {...
4816       template <typename T>
4817       void baz(T t)
4818       requires C<T>
4819       {...
4821   * ``RCPS_WithPreceding`` (in configuration: ``WithPreceding``)
4822     Try to put the clause together with the preceding part of a declaration.
4823     For class templates: stick to the template declaration.
4824     For function templates: stick to the template declaration.
4825     For function declaration followed by a requires clause: stick to the
4826     parameter list.
4828     .. code-block:: c++
4830       template <typename T> requires C<T>
4831       struct Foo {...
4833       template <typename T> requires C<T>
4834       void bar(T t) {...
4836       template <typename T>
4837       void baz(T t) requires C<T>
4838       {...
4840   * ``RCPS_WithFollowing`` (in configuration: ``WithFollowing``)
4841     Try to put the ``requires`` clause together with the class or function
4842     declaration.
4844     .. code-block:: c++
4846       template <typename T>
4847       requires C<T> struct Foo {...
4849       template <typename T>
4850       requires C<T> void bar(T t) {...
4852       template <typename T>
4853       void baz(T t)
4854       requires C<T> {...
4856   * ``RCPS_SingleLine`` (in configuration: ``SingleLine``)
4857     Try to put everything in the same line if possible. Otherwise normal
4858     line breaking rules take over.
4860     .. code-block:: c++
4862       // Fitting:
4863       template <typename T> requires C<T> struct Foo {...
4865       template <typename T> requires C<T> void bar(T t) {...
4867       template <typename T> void bar(T t) requires C<T> {...
4869       // Not fitting, one possible example:
4870       template <typename LongName>
4871       requires C<LongName>
4872       struct Foo {...
4874       template <typename LongName>
4875       requires C<LongName>
4876       void bar(LongName ln) {
4878       template <typename LongName>
4879       void bar(LongName ln)
4880           requires C<LongName> {
4884 .. _RequiresExpressionIndentation:
4886 **RequiresExpressionIndentation** (``RequiresExpressionIndentationKind``) :versionbadge:`clang-format 16` :ref:`¶ <RequiresExpressionIndentation>`
4887   The indentation used for requires expression bodies.
4889   Possible values:
4891   * ``REI_OuterScope`` (in configuration: ``OuterScope``)
4892     Align requires expression body relative to the indentation level of the
4893     outer scope the requires expression resides in.
4894     This is the default.
4896     .. code-block:: c++
4898        template <typename T>
4899        concept C = requires(T t) {
4900          ...
4901        }
4903   * ``REI_Keyword`` (in configuration: ``Keyword``)
4904     Align requires expression body relative to the ``requires`` keyword.
4906     .. code-block:: c++
4908        template <typename T>
4909        concept C = requires(T t) {
4910                      ...
4911                    }
4915 .. _SeparateDefinitionBlocks:
4917 **SeparateDefinitionBlocks** (``SeparateDefinitionStyle``) :versionbadge:`clang-format 14` :ref:`¶ <SeparateDefinitionBlocks>`
4918   Specifies the use of empty lines to separate definition blocks, including
4919   classes, structs, enums, and functions.
4921   .. code-block:: c++
4923      Never                  v.s.     Always
4924      #include <cstring>              #include <cstring>
4925      struct Foo {
4926        int a, b, c;                  struct Foo {
4927      };                                int a, b, c;
4928      namespace Ns {                  };
4929      class Bar {
4930      public:                         namespace Ns {
4931        struct Foobar {               class Bar {
4932          int a;                      public:
4933          int b;                        struct Foobar {
4934        };                                int a;
4935      private:                            int b;
4936        int t;                          };
4937        int method1() {
4938          // ...                      private:
4939        }                               int t;
4940        enum List {
4941          ITEM1,                        int method1() {
4942          ITEM2                           // ...
4943        };                              }
4944        template<typename T>
4945        int method2(T x) {              enum List {
4946          // ...                          ITEM1,
4947        }                                 ITEM2
4948        int i, j, k;                    };
4949        int method3(int par) {
4950          // ...                        template<typename T>
4951        }                               int method2(T x) {
4952      };                                  // ...
4953      class C {};                       }
4954      }
4955                                        int i, j, k;
4957                                        int method3(int par) {
4958                                          // ...
4959                                        }
4960                                      };
4962                                      class C {};
4963                                      }
4965   Possible values:
4967   * ``SDS_Leave`` (in configuration: ``Leave``)
4968     Leave definition blocks as they are.
4970   * ``SDS_Always`` (in configuration: ``Always``)
4971     Insert an empty line between definition blocks.
4973   * ``SDS_Never`` (in configuration: ``Never``)
4974     Remove any empty line between definition blocks.
4978 .. _ShortNamespaceLines:
4980 **ShortNamespaceLines** (``Unsigned``) :versionbadge:`clang-format 13` :ref:`¶ <ShortNamespaceLines>`
4981   The maximal number of unwrapped lines that a short namespace spans.
4982   Defaults to 1.
4984   This determines the maximum length of short namespaces by counting
4985   unwrapped lines (i.e. containing neither opening nor closing
4986   namespace brace) and makes "FixNamespaceComments" omit adding
4987   end comments for those.
4989   .. code-block:: c++
4991      ShortNamespaceLines: 1     vs.     ShortNamespaceLines: 0
4992      namespace a {                      namespace a {
4993        int foo;                           int foo;
4994      }                                  } // namespace a
4996      ShortNamespaceLines: 1     vs.     ShortNamespaceLines: 0
4997      namespace b {                      namespace b {
4998        int foo;                           int foo;
4999        int bar;                           int bar;
5000      } // namespace b                   } // namespace b
5002 .. _SortIncludes:
5004 **SortIncludes** (``SortIncludesOptions``) :versionbadge:`clang-format 3.8` :ref:`¶ <SortIncludes>`
5005   Controls if and how clang-format will sort ``#includes``.
5007   Possible values:
5009   * ``SI_Never`` (in configuration: ``Never``)
5010     Includes are never sorted.
5012     .. code-block:: c++
5014        #include "B/A.h"
5015        #include "A/B.h"
5016        #include "a/b.h"
5017        #include "A/b.h"
5018        #include "B/a.h"
5020   * ``SI_CaseSensitive`` (in configuration: ``CaseSensitive``)
5021     Includes are sorted in an ASCIIbetical or case sensitive fashion.
5023     .. code-block:: c++
5025        #include "A/B.h"
5026        #include "A/b.h"
5027        #include "B/A.h"
5028        #include "B/a.h"
5029        #include "a/b.h"
5031   * ``SI_CaseInsensitive`` (in configuration: ``CaseInsensitive``)
5032     Includes are sorted in an alphabetical or case insensitive fashion.
5034     .. code-block:: c++
5036        #include "A/B.h"
5037        #include "A/b.h"
5038        #include "a/b.h"
5039        #include "B/A.h"
5040        #include "B/a.h"
5044 .. _SortJavaStaticImport:
5046 **SortJavaStaticImport** (``SortJavaStaticImportOptions``) :versionbadge:`clang-format 12` :ref:`¶ <SortJavaStaticImport>`
5047   When sorting Java imports, by default static imports are placed before
5048   non-static imports. If ``JavaStaticImportAfterImport`` is ``After``,
5049   static imports are placed after non-static imports.
5051   Possible values:
5053   * ``SJSIO_Before`` (in configuration: ``Before``)
5054     Static imports are placed before non-static imports.
5056     .. code-block:: java
5058       import static org.example.function1;
5060       import org.example.ClassA;
5062   * ``SJSIO_After`` (in configuration: ``After``)
5063     Static imports are placed after non-static imports.
5065     .. code-block:: java
5067       import org.example.ClassA;
5069       import static org.example.function1;
5073 .. _SortUsingDeclarations:
5075 **SortUsingDeclarations** (``SortUsingDeclarationsOptions``) :versionbadge:`clang-format 5` :ref:`¶ <SortUsingDeclarations>`
5076   Controls if and how clang-format will sort using declarations.
5078   Possible values:
5080   * ``SUD_Never`` (in configuration: ``Never``)
5081     Using declarations are never sorted.
5083     .. code-block:: c++
5085        using std::chrono::duration_cast;
5086        using std::move;
5087        using boost::regex;
5088        using boost::regex_constants::icase;
5089        using std::string;
5091   * ``SUD_Lexicographic`` (in configuration: ``Lexicographic``)
5092     Using declarations are sorted in the order defined as follows:
5093     Split the strings by "::" and discard any initial empty strings. Sort
5094     the lists of names lexicographically, and within those groups, names are
5095     in case-insensitive lexicographic order.
5097     .. code-block:: c++
5099        using boost::regex;
5100        using boost::regex_constants::icase;
5101        using std::chrono::duration_cast;
5102        using std::move;
5103        using std::string;
5105   * ``SUD_LexicographicNumeric`` (in configuration: ``LexicographicNumeric``)
5106     Using declarations are sorted in the order defined as follows:
5107     Split the strings by "::" and discard any initial empty strings. The
5108     last element of each list is a non-namespace name; all others are
5109     namespace names. Sort the lists of names lexicographically, where the
5110     sort order of individual names is that all non-namespace names come
5111     before all namespace names, and within those groups, names are in
5112     case-insensitive lexicographic order.
5114     .. code-block:: c++
5116        using boost::regex;
5117        using boost::regex_constants::icase;
5118        using std::move;
5119        using std::string;
5120        using std::chrono::duration_cast;
5124 .. _SpaceAfterCStyleCast:
5126 **SpaceAfterCStyleCast** (``Boolean``) :versionbadge:`clang-format 3.5` :ref:`¶ <SpaceAfterCStyleCast>`
5127   If ``true``, a space is inserted after C style casts.
5129   .. code-block:: c++
5131      true:                                  false:
5132      (int) i;                       vs.     (int)i;
5134 .. _SpaceAfterLogicalNot:
5136 **SpaceAfterLogicalNot** (``Boolean``) :versionbadge:`clang-format 9` :ref:`¶ <SpaceAfterLogicalNot>`
5137   If ``true``, a space is inserted after the logical not operator (``!``).
5139   .. code-block:: c++
5141      true:                                  false:
5142      ! someExpression();            vs.     !someExpression();
5144 .. _SpaceAfterTemplateKeyword:
5146 **SpaceAfterTemplateKeyword** (``Boolean``) :versionbadge:`clang-format 4` :ref:`¶ <SpaceAfterTemplateKeyword>`
5147   If ``true``, a space will be inserted after the 'template' keyword.
5149   .. code-block:: c++
5151      true:                                  false:
5152      template <int> void foo();     vs.     template<int> void foo();
5154 .. _SpaceAroundPointerQualifiers:
5156 **SpaceAroundPointerQualifiers** (``SpaceAroundPointerQualifiersStyle``) :versionbadge:`clang-format 12` :ref:`¶ <SpaceAroundPointerQualifiers>`
5157   Defines in which cases to put a space before or after pointer qualifiers
5159   Possible values:
5161   * ``SAPQ_Default`` (in configuration: ``Default``)
5162     Don't ensure spaces around pointer qualifiers and use PointerAlignment
5163     instead.
5165     .. code-block:: c++
5167        PointerAlignment: Left                 PointerAlignment: Right
5168        void* const* x = NULL;         vs.     void *const *x = NULL;
5170   * ``SAPQ_Before`` (in configuration: ``Before``)
5171     Ensure that there is a space before pointer qualifiers.
5173     .. code-block:: c++
5175        PointerAlignment: Left                 PointerAlignment: Right
5176        void* const* x = NULL;         vs.     void * const *x = NULL;
5178   * ``SAPQ_After`` (in configuration: ``After``)
5179     Ensure that there is a space after pointer qualifiers.
5181     .. code-block:: c++
5183        PointerAlignment: Left                 PointerAlignment: Right
5184        void* const * x = NULL;         vs.     void *const *x = NULL;
5186   * ``SAPQ_Both`` (in configuration: ``Both``)
5187     Ensure that there is a space both before and after pointer qualifiers.
5189     .. code-block:: c++
5191        PointerAlignment: Left                 PointerAlignment: Right
5192        void* const * x = NULL;         vs.     void * const *x = NULL;
5196 .. _SpaceBeforeAssignmentOperators:
5198 **SpaceBeforeAssignmentOperators** (``Boolean``) :versionbadge:`clang-format 3.7` :ref:`¶ <SpaceBeforeAssignmentOperators>`
5199   If ``false``, spaces will be removed before assignment operators.
5201   .. code-block:: c++
5203      true:                                  false:
5204      int a = 5;                     vs.     int a= 5;
5205      a += 42;                               a+= 42;
5207 .. _SpaceBeforeCaseColon:
5209 **SpaceBeforeCaseColon** (``Boolean``) :versionbadge:`clang-format 12` :ref:`¶ <SpaceBeforeCaseColon>`
5210   If ``false``, spaces will be removed before case colon.
5212   .. code-block:: c++
5214     true:                                   false
5215     switch (x) {                    vs.     switch (x) {
5216       case 1 : break;                         case 1: break;
5217     }                                       }
5219 .. _SpaceBeforeCpp11BracedList:
5221 **SpaceBeforeCpp11BracedList** (``Boolean``) :versionbadge:`clang-format 7` :ref:`¶ <SpaceBeforeCpp11BracedList>`
5222   If ``true``, a space will be inserted before a C++11 braced list
5223   used to initialize an object (after the preceding identifier or type).
5225   .. code-block:: c++
5227      true:                                  false:
5228      Foo foo { bar };               vs.     Foo foo{ bar };
5229      Foo {};                                Foo{};
5230      vector<int> { 1, 2, 3 };               vector<int>{ 1, 2, 3 };
5231      new int[3] { 1, 2, 3 };                new int[3]{ 1, 2, 3 };
5233 .. _SpaceBeforeCtorInitializerColon:
5235 **SpaceBeforeCtorInitializerColon** (``Boolean``) :versionbadge:`clang-format 7` :ref:`¶ <SpaceBeforeCtorInitializerColon>`
5236   If ``false``, spaces will be removed before constructor initializer
5237   colon.
5239   .. code-block:: c++
5241      true:                                  false:
5242      Foo::Foo() : a(a) {}                   Foo::Foo(): a(a) {}
5244 .. _SpaceBeforeInheritanceColon:
5246 **SpaceBeforeInheritanceColon** (``Boolean``) :versionbadge:`clang-format 7` :ref:`¶ <SpaceBeforeInheritanceColon>`
5247   If ``false``, spaces will be removed before inheritance colon.
5249   .. code-block:: c++
5251      true:                                  false:
5252      class Foo : Bar {}             vs.     class Foo: Bar {}
5254 .. _SpaceBeforeJsonColon:
5256 **SpaceBeforeJsonColon** (``Boolean``) :versionbadge:`clang-format 17` :ref:`¶ <SpaceBeforeJsonColon>`
5257   If ``true``, a space will be added before a JSON colon. For other
5258   languages, e.g. JavaScript, use ``SpacesInContainerLiterals`` instead.
5260   .. code-block:: c++
5262      true:                                  false:
5263      {                                      {
5264        "key" : "value"              vs.       "key": "value"
5265      }                                      }
5267 .. _SpaceBeforeParens:
5269 **SpaceBeforeParens** (``SpaceBeforeParensStyle``) :versionbadge:`clang-format 3.5` :ref:`¶ <SpaceBeforeParens>`
5270   Defines in which cases to put a space before opening parentheses.
5272   Possible values:
5274   * ``SBPO_Never`` (in configuration: ``Never``)
5275     Never put a space before opening parentheses.
5277     .. code-block:: c++
5279        void f() {
5280          if(true) {
5281            f();
5282          }
5283        }
5285   * ``SBPO_ControlStatements`` (in configuration: ``ControlStatements``)
5286     Put a space before opening parentheses only after control statement
5287     keywords (``for/if/while...``).
5289     .. code-block:: c++
5291        void f() {
5292          if (true) {
5293            f();
5294          }
5295        }
5297   * ``SBPO_ControlStatementsExceptControlMacros`` (in configuration: ``ControlStatementsExceptControlMacros``)
5298     Same as ``SBPO_ControlStatements`` except this option doesn't apply to
5299     ForEach and If macros. This is useful in projects where ForEach/If
5300     macros are treated as function calls instead of control statements.
5301     ``SBPO_ControlStatementsExceptForEachMacros`` remains an alias for
5302     backward compatibility.
5304     .. code-block:: c++
5306        void f() {
5307          Q_FOREACH(...) {
5308            f();
5309          }
5310        }
5312   * ``SBPO_NonEmptyParentheses`` (in configuration: ``NonEmptyParentheses``)
5313     Put a space before opening parentheses only if the parentheses are not
5314     empty i.e. '()'
5316     .. code-block:: c++
5318       void() {
5319         if (true) {
5320           f();
5321           g (x, y, z);
5322         }
5323       }
5325   * ``SBPO_Always`` (in configuration: ``Always``)
5326     Always put a space before opening parentheses, except when it's
5327     prohibited by the syntax rules (in function-like macro definitions) or
5328     when determined by other style rules (after unary operators, opening
5329     parentheses, etc.)
5331     .. code-block:: c++
5333        void f () {
5334          if (true) {
5335            f ();
5336          }
5337        }
5339   * ``SBPO_Custom`` (in configuration: ``Custom``)
5340     Configure each individual space before parentheses in
5341     ``SpaceBeforeParensOptions``.
5345 .. _SpaceBeforeParensOptions:
5347 **SpaceBeforeParensOptions** (``SpaceBeforeParensCustom``) :versionbadge:`clang-format 14` :ref:`¶ <SpaceBeforeParensOptions>`
5348   Control of individual space before parentheses.
5350   If ``SpaceBeforeParens`` is set to ``Custom``, use this to specify
5351   how each individual space before parentheses case should be handled.
5352   Otherwise, this is ignored.
5354   .. code-block:: yaml
5356     # Example of usage:
5357     SpaceBeforeParens: Custom
5358     SpaceBeforeParensOptions:
5359       AfterControlStatements: true
5360       AfterFunctionDefinitionName: true
5362   Nested configuration flags:
5364   Precise control over the spacing before parentheses.
5366   .. code-block:: c++
5368     # Should be declared this way:
5369     SpaceBeforeParens: Custom
5370     SpaceBeforeParensOptions:
5371       AfterControlStatements: true
5372       AfterFunctionDefinitionName: true
5374   * ``bool AfterControlStatements`` If ``true``, put space between control statement keywords
5375     (for/if/while...) and opening parentheses.
5377     .. code-block:: c++
5379        true:                                  false:
5380        if (...) {}                     vs.    if(...) {}
5382   * ``bool AfterForeachMacros`` If ``true``, put space between foreach macros and opening parentheses.
5384     .. code-block:: c++
5386        true:                                  false:
5387        FOREACH (...)                   vs.    FOREACH(...)
5388          <loop-body>                            <loop-body>
5390   * ``bool AfterFunctionDeclarationName`` If ``true``, put a space between function declaration name and opening
5391     parentheses.
5393     .. code-block:: c++
5395        true:                                  false:
5396        void f ();                      vs.    void f();
5398   * ``bool AfterFunctionDefinitionName`` If ``true``, put a space between function definition name and opening
5399     parentheses.
5401     .. code-block:: c++
5403        true:                                  false:
5404        void f () {}                    vs.    void f() {}
5406   * ``bool AfterIfMacros`` If ``true``, put space between if macros and opening parentheses.
5408     .. code-block:: c++
5410        true:                                  false:
5411        IF (...)                        vs.    IF(...)
5412          <conditional-body>                     <conditional-body>
5414   * ``bool AfterOverloadedOperator`` If ``true``, put a space between operator overloading and opening
5415     parentheses.
5417     .. code-block:: c++
5419        true:                                  false:
5420        void operator++ (int a);        vs.    void operator++(int a);
5421        object.operator++ (10);                object.operator++(10);
5423   * ``AfterPlacementOperatorStyle AfterPlacementOperator`` :versionbadge:`clang-format 18`
5425     Defines in which cases to put a space between ``new/delete`` operators
5426     and opening parentheses.
5428     Possible values:
5430     * ``APO_Never`` (in configuration: ``Never``)
5431       Remove space after ``new/delete`` operators and before ``(``.
5433       .. code-block:: c++
5435          new(buf) T;
5436          delete(buf) T;
5438     * ``APO_Always`` (in configuration: ``Always``)
5439       Always add space after ``new/delete`` operators and before ``(``.
5441       .. code-block:: c++
5443          new (buf) T;
5444          delete (buf) T;
5446     * ``APO_Leave`` (in configuration: ``Leave``)
5447       Leave placement ``new/delete`` expressions as they are.
5450   * ``bool AfterRequiresInClause`` If ``true``, put space between requires keyword in a requires clause and
5451     opening parentheses, if there is one.
5453     .. code-block:: c++
5455        true:                                  false:
5456        template<typename T>            vs.    template<typename T>
5457        requires (A<T> && B<T>)                requires(A<T> && B<T>)
5458        ...                                    ...
5460   * ``bool AfterRequiresInExpression`` If ``true``, put space between requires keyword in a requires expression
5461     and opening parentheses.
5463     .. code-block:: c++
5465        true:                                  false:
5466        template<typename T>            vs.    template<typename T>
5467        concept C = requires (T t) {           concept C = requires(T t) {
5468                      ...                                    ...
5469                    }                                      }
5471   * ``bool BeforeNonEmptyParentheses`` If ``true``, put a space before opening parentheses only if the
5472     parentheses are not empty.
5474     .. code-block:: c++
5476        true:                                  false:
5477        void f (int a);                 vs.    void f();
5478        f (a);                                 f();
5481 .. _SpaceBeforeRangeBasedForLoopColon:
5483 **SpaceBeforeRangeBasedForLoopColon** (``Boolean``) :versionbadge:`clang-format 7` :ref:`¶ <SpaceBeforeRangeBasedForLoopColon>`
5484   If ``false``, spaces will be removed before range-based for loop
5485   colon.
5487   .. code-block:: c++
5489      true:                                  false:
5490      for (auto v : values) {}       vs.     for(auto v: values) {}
5492 .. _SpaceBeforeSquareBrackets:
5494 **SpaceBeforeSquareBrackets** (``Boolean``) :versionbadge:`clang-format 10` :ref:`¶ <SpaceBeforeSquareBrackets>`
5495   If ``true``, spaces will be before  ``[``.
5496   Lambdas will not be affected. Only the first ``[`` will get a space added.
5498   .. code-block:: c++
5500      true:                                  false:
5501      int a [5];                    vs.      int a[5];
5502      int a [5][5];                 vs.      int a[5][5];
5504 .. _SpaceInEmptyBlock:
5506 **SpaceInEmptyBlock** (``Boolean``) :versionbadge:`clang-format 10` :ref:`¶ <SpaceInEmptyBlock>`
5507   If ``true``, spaces will be inserted into ``{}``.
5509   .. code-block:: c++
5511      true:                                false:
5512      void f() { }                   vs.   void f() {}
5513      while (true) { }                     while (true) {}
5515 .. _SpaceInEmptyParentheses:
5517 **SpaceInEmptyParentheses** (``Boolean``) :versionbadge:`clang-format 3.7` :ref:`¶ <SpaceInEmptyParentheses>`
5518   If ``true``, spaces may be inserted into ``()``.
5519   This option is **deprecated**. See ``InEmptyParentheses`` of
5520   ``SpacesInParensOptions``.
5522 .. _SpacesBeforeTrailingComments:
5524 **SpacesBeforeTrailingComments** (``Unsigned``) :versionbadge:`clang-format 3.7` :ref:`¶ <SpacesBeforeTrailingComments>`
5525   The number of spaces before trailing line comments
5526   (``//`` - comments).
5528   This does not affect trailing block comments (``/*`` - comments) as those
5529   commonly have different usage patterns and a number of special cases.  In
5530   the case of Verilog, it doesn't affect a comment right after the opening
5531   parenthesis in the port or parameter list in a module header, because it
5532   is probably for the port on the following line instead of the parenthesis
5533   it follows.
5535   .. code-block:: c++
5537      SpacesBeforeTrailingComments: 3
5538      void f() {
5539        if (true) {   // foo1
5540          f();        // bar
5541        }             // foo
5542      }
5544 .. _SpacesInAngles:
5546 **SpacesInAngles** (``SpacesInAnglesStyle``) :versionbadge:`clang-format 3.4` :ref:`¶ <SpacesInAngles>`
5547   The SpacesInAnglesStyle to use for template argument lists.
5549   Possible values:
5551   * ``SIAS_Never`` (in configuration: ``Never``)
5552     Remove spaces after ``<`` and before ``>``.
5554     .. code-block:: c++
5556        static_cast<int>(arg);
5557        std::function<void(int)> fct;
5559   * ``SIAS_Always`` (in configuration: ``Always``)
5560     Add spaces after ``<`` and before ``>``.
5562     .. code-block:: c++
5564        static_cast< int >(arg);
5565        std::function< void(int) > fct;
5567   * ``SIAS_Leave`` (in configuration: ``Leave``)
5568     Keep a single space after ``<`` and before ``>`` if any spaces were
5569     present. Option ``Standard: Cpp03`` takes precedence.
5573 .. _SpacesInCStyleCastParentheses:
5575 **SpacesInCStyleCastParentheses** (``Boolean``) :versionbadge:`clang-format 3.7` :ref:`¶ <SpacesInCStyleCastParentheses>`
5576   If ``true``, spaces may be inserted into C style casts.
5577   This option is **deprecated**. See ``InCStyleCasts`` of
5578   ``SpacesInParensOptions``.
5580 .. _SpacesInConditionalStatement:
5582 **SpacesInConditionalStatement** (``Boolean``) :versionbadge:`clang-format 10` :ref:`¶ <SpacesInConditionalStatement>`
5583   If ``true``, spaces will be inserted around if/for/switch/while
5584   conditions.
5585   This option is **deprecated**. See ``InConditionalStatements`` of
5586   ``SpacesInParensOptions``.
5588 .. _SpacesInContainerLiterals:
5590 **SpacesInContainerLiterals** (``Boolean``) :versionbadge:`clang-format 3.7` :ref:`¶ <SpacesInContainerLiterals>`
5591   If ``true``, spaces are inserted inside container literals (e.g.  ObjC and
5592   Javascript array and dict literals). For JSON, use
5593   ``SpaceBeforeJsonColon`` instead.
5595   .. code-block:: js
5597      true:                                  false:
5598      var arr = [ 1, 2, 3 ];         vs.     var arr = [1, 2, 3];
5599      f({a : 1, b : 2, c : 3});              f({a: 1, b: 2, c: 3});
5601 .. _SpacesInLineCommentPrefix:
5603 **SpacesInLineCommentPrefix** (``SpacesInLineComment``) :versionbadge:`clang-format 13` :ref:`¶ <SpacesInLineCommentPrefix>`
5604   How many spaces are allowed at the start of a line comment. To disable the
5605   maximum set it to ``-1``, apart from that the maximum takes precedence
5606   over the minimum.
5608   .. code-block:: c++
5610     Minimum = 1
5611     Maximum = -1
5612     // One space is forced
5614     //  but more spaces are possible
5616     Minimum = 0
5617     Maximum = 0
5618     //Forces to start every comment directly after the slashes
5620   Note that in line comment sections the relative indent of the subsequent
5621   lines is kept, that means the following:
5623   .. code-block:: c++
5625     before:                                   after:
5626     Minimum: 1
5627     //if (b) {                                // if (b) {
5628     //  return true;                          //   return true;
5629     //}                                       // }
5631     Maximum: 0
5632     /// List:                                 ///List:
5633     ///  - Foo                                /// - Foo
5634     ///    - Bar                              ///   - Bar
5636   This option has only effect if ``ReflowComments`` is set to ``true``.
5638   Nested configuration flags:
5640   Control of spaces within a single line comment.
5642   * ``unsigned Minimum`` The minimum number of spaces at the start of the comment.
5644   * ``unsigned Maximum`` The maximum number of spaces at the start of the comment.
5647 .. _SpacesInParens:
5649 **SpacesInParens** (``SpacesInParensStyle``) :versionbadge:`clang-format 17` :ref:`¶ <SpacesInParens>`
5650   Defines in which cases spaces will be inserted after ``(`` and before
5651   ``)``.
5653   Possible values:
5655   * ``SIPO_Never`` (in configuration: ``Never``)
5656     Never put a space in parentheses.
5658     .. code-block:: c++
5660        void f() {
5661          if(true) {
5662            f();
5663          }
5664        }
5666   * ``SIPO_Custom`` (in configuration: ``Custom``)
5667     Configure each individual space in parentheses in
5668     `SpacesInParensOptions`.
5672 .. _SpacesInParensOptions:
5674 **SpacesInParensOptions** (``SpacesInParensCustom``) :versionbadge:`clang-format 17` :ref:`¶ <SpacesInParensOptions>`
5675   Control of individual spaces in parentheses.
5677   If ``SpacesInParens`` is set to ``Custom``, use this to specify
5678   how each individual space in parentheses case should be handled.
5679   Otherwise, this is ignored.
5681   .. code-block:: yaml
5683     # Example of usage:
5684     SpacesInParens: Custom
5685     SpacesInParensOptions:
5686       InConditionalStatements: true
5687       InEmptyParentheses: true
5689   Nested configuration flags:
5691   Precise control over the spacing in parentheses.
5693   .. code-block:: c++
5695     # Should be declared this way:
5696     SpacesInParens: Custom
5697     SpacesInParensOptions:
5698       InConditionalStatements: true
5699       Other: true
5701   * ``bool InConditionalStatements`` Put a space in parentheses only inside conditional statements
5702     (``for/if/while/switch...``).
5704     .. code-block:: c++
5706        true:                                  false:
5707        if ( a )  { ... }              vs.     if (a) { ... }
5708        while ( i < 5 )  { ... }               while (i < 5) { ... }
5710   * ``bool InCStyleCasts`` Put a space in C style casts.
5712     .. code-block:: c++
5714        true:                                  false:
5715        x = ( int32 )y                 vs.     x = (int32)y
5717   * ``bool InEmptyParentheses`` Put a space in parentheses only if the parentheses are empty i.e. '()'
5719     .. code-block:: c++
5721        true:                                false:
5722        void f( ) {                    vs.   void f() {
5723          int x[] = {foo( ), bar( )};          int x[] = {foo(), bar()};
5724          if (true) {                          if (true) {
5725            f( );                                f();
5726          }                                    }
5727        }                                    }
5729   * ``bool Other`` Put a space in parentheses not covered by preceding options.
5731     .. code-block:: c++
5733        true:                                  false:
5734        t f( Deleted & ) & = delete;   vs.     t f(Deleted &) & = delete;
5737 .. _SpacesInParentheses:
5739 **SpacesInParentheses** (``Boolean``) :versionbadge:`clang-format 3.7` :ref:`¶ <SpacesInParentheses>`
5740   If ``true``, spaces will be inserted after ``(`` and before ``)``.
5741   This option is **deprecated**. The previous behavior is preserved by using
5742   ``SpacesInParens`` with ``Custom`` and by setting all
5743   ``SpacesInParensOptions`` to ``true`` except for ``InCStyleCasts`` and
5744   ``InEmptyParentheses``.
5746 .. _SpacesInSquareBrackets:
5748 **SpacesInSquareBrackets** (``Boolean``) :versionbadge:`clang-format 3.7` :ref:`¶ <SpacesInSquareBrackets>`
5749   If ``true``, spaces will be inserted after ``[`` and before ``]``.
5750   Lambdas without arguments or unspecified size array declarations will not
5751   be affected.
5753   .. code-block:: c++
5755      true:                                  false:
5756      int a[ 5 ];                    vs.     int a[5];
5757      std::unique_ptr<int[]> foo() {} // Won't be affected
5759 .. _Standard:
5761 **Standard** (``LanguageStandard``) :versionbadge:`clang-format 3.7` :ref:`¶ <Standard>`
5762   Parse and format C++ constructs compatible with this standard.
5764   .. code-block:: c++
5766      c++03:                                 latest:
5767      vector<set<int> > x;           vs.     vector<set<int>> x;
5769   Possible values:
5771   * ``LS_Cpp03`` (in configuration: ``c++03``)
5772     Parse and format as C++03.
5773     ``Cpp03`` is a deprecated alias for ``c++03``
5775   * ``LS_Cpp11`` (in configuration: ``c++11``)
5776     Parse and format as C++11.
5778   * ``LS_Cpp14`` (in configuration: ``c++14``)
5779     Parse and format as C++14.
5781   * ``LS_Cpp17`` (in configuration: ``c++17``)
5782     Parse and format as C++17.
5784   * ``LS_Cpp20`` (in configuration: ``c++20``)
5785     Parse and format as C++20.
5787   * ``LS_Latest`` (in configuration: ``Latest``)
5788     Parse and format using the latest supported language version.
5789     ``Cpp11`` is a deprecated alias for ``Latest``
5791   * ``LS_Auto`` (in configuration: ``Auto``)
5792     Automatic detection based on the input.
5796 .. _StatementAttributeLikeMacros:
5798 **StatementAttributeLikeMacros** (``List of Strings``) :versionbadge:`clang-format 12` :ref:`¶ <StatementAttributeLikeMacros>`
5799   Macros which are ignored in front of a statement, as if they were an
5800   attribute. So that they are not parsed as identifier, for example for Qts
5801   emit.
5803   .. code-block:: c++
5805     AlignConsecutiveDeclarations: true
5806     StatementAttributeLikeMacros: []
5807     unsigned char data = 'x';
5808     emit          signal(data); // This is parsed as variable declaration.
5810     AlignConsecutiveDeclarations: true
5811     StatementAttributeLikeMacros: [emit]
5812     unsigned char data = 'x';
5813     emit signal(data); // Now it's fine again.
5815 .. _StatementMacros:
5817 **StatementMacros** (``List of Strings``) :versionbadge:`clang-format 8` :ref:`¶ <StatementMacros>`
5818   A vector of macros that should be interpreted as complete
5819   statements.
5821   Typical macros are expressions, and require a semi-colon to be
5822   added; sometimes this is not the case, and this allows to make
5823   clang-format aware of such cases.
5825   For example: Q_UNUSED
5827 .. _TabWidth:
5829 **TabWidth** (``Unsigned``) :versionbadge:`clang-format 3.7` :ref:`¶ <TabWidth>`
5830   The number of columns used for tab stops.
5832 .. _TypeNames:
5834 **TypeNames** (``List of Strings``) :versionbadge:`clang-format 17` :ref:`¶ <TypeNames>`
5835   A vector of non-keyword identifiers that should be interpreted as type
5836   names.
5838   A ``*``, ``&``, or ``&&`` between a type name and another non-keyword
5839   identifier is annotated as a pointer or reference token instead of a
5840   binary operator.
5842 .. _TypenameMacros:
5844 **TypenameMacros** (``List of Strings``) :versionbadge:`clang-format 9` :ref:`¶ <TypenameMacros>`
5845   A vector of macros that should be interpreted as type declarations
5846   instead of as function calls.
5848   These are expected to be macros of the form:
5850   .. code-block:: c++
5852     STACK_OF(...)
5854   In the .clang-format configuration file, this can be configured like:
5856   .. code-block:: yaml
5858     TypenameMacros: ['STACK_OF', 'LIST']
5860   For example: OpenSSL STACK_OF, BSD LIST_ENTRY.
5862 .. _UseCRLF:
5864 **UseCRLF** (``Boolean``) :versionbadge:`clang-format 10` :ref:`¶ <UseCRLF>`
5865   This option is **deprecated**. See ``LF`` and ``CRLF`` of ``LineEnding``.
5867 .. _UseTab:
5869 **UseTab** (``UseTabStyle``) :versionbadge:`clang-format 3.7` :ref:`¶ <UseTab>`
5870   The way to use tab characters in the resulting file.
5872   Possible values:
5874   * ``UT_Never`` (in configuration: ``Never``)
5875     Never use tab.
5877   * ``UT_ForIndentation`` (in configuration: ``ForIndentation``)
5878     Use tabs only for indentation.
5880   * ``UT_ForContinuationAndIndentation`` (in configuration: ``ForContinuationAndIndentation``)
5881     Fill all leading whitespace with tabs, and use spaces for alignment that
5882     appears within a line (e.g. consecutive assignments and declarations).
5884   * ``UT_AlignWithSpaces`` (in configuration: ``AlignWithSpaces``)
5885     Use tabs for line continuation and indentation, and spaces for
5886     alignment.
5888   * ``UT_Always`` (in configuration: ``Always``)
5889     Use tabs whenever we need to fill whitespace that spans at least from
5890     one tab stop to the next one.
5894 .. _VerilogBreakBetweenInstancePorts:
5896 **VerilogBreakBetweenInstancePorts** (``Boolean``) :versionbadge:`clang-format 17` :ref:`¶ <VerilogBreakBetweenInstancePorts>`
5897   For Verilog, put each port on its own line in module instantiations.
5899   .. code-block:: c++
5901      true:
5902      ffnand ff1(.q(),
5903                 .qbar(out1),
5904                 .clear(in1),
5905                 .preset(in2));
5907      false:
5908      ffnand ff1(.q(), .qbar(out1), .clear(in1), .preset(in2));
5910 .. _WhitespaceSensitiveMacros:
5912 **WhitespaceSensitiveMacros** (``List of Strings``) :versionbadge:`clang-format 11` :ref:`¶ <WhitespaceSensitiveMacros>`
5913   A vector of macros which are whitespace-sensitive and should not
5914   be touched.
5916   These are expected to be macros of the form:
5918   .. code-block:: c++
5920     STRINGIZE(...)
5922   In the .clang-format configuration file, this can be configured like:
5924   .. code-block:: yaml
5926     WhitespaceSensitiveMacros: ['STRINGIZE', 'PP_STRINGIZE']
5928   For example: BOOST_PP_STRINGIZE
5930 .. END_FORMAT_STYLE_OPTIONS
5932 Adding additional style options
5933 ===============================
5935 Each additional style option adds costs to the clang-format project. Some of
5936 these costs affect the clang-format development itself, as we need to make
5937 sure that any given combination of options work and that new features don't
5938 break any of the existing options in any way. There are also costs for end users
5939 as options become less discoverable and people have to think about and make a
5940 decision on options they don't really care about.
5942 The goal of the clang-format project is more on the side of supporting a
5943 limited set of styles really well as opposed to supporting every single style
5944 used by a codebase somewhere in the wild. Of course, we do want to support all
5945 major projects and thus have established the following bar for adding style
5946 options. Each new style option must ..
5948   * be used in a project of significant size (have dozens of contributors)
5949   * have a publicly accessible style guide
5950   * have a person willing to contribute and maintain patches
5952 Examples
5953 ========
5955 A style similar to the `Linux Kernel style
5956 <https://www.kernel.org/doc/html/latest/process/coding-style.html>`_:
5958 .. code-block:: yaml
5960   BasedOnStyle: LLVM
5961   IndentWidth: 8
5962   UseTab: Always
5963   BreakBeforeBraces: Linux
5964   AllowShortIfStatementsOnASingleLine: false
5965   IndentCaseLabels: false
5967 The result is (imagine that tabs are used for indentation here):
5969 .. code-block:: c++
5971   void test()
5972   {
5973           switch (x) {
5974           case 0:
5975           case 1:
5976                   do_something();
5977                   break;
5978           case 2:
5979                   do_something_else();
5980                   break;
5981           default:
5982                   break;
5983           }
5984           if (condition)
5985                   do_something_completely_different();
5987           if (x == y) {
5988                   q();
5989           } else if (x > y) {
5990                   w();
5991           } else {
5992                   r();
5993           }
5994   }
5996 A style similar to the default Visual Studio formatting style:
5998 .. code-block:: yaml
6000   UseTab: Never
6001   IndentWidth: 4
6002   BreakBeforeBraces: Allman
6003   AllowShortIfStatementsOnASingleLine: false
6004   IndentCaseLabels: false
6005   ColumnLimit: 0
6007 The result is:
6009 .. code-block:: c++
6011   void test()
6012   {
6013       switch (suffix)
6014       {
6015       case 0:
6016       case 1:
6017           do_something();
6018           break;
6019       case 2:
6020           do_something_else();
6021           break;
6022       default:
6023           break;
6024       }
6025       if (condition)
6026           do_something_completely_different();
6028       if (x == y)
6029       {
6030           q();
6031       }
6032       else if (x > y)
6033       {
6034           w();
6035       }
6036       else
6037       {
6038           r();
6039       }
6040   }