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