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