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