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