1.. raw:: html
2
3      <style type="text/css">
4        .versionbadge { background-color: #1c913d; height: 20px; display: inline-block; width: 120px; text-align: center; border-radius: 5px; color: #FFFFFF; font-family="Verdana,Geneva,DejaVu Sans,sans-serif" }
5      </style>
6
7.. role:: versionbadge
8
9==========================
10Clang-Format Style Options
11==========================
12
13:doc:`ClangFormatStyleOptions` describes configurable formatting style options
14supported by :doc:`LibFormat` and :doc:`ClangFormat`.
15
16When using :program:`clang-format` command line utility or
17``clang::format::reformat(...)`` functions from code, one can either use one of
18the predefined styles (LLVM, Google, Chromium, Mozilla, WebKit, Microsoft) or
19create a custom style by configuring specific style options.
20
21
22Configuring Style with clang-format
23===================================
24
25:program:`clang-format` supports two ways to provide custom style options:
26directly specify style configuration in the ``-style=`` command line option or
27use ``-style=file`` and put style configuration in the ``.clang-format`` or
28``_clang-format`` file in the project directory.
29
30When using ``-style=file``, :program:`clang-format` for each input file will
31try to find the ``.clang-format`` file located in the closest parent directory
32of the input file. When the standard input is used, the search is started from
33the current directory.
34
35When using ``-style=file:<format_file_path>``, :program:`clang-format` for
36each input file will use the format file located at `<format_file_path>`.
37The path may be absolute or relative to the working directory.
38
39The ``.clang-format`` file uses YAML format:
40
41.. code-block:: yaml
42
43  key1: value1
44  key2: value2
45  # A comment.
46  ...
47
48The configuration file can consist of several sections each having different
49``Language:`` parameter denoting the programming language this section of the
50configuration is targeted at. See the description of the **Language** option
51below for the list of supported languages. The first section may have no
52language set, it will set the default style options for all languages.
53Configuration sections for specific language will override options set in the
54default section.
55
56When :program:`clang-format` formats a file, it auto-detects the language using
57the file name. When formatting standard input or a file that doesn't have the
58extension corresponding to its language, ``-assume-filename=`` option can be
59used to override the file name :program:`clang-format` uses to detect the
60language.
61
62An example of a configuration file for multiple languages:
63
64.. code-block:: yaml
65
66  ---
67  # We'll use defaults from the LLVM style, but with 4 columns indentation.
68  BasedOnStyle: LLVM
69  IndentWidth: 4
70  ---
71  Language: Cpp
72  # Force pointers to the type for C++.
73  DerivePointerAlignment: false
74  PointerAlignment: Left
75  ---
76  Language: JavaScript
77  # Use 100 columns for JS.
78  ColumnLimit: 100
79  ---
80  Language: Proto
81  # Don't format .proto files.
82  DisableFormat: true
83  ---
84  Language: CSharp
85  # Use 100 columns for C#.
86  ColumnLimit: 100
87  ...
88
89An easy way to get a valid ``.clang-format`` file containing all configuration
90options of a certain predefined style is:
91
92.. code-block:: console
93
94  clang-format -style=llvm -dump-config > .clang-format
95
96When specifying configuration in the ``-style=`` option, the same configuration
97is applied for all input files. The format of the configuration is:
98
99.. code-block:: console
100
101  -style='{key1: value1, key2: value2, ...}'
102
103
104Disabling Formatting on a Piece of Code
105=======================================
106
107Clang-format understands also special comments that switch formatting in a
108delimited range. The code between a comment ``// clang-format off`` or
109``/* clang-format off */`` up to a comment ``// clang-format on`` or
110``/* clang-format on */`` will not be formatted. The comments themselves
111will be formatted (aligned) normally.
112
113.. code-block:: c++
114
115  int formatted_code;
116  // clang-format off
117      void    unformatted_code  ;
118  // clang-format on
119  void formatted_code_again;
120
121
122Configuring Style in Code
123=========================
124
125When using ``clang::format::reformat(...)`` functions, the format is specified
126by supplying the `clang::format::FormatStyle
127<https://clang.llvm.org/doxygen/structclang_1_1format_1_1FormatStyle.html>`_
128structure.
129
130
131Configurable Format Style Options
132=================================
133
134This section lists the supported style options. Value type is specified for
135each option. For enumeration types possible values are specified both as a C++
136enumeration member (with a prefix, e.g. ``LS_Auto``), and as a value usable in
137the configuration (without a prefix: ``Auto``).
138
139
140**BasedOnStyle** (``String``)
141  The style used for all options not specifically set in the configuration.
142
143  This option is supported only in the :program:`clang-format` configuration
144  (both within ``-style='{...}'`` and the ``.clang-format`` file).
145
146  Possible values:
147
148  * ``LLVM``
149    A style complying with the `LLVM coding standards
150    <https://llvm.org/docs/CodingStandards.html>`_
151  * ``Google``
152    A style complying with `Google's C++ style guide
153    <https://google.github.io/styleguide/cppguide.html>`_
154  * ``Chromium``
155    A style complying with `Chromium's style guide
156    <https://chromium.googlesource.com/chromium/src/+/refs/heads/main/styleguide/styleguide.md>`_
157  * ``Mozilla``
158    A style complying with `Mozilla's style guide
159    <https://firefox-source-docs.mozilla.org/code-quality/coding-style/index.html>`_
160  * ``WebKit``
161    A style complying with `WebKit's style guide
162    <https://www.webkit.org/coding/coding-style.html>`_
163  * ``Microsoft``
164    A style complying with `Microsoft's style guide
165    <https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference>`_
166  * ``GNU``
167    A style complying with the `GNU coding standards
168    <https://www.gnu.org/prep/standards/standards.html>`_
169  * ``InheritParentConfig``
170    Not a real style, but allows to use the ``.clang-format`` file from the
171    parent directory (or its parent if there is none). If there is no parent
172    file found it falls back to the ``fallback`` style, and applies the changes
173    to that.
174
175    With this option you can overwrite some parts of your main style for your
176    subdirectories. This is also possible through the command line, e.g.:
177    ``--style={BasedOnStyle: InheritParentConfig, ColumnLimit: 20}``
178
179.. START_FORMAT_STYLE_OPTIONS
180
181**AccessModifierOffset** (``Integer``) :versionbadge:`clang-format 3.3`
182  The extra indent or outdent of access modifiers, e.g. ``public:``.
183
184**AlignAfterOpenBracket** (``BracketAlignmentStyle``) :versionbadge:`clang-format 3.8`
185  If ``true``, horizontally aligns arguments after an open bracket.
186
187  This applies to round brackets (parentheses), angle brackets and square
188  brackets.
189
190  Possible values:
191
192  * ``BAS_Align`` (in configuration: ``Align``)
193    Align parameters on the open bracket, e.g.:
194
195    .. code-block:: c++
196
197      someLongFunction(argument1,
198                       argument2);
199
200  * ``BAS_DontAlign`` (in configuration: ``DontAlign``)
201    Don't align, instead use ``ContinuationIndentWidth``, e.g.:
202
203    .. code-block:: c++
204
205      someLongFunction(argument1,
206          argument2);
207
208  * ``BAS_AlwaysBreak`` (in configuration: ``AlwaysBreak``)
209    Always break after an open bracket, if the parameters don't fit
210    on a single line, e.g.:
211
212    .. code-block:: c++
213
214      someLongFunction(
215          argument1, argument2);
216
217  * ``BAS_BlockIndent`` (in configuration: ``BlockIndent``)
218    Always break after an open bracket, if the parameters don't fit
219    on a single line. Closing brackets will be placed on a new line.
220    E.g.:
221
222    .. code-block:: c++
223
224      someLongFunction(
225          argument1, argument2
226      )
227
228
229    .. warning::
230
231     Note: This currently only applies to parentheses.
232
233
234
235**AlignArrayOfStructures** (``ArrayInitializerAlignmentStyle``) :versionbadge:`clang-format 13`
236  if not ``None``, when using initialization for an array of structs
237  aligns the fields into columns.
238
239  Possible values:
240
241  * ``AIAS_Left`` (in configuration: ``Left``)
242    Align array column and left justify the columns e.g.:
243
244    .. code-block:: c++
245
246      struct test demo[] =
247      {
248          {56, 23,    "hello"},
249          {-1, 93463, "world"},
250          {7,  5,     "!!"   }
251      };
252
253  * ``AIAS_Right`` (in configuration: ``Right``)
254    Align array column and right justify the columns e.g.:
255
256    .. code-block:: c++
257
258      struct test demo[] =
259      {
260          {56,    23, "hello"},
261          {-1, 93463, "world"},
262          { 7,     5,    "!!"}
263      };
264
265  * ``AIAS_None`` (in configuration: ``None``)
266    Don't align array initializer columns.
267
268
269
270**AlignConsecutiveAssignments** (``AlignConsecutiveStyle``) :versionbadge:`clang-format 3.8`
271  Style of aligning consecutive assignments.
272
273  ``Consecutive`` will result in formattings like:
274
275  .. code-block:: c++
276
277    int a            = 1;
278    int somelongname = 2;
279    double c         = 3;
280
281  Possible values:
282
283  * ``ACS_None`` (in configuration: ``None``)
284     Do not align assignments on consecutive lines.
285
286  * ``ACS_Consecutive`` (in configuration: ``Consecutive``)
287     Align assignments on consecutive lines. This will result in
288     formattings like:
289
290     .. code-block:: c++
291
292       int a            = 1;
293       int somelongname = 2;
294       double c         = 3;
295
296       int d = 3;
297       /* A comment. */
298       double e = 4;
299
300  * ``ACS_AcrossEmptyLines`` (in configuration: ``AcrossEmptyLines``)
301     Same as ACS_Consecutive, but also spans over empty lines, e.g.
302
303     .. code-block:: c++
304
305       int a            = 1;
306       int somelongname = 2;
307       double c         = 3;
308
309       int d            = 3;
310       /* A comment. */
311       double e = 4;
312
313  * ``ACS_AcrossComments`` (in configuration: ``AcrossComments``)
314     Same as ACS_Consecutive, but also spans over lines only containing
315     comments, e.g.
316
317     .. code-block:: c++
318
319       int a            = 1;
320       int somelongname = 2;
321       double c         = 3;
322
323       int d    = 3;
324       /* A comment. */
325       double e = 4;
326
327  * ``ACS_AcrossEmptyLinesAndComments``
328    (in configuration: ``AcrossEmptyLinesAndComments``)
329
330     Same as ACS_Consecutive, but also spans over lines only containing
331     comments and empty lines, e.g.
332
333     .. code-block:: c++
334
335       int a            = 1;
336       int somelongname = 2;
337       double c         = 3;
338
339       int d            = 3;
340       /* A comment. */
341       double e         = 4;
342
343**AlignConsecutiveBitFields** (``AlignConsecutiveStyle``) :versionbadge:`clang-format 11`
344  Style of aligning consecutive bit field.
345
346  ``Consecutive`` will align the bitfield separators of consecutive lines.
347  This will result in formattings like:
348
349  .. code-block:: c++
350
351    int aaaa : 1;
352    int b    : 12;
353    int ccc  : 8;
354
355  Possible values:
356
357  * ``ACS_None`` (in configuration: ``None``)
358     Do not align bit fields on consecutive lines.
359
360  * ``ACS_Consecutive`` (in configuration: ``Consecutive``)
361     Align bit fields on consecutive lines. This will result in
362     formattings like:
363
364     .. code-block:: c++
365
366       int aaaa : 1;
367       int b    : 12;
368       int ccc  : 8;
369
370       int d : 2;
371       /* A comment. */
372       int ee : 3;
373
374  * ``ACS_AcrossEmptyLines`` (in configuration: ``AcrossEmptyLines``)
375     Same as ACS_Consecutive, but also spans over empty lines, e.g.
376
377     .. code-block:: c++
378
379       int aaaa : 1;
380       int b    : 12;
381       int ccc  : 8;
382
383       int d    : 2;
384       /* A comment. */
385       int ee : 3;
386
387  * ``ACS_AcrossComments`` (in configuration: ``AcrossComments``)
388     Same as ACS_Consecutive, but also spans over lines only containing
389     comments, e.g.
390
391     .. code-block:: c++
392
393       int aaaa : 1;
394       int b    : 12;
395       int ccc  : 8;
396
397       int d  : 2;
398       /* A comment. */
399       int ee : 3;
400
401  * ``ACS_AcrossEmptyLinesAndComments``
402    (in configuration: ``AcrossEmptyLinesAndComments``)
403
404     Same as ACS_Consecutive, but also spans over lines only containing
405     comments and empty lines, e.g.
406
407     .. code-block:: c++
408
409       int aaaa : 1;
410       int b    : 12;
411       int ccc  : 8;
412
413       int d    : 2;
414       /* A comment. */
415       int ee   : 3;
416
417**AlignConsecutiveDeclarations** (``AlignConsecutiveStyle``) :versionbadge:`clang-format 3.8`
418  Style of aligning consecutive declarations.
419
420  ``Consecutive`` will align the declaration names of consecutive lines.
421  This will result in formattings like:
422
423  .. code-block:: c++
424
425    int         aaaa = 12;
426    float       b = 23;
427    std::string ccc;
428
429  Possible values:
430
431  * ``ACS_None`` (in configuration: ``None``)
432     Do not align bit declarations on consecutive lines.
433
434  * ``ACS_Consecutive`` (in configuration: ``Consecutive``)
435     Align declarations on consecutive lines. This will result in
436     formattings like:
437
438     .. code-block:: c++
439
440       int         aaaa = 12;
441       float       b = 23;
442       std::string ccc;
443
444       int a = 42;
445       /* A comment. */
446       bool c = false;
447
448  * ``ACS_AcrossEmptyLines`` (in configuration: ``AcrossEmptyLines``)
449     Same as ACS_Consecutive, but also spans over empty lines, e.g.
450
451     .. code-block:: c++
452
453       int         aaaa = 12;
454       float       b = 23;
455       std::string ccc;
456
457       int         a = 42;
458       /* A comment. */
459       bool c = false;
460
461  * ``ACS_AcrossComments`` (in configuration: ``AcrossComments``)
462     Same as ACS_Consecutive, but also spans over lines only containing
463     comments, e.g.
464
465     .. code-block:: c++
466
467       int         aaaa = 12;
468       float       b = 23;
469       std::string ccc;
470
471       int  a = 42;
472       /* A comment. */
473       bool c = false;
474
475  * ``ACS_AcrossEmptyLinesAndComments``
476    (in configuration: ``AcrossEmptyLinesAndComments``)
477
478     Same as ACS_Consecutive, but also spans over lines only containing
479     comments and empty lines, e.g.
480
481     .. code-block:: c++
482
483       int         aaaa = 12;
484       float       b = 23;
485       std::string ccc;
486
487       int         a = 42;
488       /* A comment. */
489       bool        c = false;
490
491**AlignConsecutiveMacros** (``AlignConsecutiveStyle``) :versionbadge:`clang-format 9`
492  Style of aligning consecutive macro definitions.
493
494  ``Consecutive`` will result in formattings like:
495
496  .. code-block:: c++
497
498    #define SHORT_NAME       42
499    #define LONGER_NAME      0x007f
500    #define EVEN_LONGER_NAME (2)
501    #define foo(x)           (x * x)
502    #define bar(y, z)        (y + z)
503
504  Possible values:
505
506  * ``ACS_None`` (in configuration: ``None``)
507     Do not align macro definitions on consecutive lines.
508
509  * ``ACS_Consecutive`` (in configuration: ``Consecutive``)
510     Align macro definitions on consecutive lines. This will result in
511     formattings like:
512
513     .. code-block:: c++
514
515       #define SHORT_NAME       42
516       #define LONGER_NAME      0x007f
517       #define EVEN_LONGER_NAME (2)
518
519       #define foo(x) (x * x)
520       /* some comment */
521       #define bar(y, z) (y + z)
522
523  * ``ACS_AcrossEmptyLines`` (in configuration: ``AcrossEmptyLines``)
524     Same as ACS_Consecutive, but also spans over empty lines, e.g.
525
526     .. code-block:: c++
527
528       #define SHORT_NAME       42
529       #define LONGER_NAME      0x007f
530       #define EVEN_LONGER_NAME (2)
531
532       #define foo(x)           (x * x)
533       /* some comment */
534       #define bar(y, z) (y + z)
535
536  * ``ACS_AcrossComments`` (in configuration: ``AcrossComments``)
537     Same as ACS_Consecutive, but also spans over lines only containing
538     comments, e.g.
539
540     .. code-block:: c++
541
542       #define SHORT_NAME       42
543       #define LONGER_NAME      0x007f
544       #define EVEN_LONGER_NAME (2)
545
546       #define foo(x)    (x * x)
547       /* some comment */
548       #define bar(y, z) (y + z)
549
550  * ``ACS_AcrossEmptyLinesAndComments``
551    (in configuration: ``AcrossEmptyLinesAndComments``)
552
553     Same as ACS_Consecutive, but also spans over lines only containing
554     comments and empty lines, e.g.
555
556     .. code-block:: c++
557
558       #define SHORT_NAME       42
559       #define LONGER_NAME      0x007f
560       #define EVEN_LONGER_NAME (2)
561
562       #define foo(x)           (x * x)
563       /* some comment */
564       #define bar(y, z)        (y + z)
565
566**AlignEscapedNewlines** (``EscapedNewlineAlignmentStyle``) :versionbadge:`clang-format 5`
567  Options for aligning backslashes in escaped newlines.
568
569  Possible values:
570
571  * ``ENAS_DontAlign`` (in configuration: ``DontAlign``)
572    Don't align escaped newlines.
573
574    .. code-block:: c++
575
576      #define A \
577        int aaaa; \
578        int b; \
579        int dddddddddd;
580
581  * ``ENAS_Left`` (in configuration: ``Left``)
582    Align escaped newlines as far left as possible.
583
584    .. code-block:: c++
585
586      true:
587      #define A   \
588        int aaaa; \
589        int b;    \
590        int dddddddddd;
591
592      false:
593
594  * ``ENAS_Right`` (in configuration: ``Right``)
595    Align escaped newlines in the right-most column.
596
597    .. code-block:: c++
598
599      #define A                                                                      \
600        int aaaa;                                                                    \
601        int b;                                                                       \
602        int dddddddddd;
603
604
605
606**AlignOperands** (``OperandAlignmentStyle``) :versionbadge:`clang-format 12`
607  If ``true``, horizontally align operands of binary and ternary
608  expressions.
609
610  Possible values:
611
612  * ``OAS_DontAlign`` (in configuration: ``DontAlign``)
613    Do not align operands of binary and ternary expressions.
614    The wrapped lines are indented ``ContinuationIndentWidth`` spaces from
615    the start of the line.
616
617  * ``OAS_Align`` (in configuration: ``Align``)
618    Horizontally align operands of binary and ternary expressions.
619
620    Specifically, this aligns operands of a single expression that needs
621    to be split over multiple lines, e.g.:
622
623    .. code-block:: c++
624
625      int aaa = bbbbbbbbbbbbbbb +
626                ccccccccccccccc;
627
628    When ``BreakBeforeBinaryOperators`` is set, the wrapped operator is
629    aligned with the operand on the first line.
630
631    .. code-block:: c++
632
633      int aaa = bbbbbbbbbbbbbbb
634                + ccccccccccccccc;
635
636  * ``OAS_AlignAfterOperator`` (in configuration: ``AlignAfterOperator``)
637    Horizontally align operands of binary and ternary expressions.
638
639    This is similar to ``AO_Align``, except when
640    ``BreakBeforeBinaryOperators`` is set, the operator is un-indented so
641    that the wrapped operand is aligned with the operand on the first line.
642
643    .. code-block:: c++
644
645      int aaa = bbbbbbbbbbbbbbb
646              + ccccccccccccccc;
647
648
649
650**AlignTrailingComments** (``Boolean``) :versionbadge:`clang-format 3.7`
651  If ``true``, aligns trailing comments.
652
653  .. code-block:: c++
654
655    true:                                   false:
656    int a;     // My comment a      vs.     int a; // My comment a
657    int b = 2; // comment  b                int b = 2; // comment about b
658
659**AllowAllArgumentsOnNextLine** (``Boolean``) :versionbadge:`clang-format 9`
660  If a function call or braced initializer list doesn't fit on a
661  line, allow putting all arguments onto the next line, even if
662  ``BinPackArguments`` is ``false``.
663
664  .. code-block:: c++
665
666    true:
667    callFunction(
668        a, b, c, d);
669
670    false:
671    callFunction(a,
672                 b,
673                 c,
674                 d);
675
676**AllowAllConstructorInitializersOnNextLine** (``Boolean``) :versionbadge:`clang-format 9`
677  This option is **deprecated**. See ``NextLine`` of
678  ``PackConstructorInitializers``.
679
680**AllowAllParametersOfDeclarationOnNextLine** (``Boolean``) :versionbadge:`clang-format 3.3`
681  If the function declaration doesn't fit on a line,
682  allow putting all parameters of a function declaration onto
683  the next line even if ``BinPackParameters`` is ``false``.
684
685  .. code-block:: c++
686
687    true:
688    void myFunction(
689        int a, int b, int c, int d, int e);
690
691    false:
692    void myFunction(int a,
693                    int b,
694                    int c,
695                    int d,
696                    int e);
697
698**AllowShortBlocksOnASingleLine** (``ShortBlockStyle``) :versionbadge:`clang-format 11`
699  Dependent on the value, ``while (true) { continue; }`` can be put on a
700  single line.
701
702  Possible values:
703
704  * ``SBS_Never`` (in configuration: ``Never``)
705    Never merge blocks into a single line.
706
707    .. code-block:: c++
708
709      while (true) {
710      }
711      while (true) {
712        continue;
713      }
714
715  * ``SBS_Empty`` (in configuration: ``Empty``)
716    Only merge empty blocks.
717
718    .. code-block:: c++
719
720      while (true) {}
721      while (true) {
722        continue;
723      }
724
725  * ``SBS_Always`` (in configuration: ``Always``)
726    Always merge short blocks into a single line.
727
728    .. code-block:: c++
729
730      while (true) {}
731      while (true) { continue; }
732
733
734
735**AllowShortCaseLabelsOnASingleLine** (``Boolean``) :versionbadge:`clang-format 3.6`
736  If ``true``, short case labels will be contracted to a single line.
737
738  .. code-block:: c++
739
740    true:                                   false:
741    switch (a) {                    vs.     switch (a) {
742    case 1: x = 1; break;                   case 1:
743    case 2: return;                           x = 1;
744    }                                         break;
745                                            case 2:
746                                              return;
747                                            }
748
749**AllowShortEnumsOnASingleLine** (``Boolean``) :versionbadge:`clang-format 12`
750  Allow short enums on a single line.
751
752  .. code-block:: c++
753
754    true:
755    enum { A, B } myEnum;
756
757    false:
758    enum {
759      A,
760      B
761    } myEnum;
762
763**AllowShortFunctionsOnASingleLine** (``ShortFunctionStyle``) :versionbadge:`clang-format 3.5`
764  Dependent on the value, ``int f() { return 0; }`` can be put on a
765  single line.
766
767  Possible values:
768
769  * ``SFS_None`` (in configuration: ``None``)
770    Never merge functions into a single line.
771
772  * ``SFS_InlineOnly`` (in configuration: ``InlineOnly``)
773    Only merge functions defined inside a class. Same as "inline",
774    except it does not implies "empty": i.e. top level empty functions
775    are not merged either.
776
777    .. code-block:: c++
778
779      class Foo {
780        void f() { foo(); }
781      };
782      void f() {
783        foo();
784      }
785      void f() {
786      }
787
788  * ``SFS_Empty`` (in configuration: ``Empty``)
789    Only merge empty functions.
790
791    .. code-block:: c++
792
793      void f() {}
794      void f2() {
795        bar2();
796      }
797
798  * ``SFS_Inline`` (in configuration: ``Inline``)
799    Only merge functions defined inside a class. Implies "empty".
800
801    .. code-block:: c++
802
803      class Foo {
804        void f() { foo(); }
805      };
806      void f() {
807        foo();
808      }
809      void f() {}
810
811  * ``SFS_All`` (in configuration: ``All``)
812    Merge all functions fitting on a single line.
813
814    .. code-block:: c++
815
816      class Foo {
817        void f() { foo(); }
818      };
819      void f() { bar(); }
820
821
822
823**AllowShortIfStatementsOnASingleLine** (``ShortIfStyle``) :versionbadge:`clang-format 9`
824  Dependent on the value, ``if (a) return;`` can be put on a single line.
825
826  Possible values:
827
828  * ``SIS_Never`` (in configuration: ``Never``)
829    Never put short ifs on the same line.
830
831    .. code-block:: c++
832
833      if (a)
834        return;
835
836      if (b)
837        return;
838      else
839        return;
840
841      if (c)
842        return;
843      else {
844        return;
845      }
846
847  * ``SIS_WithoutElse`` (in configuration: ``WithoutElse``)
848    Put short ifs on the same line only if there is no else statement.
849
850    .. code-block:: c++
851
852      if (a) return;
853
854      if (b)
855        return;
856      else
857        return;
858
859      if (c)
860        return;
861      else {
862        return;
863      }
864
865  * ``SIS_OnlyFirstIf`` (in configuration: ``OnlyFirstIf``)
866    Put short ifs, but not else ifs nor else statements, on the same line.
867
868    .. code-block:: c++
869
870      if (a) return;
871
872      if (b) return;
873      else if (b)
874        return;
875      else
876        return;
877
878      if (c) return;
879      else {
880        return;
881      }
882
883  * ``SIS_AllIfsAndElse`` (in configuration: ``AllIfsAndElse``)
884    Always put short ifs, else ifs and else statements on the same
885    line.
886
887    .. code-block:: c++
888
889      if (a) return;
890
891      if (b) return;
892      else return;
893
894      if (c) return;
895      else {
896        return;
897      }
898
899
900
901**AllowShortLambdasOnASingleLine** (``ShortLambdaStyle``) :versionbadge:`clang-format 9`
902  Dependent on the value, ``auto lambda []() { return 0; }`` can be put on a
903  single line.
904
905  Possible values:
906
907  * ``SLS_None`` (in configuration: ``None``)
908    Never merge lambdas into a single line.
909
910  * ``SLS_Empty`` (in configuration: ``Empty``)
911    Only merge empty lambdas.
912
913    .. code-block:: c++
914
915      auto lambda = [](int a) {}
916      auto lambda2 = [](int a) {
917          return a;
918      };
919
920  * ``SLS_Inline`` (in configuration: ``Inline``)
921    Merge lambda into a single line if argument of a function.
922
923    .. code-block:: c++
924
925      auto lambda = [](int a) {
926          return a;
927      };
928      sort(a.begin(), a.end(), ()[] { return x < y; })
929
930  * ``SLS_All`` (in configuration: ``All``)
931    Merge all lambdas fitting on a single line.
932
933    .. code-block:: c++
934
935      auto lambda = [](int a) {}
936      auto lambda2 = [](int a) { return a; };
937
938
939
940**AllowShortLoopsOnASingleLine** (``Boolean``) :versionbadge:`clang-format 3.7`
941  If ``true``, ``while (true) continue;`` can be put on a single
942  line.
943
944**AlwaysBreakAfterDefinitionReturnType** (``DefinitionReturnTypeBreakingStyle``) :versionbadge:`clang-format 3.7`
945  The function definition return type breaking style to use.  This
946  option is **deprecated** and is retained for backwards compatibility.
947
948  Possible values:
949
950  * ``DRTBS_None`` (in configuration: ``None``)
951    Break after return type automatically.
952    ``PenaltyReturnTypeOnItsOwnLine`` is taken into account.
953
954  * ``DRTBS_All`` (in configuration: ``All``)
955    Always break after the return type.
956
957  * ``DRTBS_TopLevel`` (in configuration: ``TopLevel``)
958    Always break after the return types of top-level functions.
959
960
961
962**AlwaysBreakAfterReturnType** (``ReturnTypeBreakingStyle``) :versionbadge:`clang-format 3.8`
963  The function declaration return type breaking style to use.
964
965  Possible values:
966
967  * ``RTBS_None`` (in configuration: ``None``)
968    Break after return type automatically.
969    ``PenaltyReturnTypeOnItsOwnLine`` is taken into account.
970
971    .. code-block:: c++
972
973      class A {
974        int f() { return 0; };
975      };
976      int f();
977      int f() { return 1; }
978
979  * ``RTBS_All`` (in configuration: ``All``)
980    Always break after the return type.
981
982    .. code-block:: c++
983
984      class A {
985        int
986        f() {
987          return 0;
988        };
989      };
990      int
991      f();
992      int
993      f() {
994        return 1;
995      }
996
997  * ``RTBS_TopLevel`` (in configuration: ``TopLevel``)
998    Always break after the return types of top-level functions.
999
1000    .. code-block:: c++
1001
1002      class A {
1003        int f() { return 0; };
1004      };
1005      int
1006      f();
1007      int
1008      f() {
1009        return 1;
1010      }
1011
1012  * ``RTBS_AllDefinitions`` (in configuration: ``AllDefinitions``)
1013    Always break after the return type of function definitions.
1014
1015    .. code-block:: c++
1016
1017      class A {
1018        int
1019        f() {
1020          return 0;
1021        };
1022      };
1023      int f();
1024      int
1025      f() {
1026        return 1;
1027      }
1028
1029  * ``RTBS_TopLevelDefinitions`` (in configuration: ``TopLevelDefinitions``)
1030    Always break after the return type of top-level definitions.
1031
1032    .. code-block:: c++
1033
1034      class A {
1035        int f() { return 0; };
1036      };
1037      int f();
1038      int
1039      f() {
1040        return 1;
1041      }
1042
1043
1044
1045**AlwaysBreakBeforeMultilineStrings** (``Boolean``) :versionbadge:`clang-format 3.4`
1046  If ``true``, always break before multiline string literals.
1047
1048  This flag is mean to make cases where there are multiple multiline strings
1049  in a file look more consistent. Thus, it will only take effect if wrapping
1050  the string at that point leads to it being indented
1051  ``ContinuationIndentWidth`` spaces from the start of the line.
1052
1053  .. code-block:: c++
1054
1055     true:                                  false:
1056     aaaa =                         vs.     aaaa = "bbbb"
1057         "bbbb"                                    "cccc";
1058         "cccc";
1059
1060**AlwaysBreakTemplateDeclarations** (``BreakTemplateDeclarationsStyle``) :versionbadge:`clang-format 7`
1061  The template declaration breaking style to use.
1062
1063  Possible values:
1064
1065  * ``BTDS_No`` (in configuration: ``No``)
1066    Do not force break before declaration.
1067    ``PenaltyBreakTemplateDeclaration`` is taken into account.
1068
1069    .. code-block:: c++
1070
1071       template <typename T> T foo() {
1072       }
1073       template <typename T> T foo(int aaaaaaaaaaaaaaaaaaaaa,
1074                                   int bbbbbbbbbbbbbbbbbbbbb) {
1075       }
1076
1077  * ``BTDS_MultiLine`` (in configuration: ``MultiLine``)
1078    Force break after template declaration only when the following
1079    declaration spans multiple lines.
1080
1081    .. code-block:: c++
1082
1083       template <typename T> T foo() {
1084       }
1085       template <typename T>
1086       T foo(int aaaaaaaaaaaaaaaaaaaaa,
1087             int bbbbbbbbbbbbbbbbbbbbb) {
1088       }
1089
1090  * ``BTDS_Yes`` (in configuration: ``Yes``)
1091    Always break after template declaration.
1092
1093    .. code-block:: c++
1094
1095       template <typename T>
1096       T foo() {
1097       }
1098       template <typename T>
1099       T foo(int aaaaaaaaaaaaaaaaaaaaa,
1100             int bbbbbbbbbbbbbbbbbbbbb) {
1101       }
1102
1103
1104
1105**AttributeMacros** (``List of Strings``) :versionbadge:`clang-format 12`
1106  A vector of strings that should be interpreted as attributes/qualifiers
1107  instead of identifiers. This can be useful for language extensions or
1108  static analyzer annotations.
1109
1110  For example:
1111
1112  .. code-block:: c++
1113
1114    x = (char *__capability)&y;
1115    int function(void) __ununsed;
1116    void only_writes_to_buffer(char *__output buffer);
1117
1118  In the .clang-format configuration file, this can be configured like:
1119
1120  .. code-block:: yaml
1121
1122    AttributeMacros: ['__capability', '__output', '__ununsed']
1123
1124**BinPackArguments** (``Boolean``) :versionbadge:`clang-format 3.7`
1125  If ``false``, a function call's arguments will either be all on the
1126  same line or will have one line each.
1127
1128  .. code-block:: c++
1129
1130    true:
1131    void f() {
1132      f(aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa,
1133        aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
1134    }
1135
1136    false:
1137    void f() {
1138      f(aaaaaaaaaaaaaaaaaaaa,
1139        aaaaaaaaaaaaaaaaaaaa,
1140        aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
1141    }
1142
1143**BinPackParameters** (``Boolean``) :versionbadge:`clang-format 3.7`
1144  If ``false``, a function declaration's or function definition's
1145  parameters will either all be on the same line or will have one line each.
1146
1147  .. code-block:: c++
1148
1149    true:
1150    void f(int aaaaaaaaaaaaaaaaaaaa, int aaaaaaaaaaaaaaaaaaaa,
1151           int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}
1152
1153    false:
1154    void f(int aaaaaaaaaaaaaaaaaaaa,
1155           int aaaaaaaaaaaaaaaaaaaa,
1156           int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}
1157
1158**BitFieldColonSpacing** (``BitFieldColonSpacingStyle``) :versionbadge:`clang-format 12`
1159  The BitFieldColonSpacingStyle to use for bitfields.
1160
1161  Possible values:
1162
1163  * ``BFCS_Both`` (in configuration: ``Both``)
1164    Add one space on each side of the ``:``
1165
1166    .. code-block:: c++
1167
1168      unsigned bf : 2;
1169
1170  * ``BFCS_None`` (in configuration: ``None``)
1171    Add no space around the ``:`` (except when needed for
1172    ``AlignConsecutiveBitFields``).
1173
1174    .. code-block:: c++
1175
1176      unsigned bf:2;
1177
1178  * ``BFCS_Before`` (in configuration: ``Before``)
1179    Add space before the ``:`` only
1180
1181    .. code-block:: c++
1182
1183      unsigned bf :2;
1184
1185  * ``BFCS_After`` (in configuration: ``After``)
1186    Add space after the ``:`` only (space may be added before if
1187    needed for ``AlignConsecutiveBitFields``).
1188
1189    .. code-block:: c++
1190
1191      unsigned bf: 2;
1192
1193
1194
1195**BraceWrapping** (``BraceWrappingFlags``) :versionbadge:`clang-format 3.8`
1196  Control of individual brace wrapping cases.
1197
1198  If ``BreakBeforeBraces`` is set to ``BS_Custom``, use this to specify how
1199  each individual brace case should be handled. Otherwise, this is ignored.
1200
1201  .. code-block:: yaml
1202
1203    # Example of usage:
1204    BreakBeforeBraces: Custom
1205    BraceWrapping:
1206      AfterEnum: true
1207      AfterStruct: false
1208      SplitEmptyFunction: false
1209
1210  Nested configuration flags:
1211
1212
1213  * ``bool AfterCaseLabel`` Wrap case labels.
1214
1215    .. code-block:: c++
1216
1217      false:                                true:
1218      switch (foo) {                vs.     switch (foo) {
1219        case 1: {                             case 1:
1220          bar();                              {
1221          break;                                bar();
1222        }                                       break;
1223        default: {                            }
1224          plop();                             default:
1225        }                                     {
1226      }                                         plop();
1227                                              }
1228                                            }
1229
1230  * ``bool AfterClass`` Wrap class definitions.
1231
1232    .. code-block:: c++
1233
1234      true:
1235      class foo {};
1236
1237      false:
1238      class foo
1239      {};
1240
1241  * ``BraceWrappingAfterControlStatementStyle AfterControlStatement``
1242    Wrap control statements (``if``/``for``/``while``/``switch``/..).
1243
1244    Possible values:
1245
1246    * ``BWACS_Never`` (in configuration: ``Never``)
1247      Never wrap braces after a control statement.
1248
1249      .. code-block:: c++
1250
1251        if (foo()) {
1252        } else {
1253        }
1254        for (int i = 0; i < 10; ++i) {
1255        }
1256
1257    * ``BWACS_MultiLine`` (in configuration: ``MultiLine``)
1258      Only wrap braces after a multi-line control statement.
1259
1260      .. code-block:: c++
1261
1262        if (foo && bar &&
1263            baz)
1264        {
1265          quux();
1266        }
1267        while (foo || bar) {
1268        }
1269
1270    * ``BWACS_Always`` (in configuration: ``Always``)
1271      Always wrap braces after a control statement.
1272
1273      .. code-block:: c++
1274
1275        if (foo())
1276        {
1277        } else
1278        {}
1279        for (int i = 0; i < 10; ++i)
1280        {}
1281
1282
1283  * ``bool AfterEnum`` Wrap enum definitions.
1284
1285    .. code-block:: c++
1286
1287      true:
1288      enum X : int
1289      {
1290        B
1291      };
1292
1293      false:
1294      enum X : int { B };
1295
1296  * ``bool AfterFunction`` Wrap function definitions.
1297
1298    .. code-block:: c++
1299
1300      true:
1301      void foo()
1302      {
1303        bar();
1304        bar2();
1305      }
1306
1307      false:
1308      void foo() {
1309        bar();
1310        bar2();
1311      }
1312
1313  * ``bool AfterNamespace`` Wrap namespace definitions.
1314
1315    .. code-block:: c++
1316
1317      true:
1318      namespace
1319      {
1320      int foo();
1321      int bar();
1322      }
1323
1324      false:
1325      namespace {
1326      int foo();
1327      int bar();
1328      }
1329
1330  * ``bool AfterObjCDeclaration`` Wrap ObjC definitions (interfaces, implementations...).
1331    @autoreleasepool and @synchronized blocks are wrapped
1332    according to `AfterControlStatement` flag.
1333
1334  * ``bool AfterStruct`` Wrap struct definitions.
1335
1336    .. code-block:: c++
1337
1338      true:
1339      struct foo
1340      {
1341        int x;
1342      };
1343
1344      false:
1345      struct foo {
1346        int x;
1347      };
1348
1349  * ``bool AfterUnion`` Wrap union definitions.
1350
1351    .. code-block:: c++
1352
1353      true:
1354      union foo
1355      {
1356        int x;
1357      }
1358
1359      false:
1360      union foo {
1361        int x;
1362      }
1363
1364  * ``bool AfterExternBlock`` Wrap extern blocks.
1365
1366    .. code-block:: c++
1367
1368      true:
1369      extern "C"
1370      {
1371        int foo();
1372      }
1373
1374      false:
1375      extern "C" {
1376      int foo();
1377      }
1378
1379  * ``bool BeforeCatch`` Wrap before ``catch``.
1380
1381    .. code-block:: c++
1382
1383      true:
1384      try {
1385        foo();
1386      }
1387      catch () {
1388      }
1389
1390      false:
1391      try {
1392        foo();
1393      } catch () {
1394      }
1395
1396  * ``bool BeforeElse`` Wrap before ``else``.
1397
1398    .. code-block:: c++
1399
1400      true:
1401      if (foo()) {
1402      }
1403      else {
1404      }
1405
1406      false:
1407      if (foo()) {
1408      } else {
1409      }
1410
1411  * ``bool BeforeLambdaBody`` Wrap lambda block.
1412
1413    .. code-block:: c++
1414
1415      true:
1416      connect(
1417        []()
1418        {
1419          foo();
1420          bar();
1421        });
1422
1423      false:
1424      connect([]() {
1425        foo();
1426        bar();
1427      });
1428
1429  * ``bool BeforeWhile`` Wrap before ``while``.
1430
1431    .. code-block:: c++
1432
1433      true:
1434      do {
1435        foo();
1436      }
1437      while (1);
1438
1439      false:
1440      do {
1441        foo();
1442      } while (1);
1443
1444  * ``bool IndentBraces`` Indent the wrapped braces themselves.
1445
1446  * ``bool SplitEmptyFunction`` If ``false``, empty function body can be put on a single line.
1447    This option is used only if the opening brace of the function has
1448    already been wrapped, i.e. the `AfterFunction` brace wrapping mode is
1449    set, and the function could/should not be put on a single line (as per
1450    `AllowShortFunctionsOnASingleLine` and constructor formatting options).
1451
1452    .. code-block:: c++
1453
1454      int f()   vs.   int f()
1455      {}              {
1456                      }
1457
1458  * ``bool SplitEmptyRecord`` If ``false``, empty record (e.g. class, struct or union) body
1459    can be put on a single line. This option is used only if the opening
1460    brace of the record has already been wrapped, i.e. the `AfterClass`
1461    (for classes) brace wrapping mode is set.
1462
1463    .. code-block:: c++
1464
1465      class Foo   vs.  class Foo
1466      {}               {
1467                       }
1468
1469  * ``bool SplitEmptyNamespace`` If ``false``, empty namespace body can be put on a single line.
1470    This option is used only if the opening brace of the namespace has
1471    already been wrapped, i.e. the `AfterNamespace` brace wrapping mode is
1472    set.
1473
1474    .. code-block:: c++
1475
1476      namespace Foo   vs.  namespace Foo
1477      {}                   {
1478                           }
1479
1480
1481**BreakAfterJavaFieldAnnotations** (``Boolean``) :versionbadge:`clang-format 3.8`
1482  Break after each annotation on a field in Java files.
1483
1484  .. code-block:: java
1485
1486     true:                                  false:
1487     @Partial                       vs.     @Partial @Mock DataLoad loader;
1488     @Mock
1489     DataLoad loader;
1490
1491**BreakBeforeBinaryOperators** (``BinaryOperatorStyle``) :versionbadge:`clang-format 3.6`
1492  The way to wrap binary operators.
1493
1494  Possible values:
1495
1496  * ``BOS_None`` (in configuration: ``None``)
1497    Break after operators.
1498
1499    .. code-block:: c++
1500
1501       LooooooooooongType loooooooooooooooooooooongVariable =
1502           someLooooooooooooooooongFunction();
1503
1504       bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
1505                            aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ==
1506                        aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &&
1507                    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa >
1508                        ccccccccccccccccccccccccccccccccccccccccc;
1509
1510  * ``BOS_NonAssignment`` (in configuration: ``NonAssignment``)
1511    Break before operators that aren't assignments.
1512
1513    .. code-block:: c++
1514
1515       LooooooooooongType loooooooooooooooooooooongVariable =
1516           someLooooooooooooooooongFunction();
1517
1518       bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
1519                            + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
1520                        == aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
1521                    && aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
1522                           > ccccccccccccccccccccccccccccccccccccccccc;
1523
1524  * ``BOS_All`` (in configuration: ``All``)
1525    Break before operators.
1526
1527    .. code-block:: c++
1528
1529       LooooooooooongType loooooooooooooooooooooongVariable
1530           = someLooooooooooooooooongFunction();
1531
1532       bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
1533                            + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
1534                        == aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
1535                    && aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
1536                           > ccccccccccccccccccccccccccccccccccccccccc;
1537
1538
1539
1540**BreakBeforeBraces** (``BraceBreakingStyle``) :versionbadge:`clang-format 3.7`
1541  The brace breaking style to use.
1542
1543  Possible values:
1544
1545  * ``BS_Attach`` (in configuration: ``Attach``)
1546    Always attach braces to surrounding context.
1547
1548    .. code-block:: c++
1549
1550      namespace N {
1551      enum E {
1552        E1,
1553        E2,
1554      };
1555
1556      class C {
1557      public:
1558        C();
1559      };
1560
1561      bool baz(int i) {
1562        try {
1563          do {
1564            switch (i) {
1565            case 1: {
1566              foobar();
1567              break;
1568            }
1569            default: {
1570              break;
1571            }
1572            }
1573          } while (--i);
1574          return true;
1575        } catch (...) {
1576          handleError();
1577          return false;
1578        }
1579      }
1580
1581      void foo(bool b) {
1582        if (b) {
1583          baz(2);
1584        } else {
1585          baz(5);
1586        }
1587      }
1588
1589      void bar() { foo(true); }
1590      } // namespace N
1591
1592  * ``BS_Linux`` (in configuration: ``Linux``)
1593    Like ``Attach``, but break before braces on function, namespace and
1594    class definitions.
1595
1596    .. code-block:: c++
1597
1598      namespace N
1599      {
1600      enum E {
1601        E1,
1602        E2,
1603      };
1604
1605      class C
1606      {
1607      public:
1608        C();
1609      };
1610
1611      bool baz(int i)
1612      {
1613        try {
1614          do {
1615            switch (i) {
1616            case 1: {
1617              foobar();
1618              break;
1619            }
1620            default: {
1621              break;
1622            }
1623            }
1624          } while (--i);
1625          return true;
1626        } catch (...) {
1627          handleError();
1628          return false;
1629        }
1630      }
1631
1632      void foo(bool b)
1633      {
1634        if (b) {
1635          baz(2);
1636        } else {
1637          baz(5);
1638        }
1639      }
1640
1641      void bar() { foo(true); }
1642      } // namespace N
1643
1644  * ``BS_Mozilla`` (in configuration: ``Mozilla``)
1645    Like ``Attach``, but break before braces on enum, function, and record
1646    definitions.
1647
1648    .. code-block:: c++
1649
1650      namespace N {
1651      enum E
1652      {
1653        E1,
1654        E2,
1655      };
1656
1657      class C
1658      {
1659      public:
1660        C();
1661      };
1662
1663      bool baz(int i)
1664      {
1665        try {
1666          do {
1667            switch (i) {
1668            case 1: {
1669              foobar();
1670              break;
1671            }
1672            default: {
1673              break;
1674            }
1675            }
1676          } while (--i);
1677          return true;
1678        } catch (...) {
1679          handleError();
1680          return false;
1681        }
1682      }
1683
1684      void foo(bool b)
1685      {
1686        if (b) {
1687          baz(2);
1688        } else {
1689          baz(5);
1690        }
1691      }
1692
1693      void bar() { foo(true); }
1694      } // namespace N
1695
1696  * ``BS_Stroustrup`` (in configuration: ``Stroustrup``)
1697    Like ``Attach``, but break before function definitions, ``catch``, and
1698    ``else``.
1699
1700    .. code-block:: c++
1701
1702      namespace N {
1703      enum E {
1704        E1,
1705        E2,
1706      };
1707
1708      class C {
1709      public:
1710        C();
1711      };
1712
1713      bool baz(int i)
1714      {
1715        try {
1716          do {
1717            switch (i) {
1718            case 1: {
1719              foobar();
1720              break;
1721            }
1722            default: {
1723              break;
1724            }
1725            }
1726          } while (--i);
1727          return true;
1728        }
1729        catch (...) {
1730          handleError();
1731          return false;
1732        }
1733      }
1734
1735      void foo(bool b)
1736      {
1737        if (b) {
1738          baz(2);
1739        }
1740        else {
1741          baz(5);
1742        }
1743      }
1744
1745      void bar() { foo(true); }
1746      } // namespace N
1747
1748  * ``BS_Allman`` (in configuration: ``Allman``)
1749    Always break before braces.
1750
1751    .. code-block:: c++
1752
1753      namespace N
1754      {
1755      enum E
1756      {
1757        E1,
1758        E2,
1759      };
1760
1761      class C
1762      {
1763      public:
1764        C();
1765      };
1766
1767      bool baz(int i)
1768      {
1769        try
1770        {
1771          do
1772          {
1773            switch (i)
1774            {
1775            case 1:
1776            {
1777              foobar();
1778              break;
1779            }
1780            default:
1781            {
1782              break;
1783            }
1784            }
1785          } while (--i);
1786          return true;
1787        }
1788        catch (...)
1789        {
1790          handleError();
1791          return false;
1792        }
1793      }
1794
1795      void foo(bool b)
1796      {
1797        if (b)
1798        {
1799          baz(2);
1800        }
1801        else
1802        {
1803          baz(5);
1804        }
1805      }
1806
1807      void bar() { foo(true); }
1808      } // namespace N
1809
1810  * ``BS_Whitesmiths`` (in configuration: ``Whitesmiths``)
1811    Like ``Allman`` but always indent braces and line up code with braces.
1812
1813    .. code-block:: c++
1814
1815      namespace N
1816        {
1817      enum E
1818        {
1819        E1,
1820        E2,
1821        };
1822
1823      class C
1824        {
1825      public:
1826        C();
1827        };
1828
1829      bool baz(int i)
1830        {
1831        try
1832          {
1833          do
1834            {
1835            switch (i)
1836              {
1837              case 1:
1838              {
1839              foobar();
1840              break;
1841              }
1842              default:
1843              {
1844              break;
1845              }
1846              }
1847            } while (--i);
1848          return true;
1849          }
1850        catch (...)
1851          {
1852          handleError();
1853          return false;
1854          }
1855        }
1856
1857      void foo(bool b)
1858        {
1859        if (b)
1860          {
1861          baz(2);
1862          }
1863        else
1864          {
1865          baz(5);
1866          }
1867        }
1868
1869      void bar() { foo(true); }
1870        } // namespace N
1871
1872  * ``BS_GNU`` (in configuration: ``GNU``)
1873    Always break before braces and add an extra level of indentation to
1874    braces of control statements, not to those of class, function
1875    or other definitions.
1876
1877    .. code-block:: c++
1878
1879      namespace N
1880      {
1881      enum E
1882      {
1883        E1,
1884        E2,
1885      };
1886
1887      class C
1888      {
1889      public:
1890        C();
1891      };
1892
1893      bool baz(int i)
1894      {
1895        try
1896          {
1897            do
1898              {
1899                switch (i)
1900                  {
1901                  case 1:
1902                    {
1903                      foobar();
1904                      break;
1905                    }
1906                  default:
1907                    {
1908                      break;
1909                    }
1910                  }
1911              }
1912            while (--i);
1913            return true;
1914          }
1915        catch (...)
1916          {
1917            handleError();
1918            return false;
1919          }
1920      }
1921
1922      void foo(bool b)
1923      {
1924        if (b)
1925          {
1926            baz(2);
1927          }
1928        else
1929          {
1930            baz(5);
1931          }
1932      }
1933
1934      void bar() { foo(true); }
1935      } // namespace N
1936
1937  * ``BS_WebKit`` (in configuration: ``WebKit``)
1938    Like ``Attach``, but break before functions.
1939
1940    .. code-block:: c++
1941
1942      namespace N {
1943      enum E {
1944        E1,
1945        E2,
1946      };
1947
1948      class C {
1949      public:
1950        C();
1951      };
1952
1953      bool baz(int i)
1954      {
1955        try {
1956          do {
1957            switch (i) {
1958            case 1: {
1959              foobar();
1960              break;
1961            }
1962            default: {
1963              break;
1964            }
1965            }
1966          } while (--i);
1967          return true;
1968        } catch (...) {
1969          handleError();
1970          return false;
1971        }
1972      }
1973
1974      void foo(bool b)
1975      {
1976        if (b) {
1977          baz(2);
1978        } else {
1979          baz(5);
1980        }
1981      }
1982
1983      void bar() { foo(true); }
1984      } // namespace N
1985
1986  * ``BS_Custom`` (in configuration: ``Custom``)
1987    Configure each individual brace in `BraceWrapping`.
1988
1989
1990
1991**BreakBeforeConceptDeclarations** (``BreakBeforeConceptDeclarationsStyle``) :versionbadge:`clang-format 13`
1992  The concept declaration style to use.
1993
1994  Possible values:
1995
1996  * ``BBCDS_Never`` (in configuration: ``Never``)
1997    Keep the template declaration line together with ``concept``.
1998
1999    .. code-block:: c++
2000
2001      template <typename T> concept C = ...;
2002
2003  * ``BBCDS_Allowed`` (in configuration: ``Allowed``)
2004    Breaking between template declaration and ``concept`` is allowed. The
2005    actual behavior depends on the content and line breaking rules and
2006    penalities.
2007
2008  * ``BBCDS_Always`` (in configuration: ``Always``)
2009    Always break before ``concept``, putting it in the line after the
2010    template declaration.
2011
2012    .. code-block:: c++
2013
2014      template <typename T>
2015      concept C = ...;
2016
2017
2018
2019**BreakBeforeTernaryOperators** (``Boolean``) :versionbadge:`clang-format 3.7`
2020  If ``true``, ternary operators will be placed after line breaks.
2021
2022  .. code-block:: c++
2023
2024     true:
2025     veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongDescription
2026         ? firstValue
2027         : SecondValueVeryVeryVeryVeryLong;
2028
2029     false:
2030     veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongDescription ?
2031         firstValue :
2032         SecondValueVeryVeryVeryVeryLong;
2033
2034**BreakConstructorInitializers** (``BreakConstructorInitializersStyle``) :versionbadge:`clang-format 5`
2035  The break constructor initializers style to use.
2036
2037  Possible values:
2038
2039  * ``BCIS_BeforeColon`` (in configuration: ``BeforeColon``)
2040    Break constructor initializers before the colon and after the commas.
2041
2042    .. code-block:: c++
2043
2044       Constructor()
2045           : initializer1(),
2046             initializer2()
2047
2048  * ``BCIS_BeforeComma`` (in configuration: ``BeforeComma``)
2049    Break constructor initializers before the colon and commas, and align
2050    the commas with the colon.
2051
2052    .. code-block:: c++
2053
2054       Constructor()
2055           : initializer1()
2056           , initializer2()
2057
2058  * ``BCIS_AfterColon`` (in configuration: ``AfterColon``)
2059    Break constructor initializers after the colon and commas.
2060
2061    .. code-block:: c++
2062
2063       Constructor() :
2064           initializer1(),
2065           initializer2()
2066
2067
2068
2069**BreakInheritanceList** (``BreakInheritanceListStyle``) :versionbadge:`clang-format 7`
2070  The inheritance list style to use.
2071
2072  Possible values:
2073
2074  * ``BILS_BeforeColon`` (in configuration: ``BeforeColon``)
2075    Break inheritance list before the colon and after the commas.
2076
2077    .. code-block:: c++
2078
2079       class Foo
2080           : Base1,
2081             Base2
2082       {};
2083
2084  * ``BILS_BeforeComma`` (in configuration: ``BeforeComma``)
2085    Break inheritance list before the colon and commas, and align
2086    the commas with the colon.
2087
2088    .. code-block:: c++
2089
2090       class Foo
2091           : Base1
2092           , Base2
2093       {};
2094
2095  * ``BILS_AfterColon`` (in configuration: ``AfterColon``)
2096    Break inheritance list after the colon and commas.
2097
2098    .. code-block:: c++
2099
2100       class Foo :
2101           Base1,
2102           Base2
2103       {};
2104
2105  * ``BILS_AfterComma`` (in configuration: ``AfterComma``)
2106    Break inheritance list only after the commas.
2107
2108    .. code-block:: c++
2109
2110       class Foo : Base1,
2111                   Base2
2112       {};
2113
2114
2115
2116**BreakStringLiterals** (``Boolean``) :versionbadge:`clang-format 3.9`
2117  Allow breaking string literals when formatting.
2118
2119  .. code-block:: c++
2120
2121     true:
2122     const char* x = "veryVeryVeryVeryVeryVe"
2123                     "ryVeryVeryVeryVeryVery"
2124                     "VeryLongString";
2125
2126     false:
2127     const char* x =
2128       "veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongString";
2129
2130**ColumnLimit** (``Unsigned``) :versionbadge:`clang-format 3.7`
2131  The column limit.
2132
2133  A column limit of ``0`` means that there is no column limit. In this case,
2134  clang-format will respect the input's line breaking decisions within
2135  statements unless they contradict other rules.
2136
2137**CommentPragmas** (``String``) :versionbadge:`clang-format 3.7`
2138  A regular expression that describes comments with special meaning,
2139  which should not be split into lines or otherwise changed.
2140
2141  .. code-block:: c++
2142
2143     // CommentPragmas: '^ FOOBAR pragma:'
2144     // Will leave the following line unaffected
2145     #include <vector> // FOOBAR pragma: keep
2146
2147**CompactNamespaces** (``Boolean``) :versionbadge:`clang-format 5`
2148  If ``true``, consecutive namespace declarations will be on the same
2149  line. If ``false``, each namespace is declared on a new line.
2150
2151  .. code-block:: c++
2152
2153    true:
2154    namespace Foo { namespace Bar {
2155    }}
2156
2157    false:
2158    namespace Foo {
2159    namespace Bar {
2160    }
2161    }
2162
2163  If it does not fit on a single line, the overflowing namespaces get
2164  wrapped:
2165
2166  .. code-block:: c++
2167
2168    namespace Foo { namespace Bar {
2169    namespace Extra {
2170    }}}
2171
2172**ConstructorInitializerAllOnOneLineOrOnePerLine** (``Boolean``) :versionbadge:`clang-format 3.7`
2173  This option is **deprecated**. See ``CurrentLine`` of
2174  ``PackConstructorInitializers``.
2175
2176**ConstructorInitializerIndentWidth** (``Unsigned``) :versionbadge:`clang-format 3.7`
2177  The number of characters to use for indentation of constructor
2178  initializer lists as well as inheritance lists.
2179
2180**ContinuationIndentWidth** (``Unsigned``) :versionbadge:`clang-format 3.7`
2181  Indent width for line continuations.
2182
2183  .. code-block:: c++
2184
2185     ContinuationIndentWidth: 2
2186
2187     int i =         //  VeryVeryVeryVeryVeryLongComment
2188       longFunction( // Again a long comment
2189         arg);
2190
2191**Cpp11BracedListStyle** (``Boolean``) :versionbadge:`clang-format 3.4`
2192  If ``true``, format braced lists as best suited for C++11 braced
2193  lists.
2194
2195  Important differences:
2196  - No spaces inside the braced list.
2197  - No line break before the closing brace.
2198  - Indentation with the continuation indent, not with the block indent.
2199
2200  Fundamentally, C++11 braced lists are formatted exactly like function
2201  calls would be formatted in their place. If the braced list follows a name
2202  (e.g. a type or variable name), clang-format formats as if the ``{}`` were
2203  the parentheses of a function call with that name. If there is no name,
2204  a zero-length name is assumed.
2205
2206  .. code-block:: c++
2207
2208     true:                                  false:
2209     vector<int> x{1, 2, 3, 4};     vs.     vector<int> x{ 1, 2, 3, 4 };
2210     vector<T> x{{}, {}, {}, {}};           vector<T> x{ {}, {}, {}, {} };
2211     f(MyMap[{composite, key}]);            f(MyMap[{ composite, key }]);
2212     new int[3]{1, 2, 3};                   new int[3]{ 1, 2, 3 };
2213
2214**DeriveLineEnding** (``Boolean``) :versionbadge:`clang-format 11`
2215  Analyze the formatted file for the most used line ending (``\r\n``
2216  or ``\n``). ``UseCRLF`` is only used as a fallback if none can be derived.
2217
2218**DerivePointerAlignment** (``Boolean``) :versionbadge:`clang-format 3.7`
2219  If ``true``, analyze the formatted file for the most common
2220  alignment of ``&`` and ``*``.
2221  Pointer and reference alignment styles are going to be updated according
2222  to the preferences found in the file.
2223  ``PointerAlignment`` is then used only as fallback.
2224
2225**DisableFormat** (``Boolean``) :versionbadge:`clang-format 3.7`
2226  Disables formatting completely.
2227
2228**EmptyLineAfterAccessModifier** (``EmptyLineAfterAccessModifierStyle``) :versionbadge:`clang-format 13`
2229  Defines when to put an empty line after access modifiers.
2230  ``EmptyLineBeforeAccessModifier`` configuration handles the number of
2231  empty lines between two access modifiers.
2232
2233  Possible values:
2234
2235  * ``ELAAMS_Never`` (in configuration: ``Never``)
2236    Remove all empty lines after access modifiers.
2237
2238    .. code-block:: c++
2239
2240      struct foo {
2241      private:
2242        int i;
2243      protected:
2244        int j;
2245        /* comment */
2246      public:
2247        foo() {}
2248      private:
2249      protected:
2250      };
2251
2252  * ``ELAAMS_Leave`` (in configuration: ``Leave``)
2253    Keep existing empty lines after access modifiers.
2254    MaxEmptyLinesToKeep is applied instead.
2255
2256  * ``ELAAMS_Always`` (in configuration: ``Always``)
2257    Always add empty line after access modifiers if there are none.
2258    MaxEmptyLinesToKeep is applied also.
2259
2260    .. code-block:: c++
2261
2262      struct foo {
2263      private:
2264
2265        int i;
2266      protected:
2267
2268        int j;
2269        /* comment */
2270      public:
2271
2272        foo() {}
2273      private:
2274
2275      protected:
2276
2277      };
2278
2279
2280
2281**EmptyLineBeforeAccessModifier** (``EmptyLineBeforeAccessModifierStyle``) :versionbadge:`clang-format 13`
2282  Defines in which cases to put empty line before access modifiers.
2283
2284  Possible values:
2285
2286  * ``ELBAMS_Never`` (in configuration: ``Never``)
2287    Remove all empty lines before access modifiers.
2288
2289    .. code-block:: c++
2290
2291      struct foo {
2292      private:
2293        int i;
2294      protected:
2295        int j;
2296        /* comment */
2297      public:
2298        foo() {}
2299      private:
2300      protected:
2301      };
2302
2303  * ``ELBAMS_Leave`` (in configuration: ``Leave``)
2304    Keep existing empty lines before access modifiers.
2305
2306  * ``ELBAMS_LogicalBlock`` (in configuration: ``LogicalBlock``)
2307    Add empty line only when access modifier starts a new logical block.
2308    Logical block is a group of one or more member fields or functions.
2309
2310    .. code-block:: c++
2311
2312      struct foo {
2313      private:
2314        int i;
2315
2316      protected:
2317        int j;
2318        /* comment */
2319      public:
2320        foo() {}
2321
2322      private:
2323      protected:
2324      };
2325
2326  * ``ELBAMS_Always`` (in configuration: ``Always``)
2327    Always add empty line before access modifiers unless access modifier
2328    is at the start of struct or class definition.
2329
2330    .. code-block:: c++
2331
2332      struct foo {
2333      private:
2334        int i;
2335
2336      protected:
2337        int j;
2338        /* comment */
2339
2340      public:
2341        foo() {}
2342
2343      private:
2344
2345      protected:
2346      };
2347
2348
2349
2350**ExperimentalAutoDetectBinPacking** (``Boolean``) :versionbadge:`clang-format 3.7`
2351  If ``true``, clang-format detects whether function calls and
2352  definitions are formatted with one parameter per line.
2353
2354  Each call can be bin-packed, one-per-line or inconclusive. If it is
2355  inconclusive, e.g. completely on one line, but a decision needs to be
2356  made, clang-format analyzes whether there are other bin-packed cases in
2357  the input file and act accordingly.
2358
2359  NOTE: This is an experimental flag, that might go away or be renamed. Do
2360  not use this in config files, etc. Use at your own risk.
2361
2362**FixNamespaceComments** (``Boolean``) :versionbadge:`clang-format 5`
2363  If ``true``, clang-format adds missing namespace end comments for
2364  short namespaces and fixes invalid existing ones. Short ones are
2365  controlled by "ShortNamespaceLines".
2366
2367  .. code-block:: c++
2368
2369     true:                                  false:
2370     namespace a {                  vs.     namespace a {
2371     foo();                                 foo();
2372     bar();                                 bar();
2373     } // namespace a                       }
2374
2375**ForEachMacros** (``List of Strings``) :versionbadge:`clang-format 3.7`
2376  A vector of macros that should be interpreted as foreach loops
2377  instead of as function calls.
2378
2379  These are expected to be macros of the form:
2380
2381  .. code-block:: c++
2382
2383    FOREACH(<variable-declaration>, ...)
2384      <loop-body>
2385
2386  In the .clang-format configuration file, this can be configured like:
2387
2388  .. code-block:: yaml
2389
2390    ForEachMacros: ['RANGES_FOR', 'FOREACH']
2391
2392  For example: BOOST_FOREACH.
2393
2394**IfMacros** (``List of Strings``) :versionbadge:`clang-format 13`
2395  A vector of macros that should be interpreted as conditionals
2396  instead of as function calls.
2397
2398  These are expected to be macros of the form:
2399
2400  .. code-block:: c++
2401
2402    IF(...)
2403      <conditional-body>
2404    else IF(...)
2405      <conditional-body>
2406
2407  In the .clang-format configuration file, this can be configured like:
2408
2409  .. code-block:: yaml
2410
2411    IfMacros: ['IF']
2412
2413  For example: `KJ_IF_MAYBE
2414  <https://github.com/capnproto/capnproto/blob/master/kjdoc/tour.md#maybes>`_
2415
2416**IncludeBlocks** (``IncludeBlocksStyle``) :versionbadge:`clang-format 7`
2417  Dependent on the value, multiple ``#include`` blocks can be sorted
2418  as one and divided based on category.
2419
2420  Possible values:
2421
2422  * ``IBS_Preserve`` (in configuration: ``Preserve``)
2423    Sort each ``#include`` block separately.
2424
2425    .. code-block:: c++
2426
2427       #include "b.h"               into      #include "b.h"
2428
2429       #include <lib/main.h>                  #include "a.h"
2430       #include "a.h"                         #include <lib/main.h>
2431
2432  * ``IBS_Merge`` (in configuration: ``Merge``)
2433    Merge multiple ``#include`` blocks together and sort as one.
2434
2435    .. code-block:: c++
2436
2437       #include "b.h"               into      #include "a.h"
2438                                              #include "b.h"
2439       #include <lib/main.h>                  #include <lib/main.h>
2440       #include "a.h"
2441
2442  * ``IBS_Regroup`` (in configuration: ``Regroup``)
2443    Merge multiple ``#include`` blocks together and sort as one.
2444    Then split into groups based on category priority. See
2445    ``IncludeCategories``.
2446
2447    .. code-block:: c++
2448
2449       #include "b.h"               into      #include "a.h"
2450                                              #include "b.h"
2451       #include <lib/main.h>
2452       #include "a.h"                         #include <lib/main.h>
2453
2454
2455
2456**IncludeCategories** (``List of IncludeCategories``) :versionbadge:`clang-format 7`
2457  Regular expressions denoting the different ``#include`` categories
2458  used for ordering ``#includes``.
2459
2460  `POSIX extended
2461  <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html>`_
2462  regular expressions are supported.
2463
2464  These regular expressions are matched against the filename of an include
2465  (including the <> or "") in order. The value belonging to the first
2466  matching regular expression is assigned and ``#includes`` are sorted first
2467  according to increasing category number and then alphabetically within
2468  each category.
2469
2470  If none of the regular expressions match, INT_MAX is assigned as
2471  category. The main header for a source file automatically gets category 0.
2472  so that it is generally kept at the beginning of the ``#includes``
2473  (https://llvm.org/docs/CodingStandards.html#include-style). However, you
2474  can also assign negative priorities if you have certain headers that
2475  always need to be first.
2476
2477  There is a third and optional field ``SortPriority`` which can used while
2478  ``IncludeBlocks = IBS_Regroup`` to define the priority in which
2479  ``#includes`` should be ordered. The value of ``Priority`` defines the
2480  order of ``#include blocks`` and also allows the grouping of ``#includes``
2481  of different priority. ``SortPriority`` is set to the value of
2482  ``Priority`` as default if it is not assigned.
2483
2484  Each regular expression can be marked as case sensitive with the field
2485  ``CaseSensitive``, per default it is not.
2486
2487  To configure this in the .clang-format file, use:
2488
2489  .. code-block:: yaml
2490
2491    IncludeCategories:
2492      - Regex:           '^"(llvm|llvm-c|clang|clang-c)/'
2493        Priority:        2
2494        SortPriority:    2
2495        CaseSensitive:   true
2496      - Regex:           '^((<|")(gtest|gmock|isl|json)/)'
2497        Priority:        3
2498      - Regex:           '<[[:alnum:].]+>'
2499        Priority:        4
2500      - Regex:           '.*'
2501        Priority:        1
2502        SortPriority:    0
2503
2504**IncludeIsMainRegex** (``String``) :versionbadge:`clang-format 7`
2505  Specify a regular expression of suffixes that are allowed in the
2506  file-to-main-include mapping.
2507
2508  When guessing whether a #include is the "main" include (to assign
2509  category 0, see above), use this regex of allowed suffixes to the header
2510  stem. A partial match is done, so that:
2511  - "" means "arbitrary suffix"
2512  - "$" means "no suffix"
2513
2514  For example, if configured to "(_test)?$", then a header a.h would be seen
2515  as the "main" include in both a.cc and a_test.cc.
2516
2517**IncludeIsMainSourceRegex** (``String``) :versionbadge:`clang-format 7`
2518  Specify a regular expression for files being formatted
2519  that are allowed to be considered "main" in the
2520  file-to-main-include mapping.
2521
2522  By default, clang-format considers files as "main" only when they end
2523  with: ``.c``, ``.cc``, ``.cpp``, ``.c++``, ``.cxx``, ``.m`` or ``.mm``
2524  extensions.
2525  For these files a guessing of "main" include takes place
2526  (to assign category 0, see above). This config option allows for
2527  additional suffixes and extensions for files to be considered as "main".
2528
2529  For example, if this option is configured to ``(Impl\.hpp)$``,
2530  then a file ``ClassImpl.hpp`` is considered "main" (in addition to
2531  ``Class.c``, ``Class.cc``, ``Class.cpp`` and so on) and "main
2532  include file" logic will be executed (with *IncludeIsMainRegex* setting
2533  also being respected in later phase). Without this option set,
2534  ``ClassImpl.hpp`` would not have the main include file put on top
2535  before any other include.
2536
2537**IndentAccessModifiers** (``Boolean``) :versionbadge:`clang-format 13`
2538  Specify whether access modifiers should have their own indentation level.
2539
2540  When ``false``, access modifiers are indented (or outdented) relative to
2541  the record members, respecting the ``AccessModifierOffset``. Record
2542  members are indented one level below the record.
2543  When ``true``, access modifiers get their own indentation level. As a
2544  consequence, record members are always indented 2 levels below the record,
2545  regardless of the access modifier presence. Value of the
2546  ``AccessModifierOffset`` is ignored.
2547
2548  .. code-block:: c++
2549
2550     false:                                 true:
2551     class C {                      vs.     class C {
2552       class D {                                class D {
2553         void bar();                                void bar();
2554       protected:                                 protected:
2555         D();                                       D();
2556       };                                       };
2557     public:                                  public:
2558       C();                                     C();
2559     };                                     };
2560     void foo() {                           void foo() {
2561       return 1;                              return 1;
2562     }                                      }
2563
2564**IndentCaseBlocks** (``Boolean``) :versionbadge:`clang-format 11`
2565  Indent case label blocks one level from the case label.
2566
2567  When ``false``, the block following the case label uses the same
2568  indentation level as for the case label, treating the case label the same
2569  as an if-statement.
2570  When ``true``, the block gets indented as a scope block.
2571
2572  .. code-block:: c++
2573
2574     false:                                 true:
2575     switch (fool) {                vs.     switch (fool) {
2576     case 1: {                              case 1:
2577       bar();                                 {
2578     } break;                                   bar();
2579     default: {                               }
2580       plop();                                break;
2581     }                                      default:
2582     }                                        {
2583                                                plop();
2584                                              }
2585                                            }
2586
2587**IndentCaseLabels** (``Boolean``) :versionbadge:`clang-format 3.3`
2588  Indent case labels one level from the switch statement.
2589
2590  When ``false``, use the same indentation level as for the switch
2591  statement. Switch statement body is always indented one level more than
2592  case labels (except the first block following the case label, which
2593  itself indents the code - unless IndentCaseBlocks is enabled).
2594
2595  .. code-block:: c++
2596
2597     false:                                 true:
2598     switch (fool) {                vs.     switch (fool) {
2599     case 1:                                  case 1:
2600       bar();                                   bar();
2601       break;                                   break;
2602     default:                                 default:
2603       plop();                                  plop();
2604     }                                      }
2605
2606**IndentExternBlock** (``IndentExternBlockStyle``) :versionbadge:`clang-format 12`
2607  IndentExternBlockStyle is the type of indenting of extern blocks.
2608
2609  Possible values:
2610
2611  * ``IEBS_AfterExternBlock`` (in configuration: ``AfterExternBlock``)
2612    Backwards compatible with AfterExternBlock's indenting.
2613
2614    .. code-block:: c++
2615
2616       IndentExternBlock: AfterExternBlock
2617       BraceWrapping.AfterExternBlock: true
2618       extern "C"
2619       {
2620           void foo();
2621       }
2622
2623
2624    .. code-block:: c++
2625
2626       IndentExternBlock: AfterExternBlock
2627       BraceWrapping.AfterExternBlock: false
2628       extern "C" {
2629       void foo();
2630       }
2631
2632  * ``IEBS_NoIndent`` (in configuration: ``NoIndent``)
2633    Does not indent extern blocks.
2634
2635    .. code-block:: c++
2636
2637        extern "C" {
2638        void foo();
2639        }
2640
2641  * ``IEBS_Indent`` (in configuration: ``Indent``)
2642    Indents extern blocks.
2643
2644    .. code-block:: c++
2645
2646        extern "C" {
2647          void foo();
2648        }
2649
2650
2651
2652**IndentGotoLabels** (``Boolean``) :versionbadge:`clang-format 10`
2653  Indent goto labels.
2654
2655  When ``false``, goto labels are flushed left.
2656
2657  .. code-block:: c++
2658
2659     true:                                  false:
2660     int f() {                      vs.     int f() {
2661       if (foo()) {                           if (foo()) {
2662       label1:                              label1:
2663         bar();                                 bar();
2664       }                                      }
2665     label2:                                label2:
2666       return 1;                              return 1;
2667     }                                      }
2668
2669**IndentPPDirectives** (``PPDirectiveIndentStyle``) :versionbadge:`clang-format 6`
2670  The preprocessor directive indenting style to use.
2671
2672  Possible values:
2673
2674  * ``PPDIS_None`` (in configuration: ``None``)
2675    Does not indent any directives.
2676
2677    .. code-block:: c++
2678
2679       #if FOO
2680       #if BAR
2681       #include <foo>
2682       #endif
2683       #endif
2684
2685  * ``PPDIS_AfterHash`` (in configuration: ``AfterHash``)
2686    Indents directives after the hash.
2687
2688    .. code-block:: c++
2689
2690       #if FOO
2691       #  if BAR
2692       #    include <foo>
2693       #  endif
2694       #endif
2695
2696  * ``PPDIS_BeforeHash`` (in configuration: ``BeforeHash``)
2697    Indents directives before the hash.
2698
2699    .. code-block:: c++
2700
2701       #if FOO
2702         #if BAR
2703           #include <foo>
2704         #endif
2705       #endif
2706
2707
2708
2709**IndentRequiresClause** (``Boolean``) :versionbadge:`clang-format 13`
2710  Indent the requires clause in a template. This only applies when
2711  ``RequiresClausePosition`` is ``OwnLine``, or ``WithFollowing``.
2712
2713  .. code-block:: c++
2714
2715     true:
2716     template <typename It>
2717       requires Iterator<It>
2718     void sort(It begin, It end) {
2719       //....
2720     }
2721
2722     false:
2723     template <typename It>
2724     requires Iterator<It>
2725     void sort(It begin, It end) {
2726       //....
2727     }
2728
2729**IndentWidth** (``Unsigned``) :versionbadge:`clang-format 3.7`
2730  The number of columns to use for indentation.
2731
2732  .. code-block:: c++
2733
2734     IndentWidth: 3
2735
2736     void f() {
2737        someFunction();
2738        if (true, false) {
2739           f();
2740        }
2741     }
2742
2743**IndentWrappedFunctionNames** (``Boolean``) :versionbadge:`clang-format 3.7`
2744  Indent if a function definition or declaration is wrapped after the
2745  type.
2746
2747  .. code-block:: c++
2748
2749     true:
2750     LoooooooooooooooooooooooooooooooooooooooongReturnType
2751         LoooooooooooooooooooooooooooooooongFunctionDeclaration();
2752
2753     false:
2754     LoooooooooooooooooooooooooooooooooooooooongReturnType
2755     LoooooooooooooooooooooooooooooooongFunctionDeclaration();
2756
2757**InsertTrailingCommas** (``TrailingCommaStyle``) :versionbadge:`clang-format 12`
2758  If set to ``TCS_Wrapped`` will insert trailing commas in container
2759  literals (arrays and objects) that wrap across multiple lines.
2760  It is currently only available for JavaScript
2761  and disabled by default ``TCS_None``.
2762  ``InsertTrailingCommas`` cannot be used together with ``BinPackArguments``
2763  as inserting the comma disables bin-packing.
2764
2765  .. code-block:: c++
2766
2767    TSC_Wrapped:
2768    const someArray = [
2769    aaaaaaaaaaaaaaaaaaaaaaaaaa,
2770    aaaaaaaaaaaaaaaaaaaaaaaaaa,
2771    aaaaaaaaaaaaaaaaaaaaaaaaaa,
2772    //                        ^ inserted
2773    ]
2774
2775  Possible values:
2776
2777  * ``TCS_None`` (in configuration: ``None``)
2778    Do not insert trailing commas.
2779
2780  * ``TCS_Wrapped`` (in configuration: ``Wrapped``)
2781    Insert trailing commas in container literals that were wrapped over
2782    multiple lines. Note that this is conceptually incompatible with
2783    bin-packing, because the trailing comma is used as an indicator
2784    that a container should be formatted one-per-line (i.e. not bin-packed).
2785    So inserting a trailing comma counteracts bin-packing.
2786
2787
2788
2789**JavaImportGroups** (``List of Strings``) :versionbadge:`clang-format 8`
2790  A vector of prefixes ordered by the desired groups for Java imports.
2791
2792  One group's prefix can be a subset of another - the longest prefix is
2793  always matched. Within a group, the imports are ordered lexicographically.
2794  Static imports are grouped separately and follow the same group rules.
2795  By default, static imports are placed before non-static imports,
2796  but this behavior is changed by another option,
2797  ``SortJavaStaticImport``.
2798
2799  In the .clang-format configuration file, this can be configured like
2800  in the following yaml example. This will result in imports being
2801  formatted as in the Java example below.
2802
2803  .. code-block:: yaml
2804
2805    JavaImportGroups: ['com.example', 'com', 'org']
2806
2807
2808  .. code-block:: java
2809
2810     import static com.example.function1;
2811
2812     import static com.test.function2;
2813
2814     import static org.example.function3;
2815
2816     import com.example.ClassA;
2817     import com.example.Test;
2818     import com.example.a.ClassB;
2819
2820     import com.test.ClassC;
2821
2822     import org.example.ClassD;
2823
2824**JavaScriptQuotes** (``JavaScriptQuoteStyle``) :versionbadge:`clang-format 3.9`
2825  The JavaScriptQuoteStyle to use for JavaScript strings.
2826
2827  Possible values:
2828
2829  * ``JSQS_Leave`` (in configuration: ``Leave``)
2830    Leave string quotes as they are.
2831
2832    .. code-block:: js
2833
2834       string1 = "foo";
2835       string2 = 'bar';
2836
2837  * ``JSQS_Single`` (in configuration: ``Single``)
2838    Always use single quotes.
2839
2840    .. code-block:: js
2841
2842       string1 = 'foo';
2843       string2 = 'bar';
2844
2845  * ``JSQS_Double`` (in configuration: ``Double``)
2846    Always use double quotes.
2847
2848    .. code-block:: js
2849
2850       string1 = "foo";
2851       string2 = "bar";
2852
2853
2854
2855**JavaScriptWrapImports** (``Boolean``) :versionbadge:`clang-format 3.9`
2856  Whether to wrap JavaScript import/export statements.
2857
2858  .. code-block:: js
2859
2860     true:
2861     import {
2862         VeryLongImportsAreAnnoying,
2863         VeryLongImportsAreAnnoying,
2864         VeryLongImportsAreAnnoying,
2865     } from 'some/module.js'
2866
2867     false:
2868     import {VeryLongImportsAreAnnoying, VeryLongImportsAreAnnoying, VeryLongImportsAreAnnoying,} from "some/module.js"
2869
2870**KeepEmptyLinesAtTheStartOfBlocks** (``Boolean``) :versionbadge:`clang-format 3.7`
2871  If true, the empty line at the start of blocks is kept.
2872
2873  .. code-block:: c++
2874
2875     true:                                  false:
2876     if (foo) {                     vs.     if (foo) {
2877                                              bar();
2878       bar();                               }
2879     }
2880
2881**LambdaBodyIndentation** (``LambdaBodyIndentationKind``) :versionbadge:`clang-format 13`
2882  The indentation style of lambda bodies. ``Signature`` (the default)
2883  causes the lambda body to be indented one additional level relative to
2884  the indentation level of the signature. ``OuterScope`` forces the lambda
2885  body to be indented one additional level relative to the parent scope
2886  containing the lambda signature. For callback-heavy code, it may improve
2887  readability to have the signature indented two levels and to use
2888  ``OuterScope``. The KJ style guide requires ``OuterScope``.
2889  `KJ style guide
2890  <https://github.com/capnproto/capnproto/blob/master/style-guide.md>`_
2891
2892  Possible values:
2893
2894  * ``LBI_Signature`` (in configuration: ``Signature``)
2895    Align lambda body relative to the lambda signature. This is the default.
2896
2897    .. code-block:: c++
2898
2899       someMethod(
2900           [](SomeReallyLongLambdaSignatureArgument foo) {
2901             return;
2902           });
2903
2904  * ``LBI_OuterScope`` (in configuration: ``OuterScope``)
2905    Align lambda body relative to the indentation level of the outer scope
2906    the lambda signature resides in.
2907
2908    .. code-block:: c++
2909
2910       someMethod(
2911           [](SomeReallyLongLambdaSignatureArgument foo) {
2912         return;
2913       });
2914
2915
2916
2917**Language** (``LanguageKind``) :versionbadge:`clang-format 3.5`
2918  Language, this format style is targeted at.
2919
2920  Possible values:
2921
2922  * ``LK_None`` (in configuration: ``None``)
2923    Do not use.
2924
2925  * ``LK_Cpp`` (in configuration: ``Cpp``)
2926    Should be used for C, C++.
2927
2928  * ``LK_CSharp`` (in configuration: ``CSharp``)
2929    Should be used for C#.
2930
2931  * ``LK_Java`` (in configuration: ``Java``)
2932    Should be used for Java.
2933
2934  * ``LK_JavaScript`` (in configuration: ``JavaScript``)
2935    Should be used for JavaScript.
2936
2937  * ``LK_Json`` (in configuration: ``Json``)
2938    Should be used for JSON.
2939
2940  * ``LK_ObjC`` (in configuration: ``ObjC``)
2941    Should be used for Objective-C, Objective-C++.
2942
2943  * ``LK_Proto`` (in configuration: ``Proto``)
2944    Should be used for Protocol Buffers
2945    (https://developers.google.com/protocol-buffers/).
2946
2947  * ``LK_TableGen`` (in configuration: ``TableGen``)
2948    Should be used for TableGen code.
2949
2950  * ``LK_TextProto`` (in configuration: ``TextProto``)
2951    Should be used for Protocol Buffer messages in text format
2952    (https://developers.google.com/protocol-buffers/).
2953
2954
2955
2956**MacroBlockBegin** (``String``) :versionbadge:`clang-format 3.7`
2957  A regular expression matching macros that start a block.
2958
2959  .. code-block:: c++
2960
2961     # With:
2962     MacroBlockBegin: "^NS_MAP_BEGIN|\
2963     NS_TABLE_HEAD$"
2964     MacroBlockEnd: "^\
2965     NS_MAP_END|\
2966     NS_TABLE_.*_END$"
2967
2968     NS_MAP_BEGIN
2969       foo();
2970     NS_MAP_END
2971
2972     NS_TABLE_HEAD
2973       bar();
2974     NS_TABLE_FOO_END
2975
2976     # Without:
2977     NS_MAP_BEGIN
2978     foo();
2979     NS_MAP_END
2980
2981     NS_TABLE_HEAD
2982     bar();
2983     NS_TABLE_FOO_END
2984
2985**MacroBlockEnd** (``String``) :versionbadge:`clang-format 3.7`
2986  A regular expression matching macros that end a block.
2987
2988**MaxEmptyLinesToKeep** (``Unsigned``) :versionbadge:`clang-format 3.7`
2989  The maximum number of consecutive empty lines to keep.
2990
2991  .. code-block:: c++
2992
2993     MaxEmptyLinesToKeep: 1         vs.     MaxEmptyLinesToKeep: 0
2994     int f() {                              int f() {
2995       int = 1;                                 int i = 1;
2996                                                i = foo();
2997       i = foo();                               return i;
2998                                            }
2999       return i;
3000     }
3001
3002**NamespaceIndentation** (``NamespaceIndentationKind``) :versionbadge:`clang-format 3.7`
3003  The indentation used for namespaces.
3004
3005  Possible values:
3006
3007  * ``NI_None`` (in configuration: ``None``)
3008    Don't indent in namespaces.
3009
3010    .. code-block:: c++
3011
3012       namespace out {
3013       int i;
3014       namespace in {
3015       int i;
3016       }
3017       }
3018
3019  * ``NI_Inner`` (in configuration: ``Inner``)
3020    Indent only in inner namespaces (nested in other namespaces).
3021
3022    .. code-block:: c++
3023
3024       namespace out {
3025       int i;
3026       namespace in {
3027         int i;
3028       }
3029       }
3030
3031  * ``NI_All`` (in configuration: ``All``)
3032    Indent in all namespaces.
3033
3034    .. code-block:: c++
3035
3036       namespace out {
3037         int i;
3038         namespace in {
3039           int i;
3040         }
3041       }
3042
3043
3044
3045**NamespaceMacros** (``List of Strings``) :versionbadge:`clang-format 9`
3046  A vector of macros which are used to open namespace blocks.
3047
3048  These are expected to be macros of the form:
3049
3050  .. code-block:: c++
3051
3052    NAMESPACE(<namespace-name>, ...) {
3053      <namespace-content>
3054    }
3055
3056  For example: TESTSUITE
3057
3058**ObjCBinPackProtocolList** (``BinPackStyle``) :versionbadge:`clang-format 7`
3059  Controls bin-packing Objective-C protocol conformance list
3060  items into as few lines as possible when they go over ``ColumnLimit``.
3061
3062  If ``Auto`` (the default), delegates to the value in
3063  ``BinPackParameters``. If that is ``true``, bin-packs Objective-C
3064  protocol conformance list items into as few lines as possible
3065  whenever they go over ``ColumnLimit``.
3066
3067  If ``Always``, always bin-packs Objective-C protocol conformance
3068  list items into as few lines as possible whenever they go over
3069  ``ColumnLimit``.
3070
3071  If ``Never``, lays out Objective-C protocol conformance list items
3072  onto individual lines whenever they go over ``ColumnLimit``.
3073
3074
3075  .. code-block:: objc
3076
3077     Always (or Auto, if BinPackParameters=true):
3078     @interface ccccccccccccc () <
3079         ccccccccccccc, ccccccccccccc,
3080         ccccccccccccc, ccccccccccccc> {
3081     }
3082
3083     Never (or Auto, if BinPackParameters=false):
3084     @interface ddddddddddddd () <
3085         ddddddddddddd,
3086         ddddddddddddd,
3087         ddddddddddddd,
3088         ddddddddddddd> {
3089     }
3090
3091  Possible values:
3092
3093  * ``BPS_Auto`` (in configuration: ``Auto``)
3094    Automatically determine parameter bin-packing behavior.
3095
3096  * ``BPS_Always`` (in configuration: ``Always``)
3097    Always bin-pack parameters.
3098
3099  * ``BPS_Never`` (in configuration: ``Never``)
3100    Never bin-pack parameters.
3101
3102
3103
3104**ObjCBlockIndentWidth** (``Unsigned``) :versionbadge:`clang-format 3.7`
3105  The number of characters to use for indentation of ObjC blocks.
3106
3107  .. code-block:: objc
3108
3109     ObjCBlockIndentWidth: 4
3110
3111     [operation setCompletionBlock:^{
3112         [self onOperationDone];
3113     }];
3114
3115**ObjCBreakBeforeNestedBlockParam** (``Boolean``) :versionbadge:`clang-format 12`
3116  Break parameters list into lines when there is nested block
3117  parameters in a function call.
3118
3119  .. code-block:: c++
3120
3121    false:
3122     - (void)_aMethod
3123     {
3124         [self.test1 t:self w:self callback:^(typeof(self) self, NSNumber
3125         *u, NSNumber *v) {
3126             u = c;
3127         }]
3128     }
3129     true:
3130     - (void)_aMethod
3131     {
3132        [self.test1 t:self
3133                     w:self
3134            callback:^(typeof(self) self, NSNumber *u, NSNumber *v) {
3135                 u = c;
3136             }]
3137     }
3138
3139**ObjCSpaceAfterProperty** (``Boolean``) :versionbadge:`clang-format 3.7`
3140  Add a space after ``@property`` in Objective-C, i.e. use
3141  ``@property (readonly)`` instead of ``@property(readonly)``.
3142
3143**ObjCSpaceBeforeProtocolList** (``Boolean``) :versionbadge:`clang-format 3.7`
3144  Add a space in front of an Objective-C protocol list, i.e. use
3145  ``Foo <Protocol>`` instead of ``Foo<Protocol>``.
3146
3147**PPIndentWidth** (``Integer``) :versionbadge:`clang-format 13`
3148  The number of columns to use for indentation of preprocessor statements.
3149  When set to -1 (default) ``IndentWidth`` is used also for preprocessor
3150  statements.
3151
3152  .. code-block:: c++
3153
3154     PPIndentWidth: 1
3155
3156     #ifdef __linux__
3157     # define FOO
3158     #else
3159     # define BAR
3160     #endif
3161
3162**PackConstructorInitializers** (``PackConstructorInitializersStyle``) :versionbadge:`clang-format 14`
3163  The pack constructor initializers style to use.
3164
3165  Possible values:
3166
3167  * ``PCIS_Never`` (in configuration: ``Never``)
3168    Always put each constructor initializer on its own line.
3169
3170    .. code-block:: c++
3171
3172       Constructor()
3173           : a(),
3174             b()
3175
3176  * ``PCIS_BinPack`` (in configuration: ``BinPack``)
3177    Bin-pack constructor initializers.
3178
3179    .. code-block:: c++
3180
3181       Constructor()
3182           : aaaaaaaaaaaaaaaaaaaa(), bbbbbbbbbbbbbbbbbbbb(),
3183             cccccccccccccccccccc()
3184
3185  * ``PCIS_CurrentLine`` (in configuration: ``CurrentLine``)
3186    Put all constructor initializers on the current line if they fit.
3187    Otherwise, put each one on its own line.
3188
3189    .. code-block:: c++
3190
3191       Constructor() : a(), b()
3192
3193       Constructor()
3194           : aaaaaaaaaaaaaaaaaaaa(),
3195             bbbbbbbbbbbbbbbbbbbb(),
3196             ddddddddddddd()
3197
3198  * ``PCIS_NextLine`` (in configuration: ``NextLine``)
3199    Same as ``PCIS_CurrentLine`` except that if all constructor initializers
3200    do not fit on the current line, try to fit them on the next line.
3201
3202    .. code-block:: c++
3203
3204       Constructor() : a(), b()
3205
3206       Constructor()
3207           : aaaaaaaaaaaaaaaaaaaa(), bbbbbbbbbbbbbbbbbbbb(), ddddddddddddd()
3208
3209       Constructor()
3210           : aaaaaaaaaaaaaaaaaaaa(),
3211             bbbbbbbbbbbbbbbbbbbb(),
3212             cccccccccccccccccccc()
3213
3214
3215
3216**PenaltyBreakAssignment** (``Unsigned``) :versionbadge:`clang-format 5`
3217  The penalty for breaking around an assignment operator.
3218
3219**PenaltyBreakBeforeFirstCallParameter** (``Unsigned``) :versionbadge:`clang-format 3.7`
3220  The penalty for breaking a function call after ``call(``.
3221
3222**PenaltyBreakComment** (``Unsigned``) :versionbadge:`clang-format 3.7`
3223  The penalty for each line break introduced inside a comment.
3224
3225**PenaltyBreakFirstLessLess** (``Unsigned``) :versionbadge:`clang-format 3.7`
3226  The penalty for breaking before the first ``<<``.
3227
3228**PenaltyBreakOpenParenthesis** (``Unsigned``) :versionbadge:`clang-format 14`
3229  The penalty for breaking after ``(``.
3230
3231**PenaltyBreakString** (``Unsigned``) :versionbadge:`clang-format 3.7`
3232  The penalty for each line break introduced inside a string literal.
3233
3234**PenaltyBreakTemplateDeclaration** (``Unsigned``) :versionbadge:`clang-format 7`
3235  The penalty for breaking after template declaration.
3236
3237**PenaltyExcessCharacter** (``Unsigned``) :versionbadge:`clang-format 3.7`
3238  The penalty for each character outside of the column limit.
3239
3240**PenaltyIndentedWhitespace** (``Unsigned``) :versionbadge:`clang-format 12`
3241  Penalty for each character of whitespace indentation
3242  (counted relative to leading non-whitespace column).
3243
3244**PenaltyReturnTypeOnItsOwnLine** (``Unsigned``) :versionbadge:`clang-format 3.7`
3245  Penalty for putting the return type of a function onto its own
3246  line.
3247
3248**PointerAlignment** (``PointerAlignmentStyle``) :versionbadge:`clang-format 3.7`
3249  Pointer and reference alignment style.
3250
3251  Possible values:
3252
3253  * ``PAS_Left`` (in configuration: ``Left``)
3254    Align pointer to the left.
3255
3256    .. code-block:: c++
3257
3258      int* a;
3259
3260  * ``PAS_Right`` (in configuration: ``Right``)
3261    Align pointer to the right.
3262
3263    .. code-block:: c++
3264
3265      int *a;
3266
3267  * ``PAS_Middle`` (in configuration: ``Middle``)
3268    Align pointer in the middle.
3269
3270    .. code-block:: c++
3271
3272      int * a;
3273
3274
3275
3276**QualifierAlignment** (``QualifierAlignmentStyle``) :versionbadge:`clang-format 14`
3277  Different ways to arrange specifiers and qualifiers (e.g. const/volatile).
3278
3279  .. warning::
3280
3281   Setting ``QualifierAlignment``  to something other than `Leave`, COULD
3282   lead to incorrect code formatting due to incorrect decisions made due to
3283   clang-formats lack of complete semantic information.
3284   As such extra care should be taken to review code changes made by the use
3285   of this option.
3286
3287  Possible values:
3288
3289  * ``QAS_Leave`` (in configuration: ``Leave``)
3290    Don't change specifiers/qualifiers to either Left or Right alignment
3291    (default).
3292
3293    .. code-block:: c++
3294
3295       int const a;
3296       const int *a;
3297
3298  * ``QAS_Left`` (in configuration: ``Left``)
3299    Change specifiers/qualifiers to be left-aligned.
3300
3301    .. code-block:: c++
3302
3303       const int a;
3304       const int *a;
3305
3306  * ``QAS_Right`` (in configuration: ``Right``)
3307    Change specifiers/qualifiers to be right-aligned.
3308
3309    .. code-block:: c++
3310
3311       int const a;
3312       int const *a;
3313
3314  * ``QAS_Custom`` (in configuration: ``Custom``)
3315    Change specifiers/qualifiers to be aligned based on ``QualifierOrder``.
3316    With:
3317
3318    .. code-block:: yaml
3319
3320      QualifierOrder: ['inline', 'static' , 'type', 'const']
3321
3322
3323    .. code-block:: c++
3324
3325
3326       int const a;
3327       int const *a;
3328
3329
3330
3331**QualifierOrder** (``List of Strings``) :versionbadge:`clang-format 14`
3332  The order in which the qualifiers appear.
3333  Order is an array that can contain any of the following:
3334
3335    * const
3336    * inline
3337    * static
3338    * constexpr
3339    * volatile
3340    * restrict
3341    * type
3342
3343  Note: it MUST contain 'type'.
3344  Items to the left of 'type' will be placed to the left of the type and
3345  aligned in the order supplied. Items to the right of 'type' will be placed
3346  to the right of the type and aligned in the order supplied.
3347
3348
3349  .. code-block:: yaml
3350
3351    QualifierOrder: ['inline', 'static', 'type', 'const', 'volatile' ]
3352
3353**RawStringFormats** (``List of RawStringFormats``) :versionbadge:`clang-format 6`
3354  Defines hints for detecting supported languages code blocks in raw
3355  strings.
3356
3357  A raw string with a matching delimiter or a matching enclosing function
3358  name will be reformatted assuming the specified language based on the
3359  style for that language defined in the .clang-format file. If no style has
3360  been defined in the .clang-format file for the specific language, a
3361  predefined style given by 'BasedOnStyle' is used. If 'BasedOnStyle' is not
3362  found, the formatting is based on llvm style. A matching delimiter takes
3363  precedence over a matching enclosing function name for determining the
3364  language of the raw string contents.
3365
3366  If a canonical delimiter is specified, occurrences of other delimiters for
3367  the same language will be updated to the canonical if possible.
3368
3369  There should be at most one specification per language and each delimiter
3370  and enclosing function should not occur in multiple specifications.
3371
3372  To configure this in the .clang-format file, use:
3373
3374  .. code-block:: yaml
3375
3376    RawStringFormats:
3377      - Language: TextProto
3378          Delimiters:
3379            - 'pb'
3380            - 'proto'
3381          EnclosingFunctions:
3382            - 'PARSE_TEXT_PROTO'
3383          BasedOnStyle: google
3384      - Language: Cpp
3385          Delimiters:
3386            - 'cc'
3387            - 'cpp'
3388          BasedOnStyle: llvm
3389          CanonicalDelimiter: 'cc'
3390
3391**ReferenceAlignment** (``ReferenceAlignmentStyle``) :versionbadge:`clang-format 13`
3392  Reference alignment style (overrides ``PointerAlignment`` for
3393  references).
3394
3395  Possible values:
3396
3397  * ``RAS_Pointer`` (in configuration: ``Pointer``)
3398    Align reference like ``PointerAlignment``.
3399
3400  * ``RAS_Left`` (in configuration: ``Left``)
3401    Align reference to the left.
3402
3403    .. code-block:: c++
3404
3405      int& a;
3406
3407  * ``RAS_Right`` (in configuration: ``Right``)
3408    Align reference to the right.
3409
3410    .. code-block:: c++
3411
3412      int &a;
3413
3414  * ``RAS_Middle`` (in configuration: ``Middle``)
3415    Align reference in the middle.
3416
3417    .. code-block:: c++
3418
3419      int & a;
3420
3421
3422
3423**ReflowComments** (``Boolean``) :versionbadge:`clang-format 4`
3424  If ``true``, clang-format will attempt to re-flow comments.
3425
3426  .. code-block:: c++
3427
3428     false:
3429     // veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of information
3430     /* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of information */
3431
3432     true:
3433     // veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of
3434     // information
3435     /* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of
3436      * information */
3437
3438**RemoveBracesLLVM** (``Boolean``) :versionbadge:`clang-format 14`
3439  Remove optional braces of control statements (``if``, ``else``, ``for``,
3440  and ``while``) in C++ according to the LLVM coding style.
3441
3442  .. warning::
3443
3444   This option will be renamed and expanded to support other styles.
3445
3446  .. warning::
3447
3448   Setting this option to `true` could lead to incorrect code formatting due
3449   to clang-format's lack of complete semantic information. As such, extra
3450   care should be taken to review code changes made by this option.
3451
3452  .. code-block:: c++
3453
3454    false:                                     true:
3455
3456    if (isa<FunctionDecl>(D)) {        vs.     if (isa<FunctionDecl>(D))
3457      handleFunctionDecl(D);                     handleFunctionDecl(D);
3458    } else if (isa<VarDecl>(D)) {              else if (isa<VarDecl>(D))
3459      handleVarDecl(D);                          handleVarDecl(D);
3460    }
3461
3462    if (isa<VarDecl>(D)) {             vs.     if (isa<VarDecl>(D)) {
3463      for (auto *A : D.attrs()) {                for (auto *A : D.attrs())
3464        if (shouldProcessAttr(A)) {                if (shouldProcessAttr(A))
3465          handleAttr(A);                             handleAttr(A);
3466        }                                      }
3467      }
3468    }
3469
3470    if (isa<FunctionDecl>(D)) {        vs.     if (isa<FunctionDecl>(D))
3471      for (auto *A : D.attrs()) {                for (auto *A : D.attrs())
3472        handleAttr(A);                             handleAttr(A);
3473      }
3474    }
3475
3476    if (auto *D = (T)(D)) {            vs.     if (auto *D = (T)(D)) {
3477      if (shouldProcess(D)) {                    if (shouldProcess(D))
3478        handleVarDecl(D);                          handleVarDecl(D);
3479      } else {                                   else
3480        markAsIgnored(D);                          markAsIgnored(D);
3481      }                                        }
3482    }
3483
3484    if (a) {                           vs.     if (a)
3485      b();                                       b();
3486    } else {                                   else if (c)
3487      if (c) {                                   d();
3488        d();                                   else
3489      } else {                                   e();
3490        e();
3491      }
3492    }
3493
3494**RequiresClausePosition** (``RequiresClausePositionStyle``) :versionbadge:`clang-format 15`
3495  The position of the ``requires`` clause.
3496
3497  Possible values:
3498
3499  * ``RCPS_OwnLine`` (in configuration: ``OwnLine``)
3500    Always put the ``requires`` clause on its own line.
3501
3502    .. code-block:: c++
3503
3504      template <typename T>
3505      requires C<T>
3506      struct Foo {...
3507
3508      template <typename T>
3509      requires C<T>
3510      void bar(T t) {...
3511
3512      template <typename T>
3513      void baz(T t)
3514      requires C<T>
3515      {...
3516
3517  * ``RCPS_WithPreceding`` (in configuration: ``WithPreceding``)
3518    Try to put the clause together with the preceding part of a declaration.
3519    For class templates: stick to the template declaration.
3520    For function templates: stick to the template declaration.
3521    For function declaration followed by a requires clause: stick to the
3522    parameter list.
3523
3524    .. code-block:: c++
3525
3526      template <typename T> requires C<T>
3527      struct Foo {...
3528
3529      template <typename T> requires C<T>
3530      void bar(T t) {...
3531
3532      template <typename T>
3533      void baz(T t) requires C<T>
3534      {...
3535
3536  * ``RCPS_WithFollowing`` (in configuration: ``WithFollowing``)
3537    Try to put the ``requires`` clause together with the class or function
3538    declaration.
3539
3540    .. code-block:: c++
3541
3542      template <typename T>
3543      requires C<T> struct Foo {...
3544
3545      template <typename T>
3546      requires C<T> void bar(T t) {...
3547
3548      template <typename T>
3549      void baz(T t)
3550      requires C<T> {...
3551
3552  * ``RCPS_SingleLine`` (in configuration: ``SingleLine``)
3553    Try to put everything in the same line if possible. Otherwise normal
3554    line breaking rules take over.
3555
3556    .. code-block:: c++
3557
3558      // Fitting:
3559      template <typename T> requires C<T> struct Foo {...
3560
3561      template <typename T> requires C<T> void bar(T t) {...
3562
3563      template <typename T> void bar(T t) requires C<T> {...
3564
3565      // Not fitting, one possible example:
3566      template <typename LongName>
3567      requires C<LongName>
3568      struct Foo {...
3569
3570      template <typename LongName>
3571      requires C<LongName>
3572      void bar(LongName ln) {
3573
3574      template <typename LongName>
3575      void bar(LongName ln)
3576          requires C<LongName> {
3577
3578
3579
3580**SeparateDefinitionBlocks** (``SeparateDefinitionStyle``) :versionbadge:`clang-format 14`
3581  Specifies the use of empty lines to separate definition blocks, including
3582  classes, structs, enums, and functions.
3583
3584  .. code-block:: c++
3585
3586     Never                  v.s.     Always
3587     #include <cstring>              #include <cstring>
3588     struct Foo {
3589       int a, b, c;                  struct Foo {
3590     };                                int a, b, c;
3591     namespace Ns {                  };
3592     class Bar {
3593     public:                         namespace Ns {
3594       struct Foobar {               class Bar {
3595         int a;                      public:
3596         int b;                        struct Foobar {
3597       };                                int a;
3598     private:                            int b;
3599       int t;                          };
3600       int method1() {
3601         // ...                      private:
3602       }                               int t;
3603       enum List {
3604         ITEM1,                        int method1() {
3605         ITEM2                           // ...
3606       };                              }
3607       template<typename T>
3608       int method2(T x) {              enum List {
3609         // ...                          ITEM1,
3610       }                                 ITEM2
3611       int i, j, k;                    };
3612       int method3(int par) {
3613         // ...                        template<typename T>
3614       }                               int method2(T x) {
3615     };                                  // ...
3616     class C {};                       }
3617     }
3618                                       int i, j, k;
3619
3620                                       int method3(int par) {
3621                                         // ...
3622                                       }
3623                                     };
3624
3625                                     class C {};
3626                                     }
3627
3628  Possible values:
3629
3630  * ``SDS_Leave`` (in configuration: ``Leave``)
3631    Leave definition blocks as they are.
3632
3633  * ``SDS_Always`` (in configuration: ``Always``)
3634    Insert an empty line between definition blocks.
3635
3636  * ``SDS_Never`` (in configuration: ``Never``)
3637    Remove any empty line between definition blocks.
3638
3639
3640
3641**ShortNamespaceLines** (``Unsigned``) :versionbadge:`clang-format 13`
3642  The maximal number of unwrapped lines that a short namespace spans.
3643  Defaults to 1.
3644
3645  This determines the maximum length of short namespaces by counting
3646  unwrapped lines (i.e. containing neither opening nor closing
3647  namespace brace) and makes "FixNamespaceComments" omit adding
3648  end comments for those.
3649
3650  .. code-block:: c++
3651
3652     ShortNamespaceLines: 1     vs.     ShortNamespaceLines: 0
3653     namespace a {                      namespace a {
3654       int foo;                           int foo;
3655     }                                  } // namespace a
3656
3657     ShortNamespaceLines: 1     vs.     ShortNamespaceLines: 0
3658     namespace b {                      namespace b {
3659       int foo;                           int foo;
3660       int bar;                           int bar;
3661     } // namespace b                   } // namespace b
3662
3663**SortIncludes** (``SortIncludesOptions``) :versionbadge:`clang-format 4`
3664  Controls if and how clang-format will sort ``#includes``.
3665  If ``Never``, includes are never sorted.
3666  If ``CaseInsensitive``, includes are sorted in an ASCIIbetical or case
3667  insensitive fashion.
3668  If ``CaseSensitive``, includes are sorted in an alphabetical or case
3669  sensitive fashion.
3670
3671  Possible values:
3672
3673  * ``SI_Never`` (in configuration: ``Never``)
3674    Includes are never sorted.
3675
3676    .. code-block:: c++
3677
3678       #include "B/A.h"
3679       #include "A/B.h"
3680       #include "a/b.h"
3681       #include "A/b.h"
3682       #include "B/a.h"
3683
3684  * ``SI_CaseSensitive`` (in configuration: ``CaseSensitive``)
3685    Includes are sorted in an ASCIIbetical or case sensitive fashion.
3686
3687    .. code-block:: c++
3688
3689       #include "A/B.h"
3690       #include "A/b.h"
3691       #include "B/A.h"
3692       #include "B/a.h"
3693       #include "a/b.h"
3694
3695  * ``SI_CaseInsensitive`` (in configuration: ``CaseInsensitive``)
3696    Includes are sorted in an alphabetical or case insensitive fashion.
3697
3698    .. code-block:: c++
3699
3700       #include "A/B.h"
3701       #include "A/b.h"
3702       #include "a/b.h"
3703       #include "B/A.h"
3704       #include "B/a.h"
3705
3706
3707
3708**SortJavaStaticImport** (``SortJavaStaticImportOptions``) :versionbadge:`clang-format 12`
3709  When sorting Java imports, by default static imports are placed before
3710  non-static imports. If ``JavaStaticImportAfterImport`` is ``After``,
3711  static imports are placed after non-static imports.
3712
3713  Possible values:
3714
3715  * ``SJSIO_Before`` (in configuration: ``Before``)
3716    Static imports are placed before non-static imports.
3717
3718    .. code-block:: java
3719
3720      import static org.example.function1;
3721
3722      import org.example.ClassA;
3723
3724  * ``SJSIO_After`` (in configuration: ``After``)
3725    Static imports are placed after non-static imports.
3726
3727    .. code-block:: java
3728
3729      import org.example.ClassA;
3730
3731      import static org.example.function1;
3732
3733
3734
3735**SortUsingDeclarations** (``Boolean``) :versionbadge:`clang-format 5`
3736  If ``true``, clang-format will sort using declarations.
3737
3738  The order of using declarations is defined as follows:
3739  Split the strings by "::" and discard any initial empty strings. The last
3740  element of each list is a non-namespace name; all others are namespace
3741  names. Sort the lists of names lexicographically, where the sort order of
3742  individual names is that all non-namespace names come before all namespace
3743  names, and within those groups, names are in case-insensitive
3744  lexicographic order.
3745
3746  .. code-block:: c++
3747
3748     false:                                 true:
3749     using std::cout;               vs.     using std::cin;
3750     using std::cin;                        using std::cout;
3751
3752**SpaceAfterCStyleCast** (``Boolean``) :versionbadge:`clang-format 3.5`
3753  If ``true``, a space is inserted after C style casts.
3754
3755  .. code-block:: c++
3756
3757     true:                                  false:
3758     (int) i;                       vs.     (int)i;
3759
3760**SpaceAfterLogicalNot** (``Boolean``) :versionbadge:`clang-format 9`
3761  If ``true``, a space is inserted after the logical not operator (``!``).
3762
3763  .. code-block:: c++
3764
3765     true:                                  false:
3766     ! someExpression();            vs.     !someExpression();
3767
3768**SpaceAfterTemplateKeyword** (``Boolean``) :versionbadge:`clang-format 4`
3769  If ``true``, a space will be inserted after the 'template' keyword.
3770
3771  .. code-block:: c++
3772
3773     true:                                  false:
3774     template <int> void foo();     vs.     template<int> void foo();
3775
3776**SpaceAroundPointerQualifiers** (``SpaceAroundPointerQualifiersStyle``) :versionbadge:`clang-format 12`
3777  Defines in which cases to put a space before or after pointer qualifiers
3778
3779  Possible values:
3780
3781  * ``SAPQ_Default`` (in configuration: ``Default``)
3782    Don't ensure spaces around pointer qualifiers and use PointerAlignment
3783    instead.
3784
3785    .. code-block:: c++
3786
3787       PointerAlignment: Left                 PointerAlignment: Right
3788       void* const* x = NULL;         vs.     void *const *x = NULL;
3789
3790  * ``SAPQ_Before`` (in configuration: ``Before``)
3791    Ensure that there is a space before pointer qualifiers.
3792
3793    .. code-block:: c++
3794
3795       PointerAlignment: Left                 PointerAlignment: Right
3796       void* const* x = NULL;         vs.     void * const *x = NULL;
3797
3798  * ``SAPQ_After`` (in configuration: ``After``)
3799    Ensure that there is a space after pointer qualifiers.
3800
3801    .. code-block:: c++
3802
3803       PointerAlignment: Left                 PointerAlignment: Right
3804       void* const * x = NULL;         vs.     void *const *x = NULL;
3805
3806  * ``SAPQ_Both`` (in configuration: ``Both``)
3807    Ensure that there is a space both before and after pointer qualifiers.
3808
3809    .. code-block:: c++
3810
3811       PointerAlignment: Left                 PointerAlignment: Right
3812       void* const * x = NULL;         vs.     void * const *x = NULL;
3813
3814
3815
3816**SpaceBeforeAssignmentOperators** (``Boolean``) :versionbadge:`clang-format 3.7`
3817  If ``false``, spaces will be removed before assignment operators.
3818
3819  .. code-block:: c++
3820
3821     true:                                  false:
3822     int a = 5;                     vs.     int a= 5;
3823     a += 42;                               a+= 42;
3824
3825**SpaceBeforeCaseColon** (``Boolean``) :versionbadge:`clang-format 12`
3826  If ``false``, spaces will be removed before case colon.
3827
3828  .. code-block:: c++
3829
3830    true:                                   false
3831    switch (x) {                    vs.     switch (x) {
3832      case 1 : break;                         case 1: break;
3833    }                                       }
3834
3835**SpaceBeforeCpp11BracedList** (``Boolean``) :versionbadge:`clang-format 7`
3836  If ``true``, a space will be inserted before a C++11 braced list
3837  used to initialize an object (after the preceding identifier or type).
3838
3839  .. code-block:: c++
3840
3841     true:                                  false:
3842     Foo foo { bar };               vs.     Foo foo{ bar };
3843     Foo {};                                Foo{};
3844     vector<int> { 1, 2, 3 };               vector<int>{ 1, 2, 3 };
3845     new int[3] { 1, 2, 3 };                new int[3]{ 1, 2, 3 };
3846
3847**SpaceBeforeCtorInitializerColon** (``Boolean``) :versionbadge:`clang-format 7`
3848  If ``false``, spaces will be removed before constructor initializer
3849  colon.
3850
3851  .. code-block:: c++
3852
3853     true:                                  false:
3854     Foo::Foo() : a(a) {}                   Foo::Foo(): a(a) {}
3855
3856**SpaceBeforeInheritanceColon** (``Boolean``) :versionbadge:`clang-format 7`
3857  If ``false``, spaces will be removed before inheritance colon.
3858
3859  .. code-block:: c++
3860
3861     true:                                  false:
3862     class Foo : Bar {}             vs.     class Foo: Bar {}
3863
3864**SpaceBeforeParens** (``SpaceBeforeParensStyle``) :versionbadge:`clang-format 3.5`
3865  Defines in which cases to put a space before opening parentheses.
3866
3867  Possible values:
3868
3869  * ``SBPO_Never`` (in configuration: ``Never``)
3870    Never put a space before opening parentheses.
3871
3872    .. code-block:: c++
3873
3874       void f() {
3875         if(true) {
3876           f();
3877         }
3878       }
3879
3880  * ``SBPO_ControlStatements`` (in configuration: ``ControlStatements``)
3881    Put a space before opening parentheses only after control statement
3882    keywords (``for/if/while...``).
3883
3884    .. code-block:: c++
3885
3886       void f() {
3887         if (true) {
3888           f();
3889         }
3890       }
3891
3892  * ``SBPO_ControlStatementsExceptControlMacros`` (in configuration: ``ControlStatementsExceptControlMacros``)
3893    Same as ``SBPO_ControlStatements`` except this option doesn't apply to
3894    ForEach and If macros. This is useful in projects where ForEach/If
3895    macros are treated as function calls instead of control statements.
3896    ``SBPO_ControlStatementsExceptForEachMacros`` remains an alias for
3897    backward compatibility.
3898
3899    .. code-block:: c++
3900
3901       void f() {
3902         Q_FOREACH(...) {
3903           f();
3904         }
3905       }
3906
3907  * ``SBPO_NonEmptyParentheses`` (in configuration: ``NonEmptyParentheses``)
3908    Put a space before opening parentheses only if the parentheses are not
3909    empty i.e. '()'
3910
3911    .. code-block:: c++
3912
3913      void() {
3914        if (true) {
3915          f();
3916          g (x, y, z);
3917        }
3918      }
3919
3920  * ``SBPO_Always`` (in configuration: ``Always``)
3921    Always put a space before opening parentheses, except when it's
3922    prohibited by the syntax rules (in function-like macro definitions) or
3923    when determined by other style rules (after unary operators, opening
3924    parentheses, etc.)
3925
3926    .. code-block:: c++
3927
3928       void f () {
3929         if (true) {
3930           f ();
3931         }
3932       }
3933
3934  * ``SBPO_Custom`` (in configuration: ``Custom``)
3935    Configure each individual space before parentheses in
3936    `SpaceBeforeParensOptions`.
3937
3938
3939
3940**SpaceBeforeParensOptions** (``SpaceBeforeParensCustom``) :versionbadge:`clang-format 14`
3941  Control of individual space before parentheses.
3942
3943  If ``SpaceBeforeParens`` is set to ``Custom``, use this to specify
3944  how each individual space before parentheses case should be handled.
3945  Otherwise, this is ignored.
3946
3947  .. code-block:: yaml
3948
3949    # Example of usage:
3950    SpaceBeforeParens: Custom
3951    SpaceBeforeParensOptions:
3952      AfterControlStatements: true
3953      AfterFunctionDefinitionName: true
3954
3955  Nested configuration flags:
3956
3957
3958  * ``bool AfterControlStatements`` If ``true``, put space betwee control statement keywords
3959    (for/if/while...) and opening parentheses.
3960
3961    .. code-block:: c++
3962
3963       true:                                  false:
3964       if (...) {}                     vs.    if(...) {}
3965
3966  * ``bool AfterForeachMacros`` If ``true``, put space between foreach macros and opening parentheses.
3967
3968    .. code-block:: c++
3969
3970       true:                                  false:
3971       FOREACH (...)                   vs.    FOREACH(...)
3972         <loop-body>                            <loop-body>
3973
3974  * ``bool AfterFunctionDeclarationName`` If ``true``, put a space between function declaration name and opening
3975    parentheses.
3976
3977    .. code-block:: c++
3978
3979       true:                                  false:
3980       void f ();                      vs.    void f();
3981
3982  * ``bool AfterFunctionDefinitionName`` If ``true``, put a space between function definition name and opening
3983    parentheses.
3984
3985    .. code-block:: c++
3986
3987       true:                                  false:
3988       void f () {}                    vs.    void f() {}
3989
3990  * ``bool AfterIfMacros`` If ``true``, put space between if macros and opening parentheses.
3991
3992    .. code-block:: c++
3993
3994       true:                                  false:
3995       IF (...)                        vs.    IF(...)
3996         <conditional-body>                     <conditional-body>
3997
3998  * ``bool AfterOverloadedOperator`` If ``true``, put a space between operator overloading and opening
3999    parentheses.
4000
4001    .. code-block:: c++
4002
4003       true:                                  false:
4004       void operator++ (int a);        vs.    void operator++(int a);
4005       object.operator++ (10);                object.operator++(10);
4006
4007  * ``bool BeforeNonEmptyParentheses`` If ``true``, put a space before opening parentheses only if the
4008    parentheses are not empty.
4009
4010    .. code-block:: c++
4011
4012       true:                                  false:
4013       void f (int a);                 vs.    void f();
4014       f (a);                                 f();
4015
4016
4017**SpaceBeforeRangeBasedForLoopColon** (``Boolean``) :versionbadge:`clang-format 7`
4018  If ``false``, spaces will be removed before range-based for loop
4019  colon.
4020
4021  .. code-block:: c++
4022
4023     true:                                  false:
4024     for (auto v : values) {}       vs.     for(auto v: values) {}
4025
4026**SpaceBeforeSquareBrackets** (``Boolean``) :versionbadge:`clang-format 11`
4027  If ``true``, spaces will be before  ``[``.
4028  Lambdas will not be affected. Only the first ``[`` will get a space added.
4029
4030  .. code-block:: c++
4031
4032     true:                                  false:
4033     int a [5];                    vs.      int a[5];
4034     int a [5][5];                 vs.      int a[5][5];
4035
4036**SpaceInEmptyBlock** (``Boolean``) :versionbadge:`clang-format 11`
4037  If ``true``, spaces will be inserted into ``{}``.
4038
4039  .. code-block:: c++
4040
4041     true:                                false:
4042     void f() { }                   vs.   void f() {}
4043     while (true) { }                     while (true) {}
4044
4045**SpaceInEmptyParentheses** (``Boolean``) :versionbadge:`clang-format 3.7`
4046  If ``true``, spaces may be inserted into ``()``.
4047
4048  .. code-block:: c++
4049
4050     true:                                false:
4051     void f( ) {                    vs.   void f() {
4052       int x[] = {foo( ), bar( )};          int x[] = {foo(), bar()};
4053       if (true) {                          if (true) {
4054         f( );                                f();
4055       }                                    }
4056     }                                    }
4057
4058**SpacesBeforeTrailingComments** (``Unsigned``) :versionbadge:`clang-format 3.7`
4059  The number of spaces before trailing line comments
4060  (``//`` - comments).
4061
4062  This does not affect trailing block comments (``/*`` - comments) as
4063  those commonly have different usage patterns and a number of special
4064  cases.
4065
4066  .. code-block:: c++
4067
4068     SpacesBeforeTrailingComments: 3
4069     void f() {
4070       if (true) {   // foo1
4071         f();        // bar
4072       }             // foo
4073     }
4074
4075**SpacesInAngles** (``SpacesInAnglesStyle``) :versionbadge:`clang-format 3.4`
4076  The SpacesInAnglesStyle to use for template argument lists.
4077
4078  Possible values:
4079
4080  * ``SIAS_Never`` (in configuration: ``Never``)
4081    Remove spaces after ``<`` and before ``>``.
4082
4083    .. code-block:: c++
4084
4085       static_cast<int>(arg);
4086       std::function<void(int)> fct;
4087
4088  * ``SIAS_Always`` (in configuration: ``Always``)
4089    Add spaces after ``<`` and before ``>``.
4090
4091    .. code-block:: c++
4092
4093       static_cast< int >(arg);
4094       std::function< void(int) > fct;
4095
4096  * ``SIAS_Leave`` (in configuration: ``Leave``)
4097    Keep a single space after ``<`` and before ``>`` if any spaces were
4098    present. Option ``Standard: Cpp03`` takes precedence.
4099
4100
4101
4102**SpacesInCStyleCastParentheses** (``Boolean``) :versionbadge:`clang-format 3.7`
4103  If ``true``, spaces may be inserted into C style casts.
4104
4105  .. code-block:: c++
4106
4107     true:                                  false:
4108     x = ( int32 )y                 vs.     x = (int32)y
4109
4110**SpacesInConditionalStatement** (``Boolean``) :versionbadge:`clang-format 11`
4111  If ``true``, spaces will be inserted around if/for/switch/while
4112  conditions.
4113
4114  .. code-block:: c++
4115
4116     true:                                  false:
4117     if ( a )  { ... }              vs.     if (a) { ... }
4118     while ( i < 5 )  { ... }               while (i < 5) { ... }
4119
4120**SpacesInContainerLiterals** (``Boolean``) :versionbadge:`clang-format 3.7`
4121  If ``true``, spaces are inserted inside container literals (e.g.
4122  ObjC and Javascript array and dict literals).
4123
4124  .. code-block:: js
4125
4126     true:                                  false:
4127     var arr = [ 1, 2, 3 ];         vs.     var arr = [1, 2, 3];
4128     f({a : 1, b : 2, c : 3});              f({a: 1, b: 2, c: 3});
4129
4130**SpacesInLineCommentPrefix** (``SpacesInLineComment``) :versionbadge:`clang-format 13`
4131  How many spaces are allowed at the start of a line comment. To disable the
4132  maximum set it to ``-1``, apart from that the maximum takes precedence
4133  over the minimum.
4134
4135  .. code-block:: c++
4136
4137    Minimum = 1
4138    Maximum = -1
4139    // One space is forced
4140
4141    //  but more spaces are possible
4142
4143    Minimum = 0
4144    Maximum = 0
4145    //Forces to start every comment directly after the slashes
4146
4147  Note that in line comment sections the relative indent of the subsequent
4148  lines is kept, that means the following:
4149
4150  .. code-block:: c++
4151
4152    before:                                   after:
4153    Minimum: 1
4154    //if (b) {                                // if (b) {
4155    //  return true;                          //   return true;
4156    //}                                       // }
4157
4158    Maximum: 0
4159    /// List:                                 ///List:
4160    ///  - Foo                                /// - Foo
4161    ///    - Bar                              ///   - Bar
4162
4163  Nested configuration flags:
4164
4165
4166  * ``unsigned Minimum`` The minimum number of spaces at the start of the comment.
4167
4168  * ``unsigned Maximum`` The maximum number of spaces at the start of the comment.
4169
4170
4171**SpacesInParentheses** (``Boolean``) :versionbadge:`clang-format 3.7`
4172  If ``true``, spaces will be inserted after ``(`` and before ``)``.
4173
4174  .. code-block:: c++
4175
4176     true:                                  false:
4177     t f( Deleted & ) & = delete;   vs.     t f(Deleted &) & = delete;
4178
4179**SpacesInSquareBrackets** (``Boolean``) :versionbadge:`clang-format 3.7`
4180  If ``true``, spaces will be inserted after ``[`` and before ``]``.
4181  Lambdas without arguments or unspecified size array declarations will not
4182  be affected.
4183
4184  .. code-block:: c++
4185
4186     true:                                  false:
4187     int a[ 5 ];                    vs.     int a[5];
4188     std::unique_ptr<int[]> foo() {} // Won't be affected
4189
4190**Standard** (``LanguageStandard``) :versionbadge:`clang-format 3.7`
4191  Parse and format C++ constructs compatible with this standard.
4192
4193  .. code-block:: c++
4194
4195     c++03:                                 latest:
4196     vector<set<int> > x;           vs.     vector<set<int>> x;
4197
4198  Possible values:
4199
4200  * ``LS_Cpp03`` (in configuration: ``c++03``)
4201    Parse and format as C++03.
4202    ``Cpp03`` is a deprecated alias for ``c++03``
4203
4204  * ``LS_Cpp11`` (in configuration: ``c++11``)
4205    Parse and format as C++11.
4206
4207  * ``LS_Cpp14`` (in configuration: ``c++14``)
4208    Parse and format as C++14.
4209
4210  * ``LS_Cpp17`` (in configuration: ``c++17``)
4211    Parse and format as C++17.
4212
4213  * ``LS_Cpp20`` (in configuration: ``c++20``)
4214    Parse and format as C++20.
4215
4216  * ``LS_Latest`` (in configuration: ``Latest``)
4217    Parse and format using the latest supported language version.
4218    ``Cpp11`` is a deprecated alias for ``Latest``
4219
4220  * ``LS_Auto`` (in configuration: ``Auto``)
4221    Automatic detection based on the input.
4222
4223
4224
4225**StatementAttributeLikeMacros** (``List of Strings``) :versionbadge:`clang-format 12`
4226  Macros which are ignored in front of a statement, as if they were an
4227  attribute. So that they are not parsed as identifier, for example for Qts
4228  emit.
4229
4230  .. code-block:: c++
4231
4232    AlignConsecutiveDeclarations: true
4233    StatementAttributeLikeMacros: []
4234    unsigned char data = 'x';
4235    emit          signal(data); // This is parsed as variable declaration.
4236
4237    AlignConsecutiveDeclarations: true
4238    StatementAttributeLikeMacros: [emit]
4239    unsigned char data = 'x';
4240    emit signal(data); // Now it's fine again.
4241
4242**StatementMacros** (``List of Strings``) :versionbadge:`clang-format 8`
4243  A vector of macros that should be interpreted as complete
4244  statements.
4245
4246  Typical macros are expressions, and require a semi-colon to be
4247  added; sometimes this is not the case, and this allows to make
4248  clang-format aware of such cases.
4249
4250  For example: Q_UNUSED
4251
4252**TabWidth** (``Unsigned``) :versionbadge:`clang-format 3.7`
4253  The number of columns used for tab stops.
4254
4255**TypenameMacros** (``List of Strings``) :versionbadge:`clang-format 9`
4256  A vector of macros that should be interpreted as type declarations
4257  instead of as function calls.
4258
4259  These are expected to be macros of the form:
4260
4261  .. code-block:: c++
4262
4263    STACK_OF(...)
4264
4265  In the .clang-format configuration file, this can be configured like:
4266
4267  .. code-block:: yaml
4268
4269    TypenameMacros: ['STACK_OF', 'LIST']
4270
4271  For example: OpenSSL STACK_OF, BSD LIST_ENTRY.
4272
4273**UseCRLF** (``Boolean``) :versionbadge:`clang-format 11`
4274  Use ``\r\n`` instead of ``\n`` for line breaks.
4275  Also used as fallback if ``DeriveLineEnding`` is true.
4276
4277**UseTab** (``UseTabStyle``) :versionbadge:`clang-format 3.7`
4278  The way to use tab characters in the resulting file.
4279
4280  Possible values:
4281
4282  * ``UT_Never`` (in configuration: ``Never``)
4283    Never use tab.
4284
4285  * ``UT_ForIndentation`` (in configuration: ``ForIndentation``)
4286    Use tabs only for indentation.
4287
4288  * ``UT_ForContinuationAndIndentation`` (in configuration: ``ForContinuationAndIndentation``)
4289    Fill all leading whitespace with tabs, and use spaces for alignment that
4290    appears within a line (e.g. consecutive assignments and declarations).
4291
4292  * ``UT_AlignWithSpaces`` (in configuration: ``AlignWithSpaces``)
4293    Use tabs for line continuation and indentation, and spaces for
4294    alignment.
4295
4296  * ``UT_Always`` (in configuration: ``Always``)
4297    Use tabs whenever we need to fill whitespace that spans at least from
4298    one tab stop to the next one.
4299
4300
4301
4302**WhitespaceSensitiveMacros** (``List of Strings``) :versionbadge:`clang-format 12`
4303  A vector of macros which are whitespace-sensitive and should not
4304  be touched.
4305
4306  These are expected to be macros of the form:
4307
4308  .. code-block:: c++
4309
4310    STRINGIZE(...)
4311
4312  In the .clang-format configuration file, this can be configured like:
4313
4314  .. code-block:: yaml
4315
4316    WhitespaceSensitiveMacros: ['STRINGIZE', 'PP_STRINGIZE']
4317
4318  For example: BOOST_PP_STRINGIZE
4319
4320.. END_FORMAT_STYLE_OPTIONS
4321
4322Adding additional style options
4323===============================
4324
4325Each additional style option adds costs to the clang-format project. Some of
4326these costs affect the clang-format development itself, as we need to make
4327sure that any given combination of options work and that new features don't
4328break any of the existing options in any way. There are also costs for end users
4329as options become less discoverable and people have to think about and make a
4330decision on options they don't really care about.
4331
4332The goal of the clang-format project is more on the side of supporting a
4333limited set of styles really well as opposed to supporting every single style
4334used by a codebase somewhere in the wild. Of course, we do want to support all
4335major projects and thus have established the following bar for adding style
4336options. Each new style option must ..
4337
4338  * be used in a project of significant size (have dozens of contributors)
4339  * have a publicly accessible style guide
4340  * have a person willing to contribute and maintain patches
4341
4342Examples
4343========
4344
4345A style similar to the `Linux Kernel style
4346<https://www.kernel.org/doc/Documentation/CodingStyle>`_:
4347
4348.. code-block:: yaml
4349
4350  BasedOnStyle: LLVM
4351  IndentWidth: 8
4352  UseTab: Always
4353  BreakBeforeBraces: Linux
4354  AllowShortIfStatementsOnASingleLine: false
4355  IndentCaseLabels: false
4356
4357The result is (imagine that tabs are used for indentation here):
4358
4359.. code-block:: c++
4360
4361  void test()
4362  {
4363          switch (x) {
4364          case 0:
4365          case 1:
4366                  do_something();
4367                  break;
4368          case 2:
4369                  do_something_else();
4370                  break;
4371          default:
4372                  break;
4373          }
4374          if (condition)
4375                  do_something_completely_different();
4376
4377          if (x == y) {
4378                  q();
4379          } else if (x > y) {
4380                  w();
4381          } else {
4382                  r();
4383          }
4384  }
4385
4386A style similar to the default Visual Studio formatting style:
4387
4388.. code-block:: yaml
4389
4390  UseTab: Never
4391  IndentWidth: 4
4392  BreakBeforeBraces: Allman
4393  AllowShortIfStatementsOnASingleLine: false
4394  IndentCaseLabels: false
4395  ColumnLimit: 0
4396
4397The result is:
4398
4399.. code-block:: c++
4400
4401  void test()
4402  {
4403      switch (suffix)
4404      {
4405      case 0:
4406      case 1:
4407          do_something();
4408          break;
4409      case 2:
4410          do_something_else();
4411          break;
4412      default:
4413          break;
4414      }
4415      if (condition)
4416          do_something_completely_different();
4417
4418      if (x == y)
4419      {
4420          q();
4421      }
4422      else if (x > y)
4423      {
4424          w();
4425      }
4426      else
4427      {
4428          r();
4429      }
4430  }
4431