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