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