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