xref: /freebsd/contrib/llvm-project/clang/include/clang/Format/Format.h (revision e64bea71c21eb42e97aa615188ba91f6cce0d36d)
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     /// \note
96     ///  This currently only applies to braced initializer lists (when
97     ///  ``Cpp11BracedListStyle`` is ``true``) and parentheses.
98     /// \endnote
99     BAS_BlockIndent,
100   };
101 
102   /// If ``true``, horizontally aligns arguments after an open bracket.
103   ///
104   /// This applies to round brackets (parentheses), angle brackets and square
105   /// brackets.
106   /// \version 3.8
107   BracketAlignmentStyle AlignAfterOpenBracket;
108 
109   /// Different style for aligning array initializers.
110   enum ArrayInitializerAlignmentStyle : int8_t {
111     /// Align array column and left justify the columns e.g.:
112     /// \code
113     ///   struct test demo[] =
114     ///   {
115     ///       {56, 23,    "hello"},
116     ///       {-1, 93463, "world"},
117     ///       {7,  5,     "!!"   }
118     ///   };
119     /// \endcode
120     AIAS_Left,
121     /// Align array column and right justify the columns e.g.:
122     /// \code
123     ///   struct test demo[] =
124     ///   {
125     ///       {56,    23, "hello"},
126     ///       {-1, 93463, "world"},
127     ///       { 7,     5,    "!!"}
128     ///   };
129     /// \endcode
130     AIAS_Right,
131     /// Don't align array initializer columns.
132     AIAS_None
133   };
134   /// If not ``None``, when using initialization for an array of structs
135   /// aligns the fields into columns.
136   ///
137   /// \note
138   ///  As of clang-format 15 this option only applied to arrays with equal
139   ///  number of columns per row.
140   /// \endnote
141   ///
142   /// \version 13
143   ArrayInitializerAlignmentStyle AlignArrayOfStructures;
144 
145   /// Alignment options.
146   ///
147   /// They can also be read as a whole for compatibility. The choices are:
148   ///
149   /// * ``None``
150   /// * ``Consecutive``
151   /// * ``AcrossEmptyLines``
152   /// * ``AcrossComments``
153   /// * ``AcrossEmptyLinesAndComments``
154   ///
155   /// For example, to align across empty lines and not across comments, either
156   /// of these work.
157   /// \code
158   ///   <option-name>: AcrossEmptyLines
159   ///
160   ///   <option-name>:
161   ///     Enabled: true
162   ///     AcrossEmptyLines: true
163   ///     AcrossComments: false
164   /// \endcode
165   struct AlignConsecutiveStyle {
166     /// Whether aligning is enabled.
167     /// \code
168     ///   #define SHORT_NAME       42
169     ///   #define LONGER_NAME      0x007f
170     ///   #define EVEN_LONGER_NAME (2)
171     ///   #define foo(x)           (x * x)
172     ///   #define bar(y, z)        (y + z)
173     ///
174     ///   int a            = 1;
175     ///   int somelongname = 2;
176     ///   double c         = 3;
177     ///
178     ///   int aaaa : 1;
179     ///   int b    : 12;
180     ///   int ccc  : 8;
181     ///
182     ///   int         aaaa = 12;
183     ///   float       b = 23;
184     ///   std::string ccc;
185     /// \endcode
186     bool Enabled;
187     /// Whether to align across empty lines.
188     /// \code
189     ///   true:
190     ///   int a            = 1;
191     ///   int somelongname = 2;
192     ///   double c         = 3;
193     ///
194     ///   int d            = 3;
195     ///
196     ///   false:
197     ///   int a            = 1;
198     ///   int somelongname = 2;
199     ///   double c         = 3;
200     ///
201     ///   int d = 3;
202     /// \endcode
203     bool AcrossEmptyLines;
204     /// Whether to align across comments.
205     /// \code
206     ///   true:
207     ///   int d    = 3;
208     ///   /* A comment. */
209     ///   double e = 4;
210     ///
211     ///   false:
212     ///   int d = 3;
213     ///   /* A comment. */
214     ///   double e = 4;
215     /// \endcode
216     bool AcrossComments;
217     /// Only for ``AlignConsecutiveAssignments``.  Whether compound assignments
218     /// like ``+=`` are aligned along with ``=``.
219     /// \code
220     ///   true:
221     ///   a   &= 2;
222     ///   bbb  = 2;
223     ///
224     ///   false:
225     ///   a &= 2;
226     ///   bbb = 2;
227     /// \endcode
228     bool AlignCompound;
229     /// Only for ``AlignConsecutiveDeclarations``. Whether function declarations
230     /// are aligned.
231     /// \code
232     ///   true:
233     ///   unsigned int f1(void);
234     ///   void         f2(void);
235     ///   size_t       f3(void);
236     ///
237     ///   false:
238     ///   unsigned int f1(void);
239     ///   void f2(void);
240     ///   size_t f3(void);
241     /// \endcode
242     bool AlignFunctionDeclarations;
243     /// Only for ``AlignConsecutiveDeclarations``. Whether function pointers are
244     /// aligned.
245     /// \code
246     ///   true:
247     ///   unsigned i;
248     ///   int     &r;
249     ///   int     *p;
250     ///   int      (*f)();
251     ///
252     ///   false:
253     ///   unsigned i;
254     ///   int     &r;
255     ///   int     *p;
256     ///   int (*f)();
257     /// \endcode
258     bool AlignFunctionPointers;
259     /// Only for ``AlignConsecutiveAssignments``.  Whether short assignment
260     /// operators are left-padded to the same length as long ones in order to
261     /// put all assignment operators to the right of the left hand side.
262     /// \code
263     ///   true:
264     ///   a   >>= 2;
265     ///   bbb   = 2;
266     ///
267     ///   a     = 2;
268     ///   bbb >>= 2;
269     ///
270     ///   false:
271     ///   a >>= 2;
272     ///   bbb = 2;
273     ///
274     ///   a     = 2;
275     ///   bbb >>= 2;
276     /// \endcode
277     bool PadOperators;
278     bool operator==(const AlignConsecutiveStyle &R) const {
279       return Enabled == R.Enabled && AcrossEmptyLines == R.AcrossEmptyLines &&
280              AcrossComments == R.AcrossComments &&
281              AlignCompound == R.AlignCompound &&
282              AlignFunctionDeclarations == R.AlignFunctionDeclarations &&
283              AlignFunctionPointers == R.AlignFunctionPointers &&
284              PadOperators == R.PadOperators;
285     }
286     bool operator!=(const AlignConsecutiveStyle &R) const {
287       return !(*this == R);
288     }
289   };
290 
291   /// Style of aligning consecutive macro definitions.
292   ///
293   /// ``Consecutive`` will result in formattings like:
294   /// \code
295   ///   #define SHORT_NAME       42
296   ///   #define LONGER_NAME      0x007f
297   ///   #define EVEN_LONGER_NAME (2)
298   ///   #define foo(x)           (x * x)
299   ///   #define bar(y, z)        (y + z)
300   /// \endcode
301   /// \version 9
302   AlignConsecutiveStyle AlignConsecutiveMacros;
303   /// Style of aligning consecutive assignments.
304   ///
305   /// ``Consecutive`` will result in formattings like:
306   /// \code
307   ///   int a            = 1;
308   ///   int somelongname = 2;
309   ///   double c         = 3;
310   /// \endcode
311   /// \version 3.8
312   AlignConsecutiveStyle AlignConsecutiveAssignments;
313   /// Style of aligning consecutive bit fields.
314   ///
315   /// ``Consecutive`` will align the bitfield separators of consecutive lines.
316   /// This will result in formattings like:
317   /// \code
318   ///   int aaaa : 1;
319   ///   int b    : 12;
320   ///   int ccc  : 8;
321   /// \endcode
322   /// \version 11
323   AlignConsecutiveStyle AlignConsecutiveBitFields;
324   /// Style of aligning consecutive declarations.
325   ///
326   /// ``Consecutive`` will align the declaration names of consecutive lines.
327   /// This will result in formattings like:
328   /// \code
329   ///   int         aaaa = 12;
330   ///   float       b = 23;
331   ///   std::string ccc;
332   /// \endcode
333   /// \version 3.8
334   AlignConsecutiveStyle AlignConsecutiveDeclarations;
335 
336   /// Alignment options.
337   ///
338   struct ShortCaseStatementsAlignmentStyle {
339     /// Whether aligning is enabled.
340     /// \code
341     ///   true:
342     ///   switch (level) {
343     ///   case log::info:    return "info:";
344     ///   case log::warning: return "warning:";
345     ///   default:           return "";
346     ///   }
347     ///
348     ///   false:
349     ///   switch (level) {
350     ///   case log::info: return "info:";
351     ///   case log::warning: return "warning:";
352     ///   default: return "";
353     ///   }
354     /// \endcode
355     bool Enabled;
356     /// Whether to align across empty lines.
357     /// \code
358     ///   true:
359     ///   switch (level) {
360     ///   case log::info:    return "info:";
361     ///   case log::warning: return "warning:";
362     ///
363     ///   default:           return "";
364     ///   }
365     ///
366     ///   false:
367     ///   switch (level) {
368     ///   case log::info:    return "info:";
369     ///   case log::warning: return "warning:";
370     ///
371     ///   default: return "";
372     ///   }
373     /// \endcode
374     bool AcrossEmptyLines;
375     /// Whether to align across comments.
376     /// \code
377     ///   true:
378     ///   switch (level) {
379     ///   case log::info:    return "info:";
380     ///   case log::warning: return "warning:";
381     ///   /* A comment. */
382     ///   default:           return "";
383     ///   }
384     ///
385     ///   false:
386     ///   switch (level) {
387     ///   case log::info:    return "info:";
388     ///   case log::warning: return "warning:";
389     ///   /* A comment. */
390     ///   default: return "";
391     ///   }
392     /// \endcode
393     bool AcrossComments;
394     /// Whether to align the case arrows when aligning short case expressions.
395     /// \code{.java}
396     ///   true:
397     ///   i = switch (day) {
398     ///     case THURSDAY, SATURDAY -> 8;
399     ///     case WEDNESDAY          -> 9;
400     ///     default                 -> 0;
401     ///   };
402     ///
403     ///   false:
404     ///   i = switch (day) {
405     ///     case THURSDAY, SATURDAY -> 8;
406     ///     case WEDNESDAY ->          9;
407     ///     default ->                 0;
408     ///   };
409     /// \endcode
410     bool AlignCaseArrows;
411     /// Whether aligned case labels are aligned on the colon, or on the tokens
412     /// after the colon.
413     /// \code
414     ///   true:
415     ///   switch (level) {
416     ///   case log::info   : return "info:";
417     ///   case log::warning: return "warning:";
418     ///   default          : return "";
419     ///   }
420     ///
421     ///   false:
422     ///   switch (level) {
423     ///   case log::info:    return "info:";
424     ///   case log::warning: return "warning:";
425     ///   default:           return "";
426     ///   }
427     /// \endcode
428     bool AlignCaseColons;
429     bool operator==(const ShortCaseStatementsAlignmentStyle &R) const {
430       return Enabled == R.Enabled && AcrossEmptyLines == R.AcrossEmptyLines &&
431              AcrossComments == R.AcrossComments &&
432              AlignCaseArrows == R.AlignCaseArrows &&
433              AlignCaseColons == R.AlignCaseColons;
434     }
435   };
436 
437   /// Style of aligning consecutive short case labels.
438   /// Only applies if ``AllowShortCaseExpressionOnASingleLine`` or
439   /// ``AllowShortCaseLabelsOnASingleLine`` is ``true``.
440   ///
441   /// \code{.yaml}
442   ///   # Example of usage:
443   ///   AlignConsecutiveShortCaseStatements:
444   ///     Enabled: true
445   ///     AcrossEmptyLines: true
446   ///     AcrossComments: true
447   ///     AlignCaseColons: false
448   /// \endcode
449   /// \version 17
450   ShortCaseStatementsAlignmentStyle AlignConsecutiveShortCaseStatements;
451 
452   /// Style of aligning consecutive TableGen DAGArg operator colons.
453   /// If enabled, align the colon inside DAGArg which have line break inside.
454   /// This works only when TableGenBreakInsideDAGArg is BreakElements or
455   /// BreakAll and the DAGArg is not excepted by
456   /// TableGenBreakingDAGArgOperators's effect.
457   /// \code
458   ///   let dagarg = (ins
459   ///       a  :$src1,
460   ///       aa :$src2,
461   ///       aaa:$src3
462   ///   )
463   /// \endcode
464   /// \version 19
465   AlignConsecutiveStyle AlignConsecutiveTableGenBreakingDAGArgColons;
466 
467   /// Style of aligning consecutive TableGen cond operator colons.
468   /// Align the colons of cases inside !cond operators.
469   /// \code
470   ///   !cond(!eq(size, 1) : 1,
471   ///         !eq(size, 16): 1,
472   ///         true         : 0)
473   /// \endcode
474   /// \version 19
475   AlignConsecutiveStyle AlignConsecutiveTableGenCondOperatorColons;
476 
477   /// Style of aligning consecutive TableGen definition colons.
478   /// This aligns the inheritance colons of consecutive definitions.
479   /// \code
480   ///   def Def       : Parent {}
481   ///   def DefDef    : Parent {}
482   ///   def DefDefDef : Parent {}
483   /// \endcode
484   /// \version 19
485   AlignConsecutiveStyle AlignConsecutiveTableGenDefinitionColons;
486 
487   /// Different styles for aligning escaped newlines.
488   enum EscapedNewlineAlignmentStyle : int8_t {
489     /// Don't align escaped newlines.
490     /// \code
491     ///   #define A \
492     ///     int aaaa; \
493     ///     int b; \
494     ///     int dddddddddd;
495     /// \endcode
496     ENAS_DontAlign,
497     /// Align escaped newlines as far left as possible.
498     /// \code
499     ///   #define A   \
500     ///     int aaaa; \
501     ///     int b;    \
502     ///     int dddddddddd;
503     /// \endcode
504     ENAS_Left,
505     /// Align escaped newlines as far left as possible, using the last line of
506     /// the preprocessor directive as the reference if it's the longest.
507     /// \code
508     ///   #define A         \
509     ///     int aaaa;       \
510     ///     int b;          \
511     ///     int dddddddddd;
512     /// \endcode
513     ENAS_LeftWithLastLine,
514     /// Align escaped newlines in the right-most column.
515     /// \code
516     ///   #define A                                                            \
517     ///     int aaaa;                                                          \
518     ///     int b;                                                             \
519     ///     int dddddddddd;
520     /// \endcode
521     ENAS_Right,
522   };
523 
524   /// Options for aligning backslashes in escaped newlines.
525   /// \version 5
526   EscapedNewlineAlignmentStyle AlignEscapedNewlines;
527 
528   /// Different styles for aligning operands.
529   enum OperandAlignmentStyle : int8_t {
530     /// Do not align operands of binary and ternary expressions.
531     /// The wrapped lines are indented ``ContinuationIndentWidth`` spaces from
532     /// the start of the line.
533     OAS_DontAlign,
534     /// Horizontally align operands of binary and ternary expressions.
535     ///
536     /// Specifically, this aligns operands of a single expression that needs
537     /// to be split over multiple lines, e.g.:
538     /// \code
539     ///   int aaa = bbbbbbbbbbbbbbb +
540     ///             ccccccccccccccc;
541     /// \endcode
542     ///
543     /// When ``BreakBeforeBinaryOperators`` is set, the wrapped operator is
544     /// aligned with the operand on the first line.
545     /// \code
546     ///   int aaa = bbbbbbbbbbbbbbb
547     ///             + ccccccccccccccc;
548     /// \endcode
549     OAS_Align,
550     /// Horizontally align operands of binary and ternary expressions.
551     ///
552     /// This is similar to ``OAS_Align``, except when
553     /// ``BreakBeforeBinaryOperators`` is set, the operator is un-indented so
554     /// that the wrapped operand is aligned with the operand on the first line.
555     /// \code
556     ///   int aaa = bbbbbbbbbbbbbbb
557     ///           + ccccccccccccccc;
558     /// \endcode
559     OAS_AlignAfterOperator,
560   };
561 
562   /// If ``true``, horizontally align operands of binary and ternary
563   /// expressions.
564   /// \version 3.5
565   OperandAlignmentStyle AlignOperands;
566 
567   /// Enums for AlignTrailingComments
568   enum TrailingCommentsAlignmentKinds : int8_t {
569     /// Leave trailing comments as they are.
570     /// \code
571     ///   int a;    // comment
572     ///   int ab;       // comment
573     ///
574     ///   int abc;  // comment
575     ///   int abcd;     // comment
576     /// \endcode
577     TCAS_Leave,
578     /// Align trailing comments.
579     /// \code
580     ///   int a;  // comment
581     ///   int ab; // comment
582     ///
583     ///   int abc;  // comment
584     ///   int abcd; // comment
585     /// \endcode
586     TCAS_Always,
587     /// Don't align trailing comments but other formatter applies.
588     /// \code
589     ///   int a; // comment
590     ///   int ab; // comment
591     ///
592     ///   int abc; // comment
593     ///   int abcd; // comment
594     /// \endcode
595     TCAS_Never,
596   };
597 
598   /// Alignment options
599   struct TrailingCommentsAlignmentStyle {
600     /// Specifies the way to align trailing comments.
601     TrailingCommentsAlignmentKinds Kind;
602     /// How many empty lines to apply alignment.
603     /// When both ``MaxEmptyLinesToKeep`` and ``OverEmptyLines`` are set to 2,
604     /// it formats like below.
605     /// \code
606     ///   int a;      // all these
607     ///
608     ///   int ab;     // comments are
609     ///
610     ///
611     ///   int abcdef; // aligned
612     /// \endcode
613     ///
614     /// When ``MaxEmptyLinesToKeep`` is set to 2 and ``OverEmptyLines`` is set
615     /// to 1, it formats like below.
616     /// \code
617     ///   int a;  // these are
618     ///
619     ///   int ab; // aligned
620     ///
621     ///
622     ///   int abcdef; // but this isn't
623     /// \endcode
624     unsigned OverEmptyLines;
625 
626     bool operator==(const TrailingCommentsAlignmentStyle &R) const {
627       return Kind == R.Kind && OverEmptyLines == R.OverEmptyLines;
628     }
629     bool operator!=(const TrailingCommentsAlignmentStyle &R) const {
630       return !(*this == R);
631     }
632   };
633 
634   /// Control of trailing comments.
635   ///
636   /// The alignment stops at closing braces after a line break, and only
637   /// followed by other closing braces, a (``do-``) ``while``, a lambda call, or
638   /// a semicolon.
639   ///
640   /// \note
641   ///  As of clang-format 16 this option is not a bool but can be set
642   ///  to the options. Conventional bool options still can be parsed as before.
643   /// \endnote
644   ///
645   /// \code{.yaml}
646   ///   # Example of usage:
647   ///   AlignTrailingComments:
648   ///     Kind: Always
649   ///     OverEmptyLines: 2
650   /// \endcode
651   /// \version 3.7
652   TrailingCommentsAlignmentStyle AlignTrailingComments;
653 
654   /// If a function call or braced initializer list doesn't fit on a line, allow
655   /// putting all arguments onto the next line, even if ``BinPackArguments`` is
656   /// ``false``.
657   /// \code
658   ///   true:
659   ///   callFunction(
660   ///       a, b, c, d);
661   ///
662   ///   false:
663   ///   callFunction(a,
664   ///                b,
665   ///                c,
666   ///                d);
667   /// \endcode
668   /// \version 9
669   bool AllowAllArgumentsOnNextLine;
670 
671   /// This option is **deprecated**. See ``NextLine`` of
672   /// ``PackConstructorInitializers``.
673   /// \version 9
674   // bool AllowAllConstructorInitializersOnNextLine;
675 
676   /// If the function declaration doesn't fit on a line,
677   /// allow putting all parameters of a function declaration onto
678   /// the next line even if ``BinPackParameters`` is ``OnePerLine``.
679   /// \code
680   ///   true:
681   ///   void myFunction(
682   ///       int a, int b, int c, int d, int e);
683   ///
684   ///   false:
685   ///   void myFunction(int a,
686   ///                   int b,
687   ///                   int c,
688   ///                   int d,
689   ///                   int e);
690   /// \endcode
691   /// \version 3.3
692   bool AllowAllParametersOfDeclarationOnNextLine;
693 
694   /// Different ways to break before a noexcept specifier.
695   enum BreakBeforeNoexceptSpecifierStyle : int8_t {
696     /// No line break allowed.
697     /// \code
698     ///   void foo(int arg1,
699     ///            double arg2) noexcept;
700     ///
701     ///   void bar(int arg1, double arg2) noexcept(
702     ///       noexcept(baz(arg1)) &&
703     ///       noexcept(baz(arg2)));
704     /// \endcode
705     BBNSS_Never,
706     /// For a simple ``noexcept`` there is no line break allowed, but when we
707     /// have a condition it is.
708     /// \code
709     ///   void foo(int arg1,
710     ///            double arg2) noexcept;
711     ///
712     ///   void bar(int arg1, double arg2)
713     ///       noexcept(noexcept(baz(arg1)) &&
714     ///                noexcept(baz(arg2)));
715     /// \endcode
716     BBNSS_OnlyWithParen,
717     /// Line breaks are allowed. But note that because of the associated
718     /// penalties ``clang-format`` often prefers not to break before the
719     /// ``noexcept``.
720     /// \code
721     ///   void foo(int arg1,
722     ///            double arg2) noexcept;
723     ///
724     ///   void bar(int arg1, double arg2)
725     ///       noexcept(noexcept(baz(arg1)) &&
726     ///                noexcept(baz(arg2)));
727     /// \endcode
728     BBNSS_Always,
729   };
730 
731   /// Controls if there could be a line break before a ``noexcept`` specifier.
732   /// \version 18
733   BreakBeforeNoexceptSpecifierStyle AllowBreakBeforeNoexceptSpecifier;
734 
735   /// Different styles for merging short blocks containing at most one
736   /// statement.
737   enum ShortBlockStyle : int8_t {
738     /// Never merge blocks into a single line.
739     /// \code
740     ///   while (true) {
741     ///   }
742     ///   while (true) {
743     ///     continue;
744     ///   }
745     /// \endcode
746     SBS_Never,
747     /// Only merge empty blocks.
748     /// \code
749     ///   while (true) {}
750     ///   while (true) {
751     ///     continue;
752     ///   }
753     /// \endcode
754     SBS_Empty,
755     /// Always merge short blocks into a single line.
756     /// \code
757     ///   while (true) {}
758     ///   while (true) { continue; }
759     /// \endcode
760     SBS_Always,
761   };
762 
763   /// Dependent on the value, ``while (true) { continue; }`` can be put on a
764   /// single line.
765   /// \version 3.5
766   ShortBlockStyle AllowShortBlocksOnASingleLine;
767 
768   /// Whether to merge a short switch labeled rule into a single line.
769   /// \code{.java}
770   ///   true:                               false:
771   ///   switch (a) {           vs.          switch (a) {
772   ///   case 1 -> 1;                        case 1 ->
773   ///   default -> 0;                         1;
774   ///   };                                  default ->
775   ///                                         0;
776   ///                                       };
777   /// \endcode
778   /// \version 19
779   bool AllowShortCaseExpressionOnASingleLine;
780 
781   /// If ``true``, short case labels will be contracted to a single line.
782   /// \code
783   ///   true:                                   false:
784   ///   switch (a) {                    vs.     switch (a) {
785   ///   case 1: x = 1; break;                   case 1:
786   ///   case 2: return;                           x = 1;
787   ///   }                                         break;
788   ///                                           case 2:
789   ///                                             return;
790   ///                                           }
791   /// \endcode
792   /// \version 3.6
793   bool AllowShortCaseLabelsOnASingleLine;
794 
795   /// Allow short compound requirement on a single line.
796   /// \code
797   ///   true:
798   ///   template <typename T>
799   ///   concept c = requires(T x) {
800   ///     { x + 1 } -> std::same_as<int>;
801   ///   };
802   ///
803   ///   false:
804   ///   template <typename T>
805   ///   concept c = requires(T x) {
806   ///     {
807   ///       x + 1
808   ///     } -> std::same_as<int>;
809   ///   };
810   /// \endcode
811   /// \version 18
812   bool AllowShortCompoundRequirementOnASingleLine;
813 
814   /// Allow short enums on a single line.
815   /// \code
816   ///   true:
817   ///   enum { A, B } myEnum;
818   ///
819   ///   false:
820   ///   enum {
821   ///     A,
822   ///     B
823   ///   } myEnum;
824   /// \endcode
825   /// \version 11
826   bool AllowShortEnumsOnASingleLine;
827 
828   /// Different styles for merging short functions containing at most one
829   /// statement.
830   enum ShortFunctionStyle : int8_t {
831     /// Never merge functions into a single line.
832     SFS_None,
833     /// Only merge functions defined inside a class. Same as ``inline``,
834     /// except it does not implies ``empty``: i.e. top level empty functions
835     /// are not merged either.
836     /// \code
837     ///   class Foo {
838     ///     void f() { foo(); }
839     ///   };
840     ///   void f() {
841     ///     foo();
842     ///   }
843     ///   void f() {
844     ///   }
845     /// \endcode
846     SFS_InlineOnly,
847     /// Only merge empty functions.
848     /// \code
849     ///   void f() {}
850     ///   void f2() {
851     ///     bar2();
852     ///   }
853     /// \endcode
854     SFS_Empty,
855     /// Only merge functions defined inside a class. Implies ``empty``.
856     /// \code
857     ///   class Foo {
858     ///     void f() { foo(); }
859     ///   };
860     ///   void f() {
861     ///     foo();
862     ///   }
863     ///   void f() {}
864     /// \endcode
865     SFS_Inline,
866     /// Merge all functions fitting on a single line.
867     /// \code
868     ///   class Foo {
869     ///     void f() { foo(); }
870     ///   };
871     ///   void f() { bar(); }
872     /// \endcode
873     SFS_All,
874   };
875 
876   /// Dependent on the value, ``int f() { return 0; }`` can be put on a
877   /// single line.
878   /// \version 3.5
879   ShortFunctionStyle AllowShortFunctionsOnASingleLine;
880 
881   /// Different styles for handling short if statements.
882   enum ShortIfStyle : int8_t {
883     /// Never put short ifs on the same line.
884     /// \code
885     ///   if (a)
886     ///     return;
887     ///
888     ///   if (b)
889     ///     return;
890     ///   else
891     ///     return;
892     ///
893     ///   if (c)
894     ///     return;
895     ///   else {
896     ///     return;
897     ///   }
898     /// \endcode
899     SIS_Never,
900     /// Put short ifs on the same line only if there is no else statement.
901     /// \code
902     ///   if (a) return;
903     ///
904     ///   if (b)
905     ///     return;
906     ///   else
907     ///     return;
908     ///
909     ///   if (c)
910     ///     return;
911     ///   else {
912     ///     return;
913     ///   }
914     /// \endcode
915     SIS_WithoutElse,
916     /// Put short ifs, but not else ifs nor else statements, on the same line.
917     /// \code
918     ///   if (a) return;
919     ///
920     ///   if (b) return;
921     ///   else if (b)
922     ///     return;
923     ///   else
924     ///     return;
925     ///
926     ///   if (c) return;
927     ///   else {
928     ///     return;
929     ///   }
930     /// \endcode
931     SIS_OnlyFirstIf,
932     /// Always put short ifs, else ifs and else statements on the same
933     /// line.
934     /// \code
935     ///   if (a) return;
936     ///
937     ///   if (b) return;
938     ///   else return;
939     ///
940     ///   if (c) return;
941     ///   else {
942     ///     return;
943     ///   }
944     /// \endcode
945     SIS_AllIfsAndElse,
946   };
947 
948   /// Dependent on the value, ``if (a) return;`` can be put on a single line.
949   /// \version 3.3
950   ShortIfStyle AllowShortIfStatementsOnASingleLine;
951 
952   /// Different styles for merging short lambdas containing at most one
953   /// statement.
954   enum ShortLambdaStyle : int8_t {
955     /// Never merge lambdas into a single line.
956     SLS_None,
957     /// Only merge empty lambdas.
958     /// \code
959     ///   auto lambda = [](int a) {};
960     ///   auto lambda2 = [](int a) {
961     ///       return a;
962     ///   };
963     /// \endcode
964     SLS_Empty,
965     /// Merge lambda into a single line if the lambda is argument of a function.
966     /// \code
967     ///   auto lambda = [](int x, int y) {
968     ///       return x < y;
969     ///   };
970     ///   sort(a.begin(), a.end(), [](int x, int y) { return x < y; });
971     /// \endcode
972     SLS_Inline,
973     /// Merge all lambdas fitting on a single line.
974     /// \code
975     ///   auto lambda = [](int a) {};
976     ///   auto lambda2 = [](int a) { return a; };
977     /// \endcode
978     SLS_All,
979   };
980 
981   /// Dependent on the value, ``auto lambda []() { return 0; }`` can be put on a
982   /// single line.
983   /// \version 9
984   ShortLambdaStyle AllowShortLambdasOnASingleLine;
985 
986   /// If ``true``, ``while (true) continue;`` can be put on a single
987   /// line.
988   /// \version 3.7
989   bool AllowShortLoopsOnASingleLine;
990 
991   /// If ``true``, ``namespace a { class b; }`` can be put on a single line.
992   /// \version 20
993   bool AllowShortNamespacesOnASingleLine;
994 
995   /// Different ways to break after the function definition return type.
996   /// This option is **deprecated** and is retained for backwards compatibility.
997   enum DefinitionReturnTypeBreakingStyle : int8_t {
998     /// Break after return type automatically.
999     /// ``PenaltyReturnTypeOnItsOwnLine`` is taken into account.
1000     DRTBS_None,
1001     /// Always break after the return type.
1002     DRTBS_All,
1003     /// Always break after the return types of top-level functions.
1004     DRTBS_TopLevel,
1005   };
1006 
1007   /// Different ways to break after the function definition or
1008   /// declaration return type.
1009   enum ReturnTypeBreakingStyle : int8_t {
1010     /// This is **deprecated**. See ``Automatic`` below.
1011     RTBS_None,
1012     /// Break after return type based on ``PenaltyReturnTypeOnItsOwnLine``.
1013     /// \code
1014     ///   class A {
1015     ///     int f() { return 0; };
1016     ///   };
1017     ///   int f();
1018     ///   int f() { return 1; }
1019     ///   int
1020     ///   LongName::AnotherLongName();
1021     /// \endcode
1022     RTBS_Automatic,
1023     /// Same as ``Automatic`` above, except that there is no break after short
1024     /// return types.
1025     /// \code
1026     ///   class A {
1027     ///     int f() { return 0; };
1028     ///   };
1029     ///   int f();
1030     ///   int f() { return 1; }
1031     ///   int LongName::
1032     ///       AnotherLongName();
1033     /// \endcode
1034     RTBS_ExceptShortType,
1035     /// Always break after the return type.
1036     /// \code
1037     ///   class A {
1038     ///     int
1039     ///     f() {
1040     ///       return 0;
1041     ///     };
1042     ///   };
1043     ///   int
1044     ///   f();
1045     ///   int
1046     ///   f() {
1047     ///     return 1;
1048     ///   }
1049     ///   int
1050     ///   LongName::AnotherLongName();
1051     /// \endcode
1052     RTBS_All,
1053     /// Always break after the return types of top-level functions.
1054     /// \code
1055     ///   class A {
1056     ///     int f() { return 0; };
1057     ///   };
1058     ///   int
1059     ///   f();
1060     ///   int
1061     ///   f() {
1062     ///     return 1;
1063     ///   }
1064     ///   int
1065     ///   LongName::AnotherLongName();
1066     /// \endcode
1067     RTBS_TopLevel,
1068     /// Always break after the return type of function definitions.
1069     /// \code
1070     ///   class A {
1071     ///     int
1072     ///     f() {
1073     ///       return 0;
1074     ///     };
1075     ///   };
1076     ///   int f();
1077     ///   int
1078     ///   f() {
1079     ///     return 1;
1080     ///   }
1081     ///   int
1082     ///   LongName::AnotherLongName();
1083     /// \endcode
1084     RTBS_AllDefinitions,
1085     /// Always break after the return type of top-level definitions.
1086     /// \code
1087     ///   class A {
1088     ///     int f() { return 0; };
1089     ///   };
1090     ///   int f();
1091     ///   int
1092     ///   f() {
1093     ///     return 1;
1094     ///   }
1095     ///   int
1096     ///   LongName::AnotherLongName();
1097     /// \endcode
1098     RTBS_TopLevelDefinitions,
1099   };
1100 
1101   /// The function definition return type breaking style to use.  This
1102   /// option is **deprecated** and is retained for backwards compatibility.
1103   /// \version 3.7
1104   DefinitionReturnTypeBreakingStyle AlwaysBreakAfterDefinitionReturnType;
1105 
1106   /// This option is renamed to ``BreakAfterReturnType``.
1107   /// \version 3.8
1108   /// @deprecated
1109   // ReturnTypeBreakingStyle AlwaysBreakAfterReturnType;
1110 
1111   /// If ``true``, always break before multiline string literals.
1112   ///
1113   /// This flag is mean to make cases where there are multiple multiline strings
1114   /// in a file look more consistent. Thus, it will only take effect if wrapping
1115   /// the string at that point leads to it being indented
1116   /// ``ContinuationIndentWidth`` spaces from the start of the line.
1117   /// \code
1118   ///    true:                                  false:
1119   ///    aaaa =                         vs.     aaaa = "bbbb"
1120   ///        "bbbb"                                    "cccc";
1121   ///        "cccc";
1122   /// \endcode
1123   /// \version 3.4
1124   bool AlwaysBreakBeforeMultilineStrings;
1125 
1126   /// Different ways to break after the template declaration.
1127   enum BreakTemplateDeclarationsStyle : int8_t {
1128     /// Do not change the line breaking before the declaration.
1129     /// \code
1130     ///    template <typename T>
1131     ///    T foo() {
1132     ///    }
1133     ///    template <typename T> T foo(int aaaaaaaaaaaaaaaaaaaaa,
1134     ///                                int bbbbbbbbbbbbbbbbbbbbb) {
1135     ///    }
1136     /// \endcode
1137     BTDS_Leave,
1138     /// Do not force break before declaration.
1139     /// ``PenaltyBreakTemplateDeclaration`` is taken into account.
1140     /// \code
1141     ///    template <typename T> T foo() {
1142     ///    }
1143     ///    template <typename T> T foo(int aaaaaaaaaaaaaaaaaaaaa,
1144     ///                                int bbbbbbbbbbbbbbbbbbbbb) {
1145     ///    }
1146     /// \endcode
1147     BTDS_No,
1148     /// Force break after template declaration only when the following
1149     /// declaration spans multiple lines.
1150     /// \code
1151     ///    template <typename T> T foo() {
1152     ///    }
1153     ///    template <typename T>
1154     ///    T foo(int aaaaaaaaaaaaaaaaaaaaa,
1155     ///          int bbbbbbbbbbbbbbbbbbbbb) {
1156     ///    }
1157     /// \endcode
1158     BTDS_MultiLine,
1159     /// Always break after template declaration.
1160     /// \code
1161     ///    template <typename T>
1162     ///    T foo() {
1163     ///    }
1164     ///    template <typename T>
1165     ///    T foo(int aaaaaaaaaaaaaaaaaaaaa,
1166     ///          int bbbbbbbbbbbbbbbbbbbbb) {
1167     ///    }
1168     /// \endcode
1169     BTDS_Yes
1170   };
1171 
1172   /// This option is renamed to ``BreakTemplateDeclarations``.
1173   /// \version 3.4
1174   /// @deprecated
1175   // BreakTemplateDeclarationsStyle AlwaysBreakTemplateDeclarations;
1176 
1177   /// A vector of strings that should be interpreted as attributes/qualifiers
1178   /// instead of identifiers. This can be useful for language extensions or
1179   /// static analyzer annotations.
1180   ///
1181   /// For example:
1182   /// \code
1183   ///   x = (char *__capability)&y;
1184   ///   int function(void) __unused;
1185   ///   void only_writes_to_buffer(char *__output buffer);
1186   /// \endcode
1187   ///
1188   /// In the .clang-format configuration file, this can be configured like:
1189   /// \code{.yaml}
1190   ///   AttributeMacros: [__capability, __output, __unused]
1191   /// \endcode
1192   ///
1193   /// \version 12
1194   std::vector<std::string> AttributeMacros;
1195 
1196   /// If ``false``, a function call's arguments will either be all on the
1197   /// same line or will have one line each.
1198   /// \code
1199   ///   true:
1200   ///   void f() {
1201   ///     f(aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa,
1202   ///       aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
1203   ///   }
1204   ///
1205   ///   false:
1206   ///   void f() {
1207   ///     f(aaaaaaaaaaaaaaaaaaaa,
1208   ///       aaaaaaaaaaaaaaaaaaaa,
1209   ///       aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
1210   ///   }
1211   /// \endcode
1212   /// \version 3.7
1213   bool BinPackArguments;
1214 
1215   /// If ``BinPackLongBracedList`` is ``true`` it overrides
1216   /// ``BinPackArguments`` if there are 20 or more items in a braced
1217   /// initializer list.
1218   /// \code
1219   ///    BinPackLongBracedList: false  vs.    BinPackLongBracedList: true
1220   ///    vector<int> x{                       vector<int> x{1, 2, ...,
1221   ///                                                       20, 21};
1222   ///                1,
1223   ///                2,
1224   ///                ...,
1225   ///                20,
1226   ///                21};
1227   /// \endcode
1228   /// \version 21
1229   bool BinPackLongBracedList;
1230 
1231   /// Different way to try to fit all parameters on a line.
1232   enum BinPackParametersStyle : int8_t {
1233     /// Bin-pack parameters.
1234     /// \code
1235     ///    void f(int a, int bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
1236     ///           int ccccccccccccccccccccccccccccccccccccccccccc);
1237     /// \endcode
1238     BPPS_BinPack,
1239     /// Put all parameters on the current line if they fit.
1240     /// Otherwise, put each one on its own line.
1241     /// \code
1242     ///    void f(int a, int b, int c);
1243     ///
1244     ///    void f(int a,
1245     ///           int b,
1246     ///           int ccccccccccccccccccccccccccccccccccccc);
1247     /// \endcode
1248     BPPS_OnePerLine,
1249     /// Always put each parameter on its own line.
1250     /// \code
1251     ///    void f(int a,
1252     ///           int b,
1253     ///           int c);
1254     /// \endcode
1255     BPPS_AlwaysOnePerLine,
1256   };
1257 
1258   /// The bin pack parameters style to use.
1259   /// \version 3.7
1260   BinPackParametersStyle BinPackParameters;
1261 
1262   /// Styles for adding spacing around ``:`` in bitfield definitions.
1263   enum BitFieldColonSpacingStyle : int8_t {
1264     /// Add one space on each side of the ``:``
1265     /// \code
1266     ///   unsigned bf : 2;
1267     /// \endcode
1268     BFCS_Both,
1269     /// Add no space around the ``:`` (except when needed for
1270     /// ``AlignConsecutiveBitFields``).
1271     /// \code
1272     ///   unsigned bf:2;
1273     /// \endcode
1274     BFCS_None,
1275     /// Add space before the ``:`` only
1276     /// \code
1277     ///   unsigned bf :2;
1278     /// \endcode
1279     BFCS_Before,
1280     /// Add space after the ``:`` only (space may be added before if
1281     /// needed for ``AlignConsecutiveBitFields``).
1282     /// \code
1283     ///   unsigned bf: 2;
1284     /// \endcode
1285     BFCS_After
1286   };
1287   /// The BitFieldColonSpacingStyle to use for bitfields.
1288   /// \version 12
1289   BitFieldColonSpacingStyle BitFieldColonSpacing;
1290 
1291   /// The number of columns to use to indent the contents of braced init lists.
1292   /// If unset or negative, ``ContinuationIndentWidth`` is used.
1293   /// \code
1294   ///   AlignAfterOpenBracket: AlwaysBreak
1295   ///   BracedInitializerIndentWidth: 2
1296   ///
1297   ///   void f() {
1298   ///     SomeClass c{
1299   ///       "foo",
1300   ///       "bar",
1301   ///       "baz",
1302   ///     };
1303   ///     auto s = SomeStruct{
1304   ///       .foo = "foo",
1305   ///       .bar = "bar",
1306   ///       .baz = "baz",
1307   ///     };
1308   ///     SomeArrayT a[3] = {
1309   ///       {
1310   ///         foo,
1311   ///         bar,
1312   ///       },
1313   ///       {
1314   ///         foo,
1315   ///         bar,
1316   ///       },
1317   ///       SomeArrayT{},
1318   ///     };
1319   ///   }
1320   /// \endcode
1321   /// \version 17
1322   int BracedInitializerIndentWidth;
1323 
1324   /// Different ways to wrap braces after control statements.
1325   enum BraceWrappingAfterControlStatementStyle : int8_t {
1326     /// Never wrap braces after a control statement.
1327     /// \code
1328     ///   if (foo()) {
1329     ///   } else {
1330     ///   }
1331     ///   for (int i = 0; i < 10; ++i) {
1332     ///   }
1333     /// \endcode
1334     BWACS_Never,
1335     /// Only wrap braces after a multi-line control statement.
1336     /// \code
1337     ///   if (foo && bar &&
1338     ///       baz)
1339     ///   {
1340     ///     quux();
1341     ///   }
1342     ///   while (foo || bar) {
1343     ///   }
1344     /// \endcode
1345     BWACS_MultiLine,
1346     /// Always wrap braces after a control statement.
1347     /// \code
1348     ///   if (foo())
1349     ///   {
1350     ///   } else
1351     ///   {}
1352     ///   for (int i = 0; i < 10; ++i)
1353     ///   {}
1354     /// \endcode
1355     BWACS_Always
1356   };
1357 
1358   /// Precise control over the wrapping of braces.
1359   /// \code
1360   ///   # Should be declared this way:
1361   ///   BreakBeforeBraces: Custom
1362   ///   BraceWrapping:
1363   ///       AfterClass: true
1364   /// \endcode
1365   struct BraceWrappingFlags {
1366     /// Wrap case labels.
1367     /// \code
1368     ///   false:                                true:
1369     ///   switch (foo) {                vs.     switch (foo) {
1370     ///     case 1: {                             case 1:
1371     ///       bar();                              {
1372     ///       break;                                bar();
1373     ///     }                                       break;
1374     ///     default: {                            }
1375     ///       plop();                             default:
1376     ///     }                                     {
1377     ///   }                                         plop();
1378     ///                                           }
1379     ///                                         }
1380     /// \endcode
1381     bool AfterCaseLabel;
1382     /// Wrap class definitions.
1383     /// \code
1384     ///   true:
1385     ///   class foo
1386     ///   {};
1387     ///
1388     ///   false:
1389     ///   class foo {};
1390     /// \endcode
1391     bool AfterClass;
1392 
1393     /// Wrap control statements (``if``/``for``/``while``/``switch``/..).
1394     BraceWrappingAfterControlStatementStyle AfterControlStatement;
1395     /// Wrap enum definitions.
1396     /// \code
1397     ///   true:
1398     ///   enum X : int
1399     ///   {
1400     ///     B
1401     ///   };
1402     ///
1403     ///   false:
1404     ///   enum X : int { B };
1405     /// \endcode
1406     bool AfterEnum;
1407     /// Wrap function definitions.
1408     /// \code
1409     ///   true:
1410     ///   void foo()
1411     ///   {
1412     ///     bar();
1413     ///     bar2();
1414     ///   }
1415     ///
1416     ///   false:
1417     ///   void foo() {
1418     ///     bar();
1419     ///     bar2();
1420     ///   }
1421     /// \endcode
1422     bool AfterFunction;
1423     /// Wrap namespace definitions.
1424     /// \code
1425     ///   true:
1426     ///   namespace
1427     ///   {
1428     ///   int foo();
1429     ///   int bar();
1430     ///   }
1431     ///
1432     ///   false:
1433     ///   namespace {
1434     ///   int foo();
1435     ///   int bar();
1436     ///   }
1437     /// \endcode
1438     bool AfterNamespace;
1439     /// Wrap ObjC definitions (interfaces, implementations...).
1440     /// \note
1441     ///  @autoreleasepool and @synchronized blocks are wrapped
1442     ///  according to ``AfterControlStatement`` flag.
1443     /// \endnote
1444     bool AfterObjCDeclaration;
1445     /// Wrap struct definitions.
1446     /// \code
1447     ///   true:
1448     ///   struct foo
1449     ///   {
1450     ///     int x;
1451     ///   };
1452     ///
1453     ///   false:
1454     ///   struct foo {
1455     ///     int x;
1456     ///   };
1457     /// \endcode
1458     bool AfterStruct;
1459     /// Wrap union definitions.
1460     /// \code
1461     ///   true:
1462     ///   union foo
1463     ///   {
1464     ///     int x;
1465     ///   }
1466     ///
1467     ///   false:
1468     ///   union foo {
1469     ///     int x;
1470     ///   }
1471     /// \endcode
1472     bool AfterUnion;
1473     /// Wrap extern blocks.
1474     /// \code
1475     ///   true:
1476     ///   extern "C"
1477     ///   {
1478     ///     int foo();
1479     ///   }
1480     ///
1481     ///   false:
1482     ///   extern "C" {
1483     ///   int foo();
1484     ///   }
1485     /// \endcode
1486     bool AfterExternBlock; // Partially superseded by IndentExternBlock
1487     /// Wrap before ``catch``.
1488     /// \code
1489     ///   true:
1490     ///   try {
1491     ///     foo();
1492     ///   }
1493     ///   catch () {
1494     ///   }
1495     ///
1496     ///   false:
1497     ///   try {
1498     ///     foo();
1499     ///   } catch () {
1500     ///   }
1501     /// \endcode
1502     bool BeforeCatch;
1503     /// Wrap before ``else``.
1504     /// \code
1505     ///   true:
1506     ///   if (foo()) {
1507     ///   }
1508     ///   else {
1509     ///   }
1510     ///
1511     ///   false:
1512     ///   if (foo()) {
1513     ///   } else {
1514     ///   }
1515     /// \endcode
1516     bool BeforeElse;
1517     /// Wrap lambda block.
1518     /// \code
1519     ///   true:
1520     ///   connect(
1521     ///     []()
1522     ///     {
1523     ///       foo();
1524     ///       bar();
1525     ///     });
1526     ///
1527     ///   false:
1528     ///   connect([]() {
1529     ///     foo();
1530     ///     bar();
1531     ///   });
1532     /// \endcode
1533     bool BeforeLambdaBody;
1534     /// Wrap before ``while``.
1535     /// \code
1536     ///   true:
1537     ///   do {
1538     ///     foo();
1539     ///   }
1540     ///   while (1);
1541     ///
1542     ///   false:
1543     ///   do {
1544     ///     foo();
1545     ///   } while (1);
1546     /// \endcode
1547     bool BeforeWhile;
1548     /// Indent the wrapped braces themselves.
1549     bool IndentBraces;
1550     /// If ``false``, empty function body can be put on a single line.
1551     /// This option is used only if the opening brace of the function has
1552     /// already been wrapped, i.e. the ``AfterFunction`` brace wrapping mode is
1553     /// set, and the function could/should not be put on a single line (as per
1554     /// ``AllowShortFunctionsOnASingleLine`` and constructor formatting
1555     /// options).
1556     /// \code
1557     ///   false:          true:
1558     ///   int f()   vs.   int f()
1559     ///   {}              {
1560     ///                   }
1561     /// \endcode
1562     ///
1563     bool SplitEmptyFunction;
1564     /// If ``false``, empty record (e.g. class, struct or union) body
1565     /// can be put on a single line. This option is used only if the opening
1566     /// brace of the record has already been wrapped, i.e. the ``AfterClass``
1567     /// (for classes) brace wrapping mode is set.
1568     /// \code
1569     ///   false:           true:
1570     ///   class Foo   vs.  class Foo
1571     ///   {}               {
1572     ///                    }
1573     /// \endcode
1574     ///
1575     bool SplitEmptyRecord;
1576     /// If ``false``, empty namespace body can be put on a single line.
1577     /// This option is used only if the opening brace of the namespace has
1578     /// already been wrapped, i.e. the ``AfterNamespace`` brace wrapping mode is
1579     /// set.
1580     /// \code
1581     ///   false:               true:
1582     ///   namespace Foo   vs.  namespace Foo
1583     ///   {}                   {
1584     ///                        }
1585     /// \endcode
1586     ///
1587     bool SplitEmptyNamespace;
1588   };
1589 
1590   /// Control of individual brace wrapping cases.
1591   ///
1592   /// If ``BreakBeforeBraces`` is set to ``Custom``, use this to specify how
1593   /// each individual brace case should be handled. Otherwise, this is ignored.
1594   /// \code{.yaml}
1595   ///   # Example of usage:
1596   ///   BreakBeforeBraces: Custom
1597   ///   BraceWrapping:
1598   ///     AfterEnum: true
1599   ///     AfterStruct: false
1600   ///     SplitEmptyFunction: false
1601   /// \endcode
1602   /// \version 3.8
1603   BraceWrappingFlags BraceWrapping;
1604 
1605   /// Break between adjacent string literals.
1606   /// \code
1607   ///    true:
1608   ///    return "Code"
1609   ///           "\0\52\26\55\55\0"
1610   ///           "x013"
1611   ///           "\02\xBA";
1612   ///    false:
1613   ///    return "Code" "\0\52\26\55\55\0" "x013" "\02\xBA";
1614   /// \endcode
1615   /// \version 18
1616   bool BreakAdjacentStringLiterals;
1617 
1618   /// Different ways to break after attributes.
1619   enum AttributeBreakingStyle : int8_t {
1620     /// Always break after attributes.
1621     /// \code
1622     ///   [[maybe_unused]]
1623     ///   const int i;
1624     ///   [[gnu::const]] [[maybe_unused]]
1625     ///   int j;
1626     ///
1627     ///   [[nodiscard]]
1628     ///   inline int f();
1629     ///   [[gnu::const]] [[nodiscard]]
1630     ///   int g();
1631     ///
1632     ///   [[likely]]
1633     ///   if (a)
1634     ///     f();
1635     ///   else
1636     ///     g();
1637     ///
1638     ///   switch (b) {
1639     ///   [[unlikely]]
1640     ///   case 1:
1641     ///     ++b;
1642     ///     break;
1643     ///   [[likely]]
1644     ///   default:
1645     ///     return;
1646     ///   }
1647     /// \endcode
1648     ABS_Always,
1649     /// Leave the line breaking after attributes as is.
1650     /// \code
1651     ///   [[maybe_unused]] const int i;
1652     ///   [[gnu::const]] [[maybe_unused]]
1653     ///   int j;
1654     ///
1655     ///   [[nodiscard]] inline int f();
1656     ///   [[gnu::const]] [[nodiscard]]
1657     ///   int g();
1658     ///
1659     ///   [[likely]] if (a)
1660     ///     f();
1661     ///   else
1662     ///     g();
1663     ///
1664     ///   switch (b) {
1665     ///   [[unlikely]] case 1:
1666     ///     ++b;
1667     ///     break;
1668     ///   [[likely]]
1669     ///   default:
1670     ///     return;
1671     ///   }
1672     /// \endcode
1673     ABS_Leave,
1674     /// Never break after attributes.
1675     /// \code
1676     ///   [[maybe_unused]] const int i;
1677     ///   [[gnu::const]] [[maybe_unused]] int j;
1678     ///
1679     ///   [[nodiscard]] inline int f();
1680     ///   [[gnu::const]] [[nodiscard]] int g();
1681     ///
1682     ///   [[likely]] if (a)
1683     ///     f();
1684     ///   else
1685     ///     g();
1686     ///
1687     ///   switch (b) {
1688     ///   [[unlikely]] case 1:
1689     ///     ++b;
1690     ///     break;
1691     ///   [[likely]] default:
1692     ///     return;
1693     ///   }
1694     /// \endcode
1695     ABS_Never,
1696   };
1697 
1698   /// Break after a group of C++11 attributes before variable or function
1699   /// (including constructor/destructor) declaration/definition names or before
1700   /// control statements, i.e. ``if``, ``switch`` (including ``case`` and
1701   /// ``default`` labels), ``for``, and ``while`` statements.
1702   /// \version 16
1703   AttributeBreakingStyle BreakAfterAttributes;
1704 
1705   /// The function declaration return type breaking style to use.
1706   /// \version 19
1707   ReturnTypeBreakingStyle BreakAfterReturnType;
1708 
1709   /// If ``true``, clang-format will always break after a Json array ``[``
1710   /// otherwise it will scan until the closing ``]`` to determine if it should
1711   /// add newlines between elements (prettier compatible).
1712   ///
1713   /// \note
1714   ///  This is currently only for formatting JSON.
1715   /// \endnote
1716   /// \code
1717   ///    true:                                  false:
1718   ///    [                          vs.      [1, 2, 3, 4]
1719   ///      1,
1720   ///      2,
1721   ///      3,
1722   ///      4
1723   ///    ]
1724   /// \endcode
1725   /// \version 16
1726   bool BreakArrays;
1727 
1728   /// The style of wrapping parameters on the same line (bin-packed) or
1729   /// on one line each.
1730   enum BinPackStyle : int8_t {
1731     /// Automatically determine parameter bin-packing behavior.
1732     BPS_Auto,
1733     /// Always bin-pack parameters.
1734     BPS_Always,
1735     /// Never bin-pack parameters.
1736     BPS_Never,
1737   };
1738 
1739   /// The style of breaking before or after binary operators.
1740   enum BinaryOperatorStyle : int8_t {
1741     /// Break after operators.
1742     /// \code
1743     ///    LooooooooooongType loooooooooooooooooooooongVariable =
1744     ///        someLooooooooooooooooongFunction();
1745     ///
1746     ///    bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
1747     ///                         aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ==
1748     ///                     aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &&
1749     ///                 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa >
1750     ///                     ccccccccccccccccccccccccccccccccccccccccc;
1751     /// \endcode
1752     BOS_None,
1753     /// Break before operators that aren't assignments.
1754     /// \code
1755     ///    LooooooooooongType loooooooooooooooooooooongVariable =
1756     ///        someLooooooooooooooooongFunction();
1757     ///
1758     ///    bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
1759     ///                         + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
1760     ///                     == aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
1761     ///                 && aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
1762     ///                        > ccccccccccccccccccccccccccccccccccccccccc;
1763     /// \endcode
1764     BOS_NonAssignment,
1765     /// Break before operators.
1766     /// \code
1767     ///    LooooooooooongType loooooooooooooooooooooongVariable
1768     ///        = someLooooooooooooooooongFunction();
1769     ///
1770     ///    bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
1771     ///                         + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
1772     ///                     == aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
1773     ///                 && aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
1774     ///                        > ccccccccccccccccccccccccccccccccccccccccc;
1775     /// \endcode
1776     BOS_All,
1777   };
1778 
1779   /// The way to wrap binary operators.
1780   /// \version 3.6
1781   BinaryOperatorStyle BreakBeforeBinaryOperators;
1782 
1783   /// Different ways to attach braces to their surrounding context.
1784   enum BraceBreakingStyle : int8_t {
1785     /// Always attach braces to surrounding context.
1786     /// \code
1787     ///   namespace N {
1788     ///   enum E {
1789     ///     E1,
1790     ///     E2,
1791     ///   };
1792     ///
1793     ///   class C {
1794     ///   public:
1795     ///     C();
1796     ///   };
1797     ///
1798     ///   bool baz(int i) {
1799     ///     try {
1800     ///       do {
1801     ///         switch (i) {
1802     ///         case 1: {
1803     ///           foobar();
1804     ///           break;
1805     ///         }
1806     ///         default: {
1807     ///           break;
1808     ///         }
1809     ///         }
1810     ///       } while (--i);
1811     ///       return true;
1812     ///     } catch (...) {
1813     ///       handleError();
1814     ///       return false;
1815     ///     }
1816     ///   }
1817     ///
1818     ///   void foo(bool b) {
1819     ///     if (b) {
1820     ///       baz(2);
1821     ///     } else {
1822     ///       baz(5);
1823     ///     }
1824     ///   }
1825     ///
1826     ///   void bar() { foo(true); }
1827     ///   } // namespace N
1828     /// \endcode
1829     BS_Attach,
1830     /// Like ``Attach``, but break before braces on function, namespace and
1831     /// class definitions.
1832     /// \code
1833     ///   namespace N
1834     ///   {
1835     ///   enum E {
1836     ///     E1,
1837     ///     E2,
1838     ///   };
1839     ///
1840     ///   class C
1841     ///   {
1842     ///   public:
1843     ///     C();
1844     ///   };
1845     ///
1846     ///   bool baz(int i)
1847     ///   {
1848     ///     try {
1849     ///       do {
1850     ///         switch (i) {
1851     ///         case 1: {
1852     ///           foobar();
1853     ///           break;
1854     ///         }
1855     ///         default: {
1856     ///           break;
1857     ///         }
1858     ///         }
1859     ///       } while (--i);
1860     ///       return true;
1861     ///     } catch (...) {
1862     ///       handleError();
1863     ///       return false;
1864     ///     }
1865     ///   }
1866     ///
1867     ///   void foo(bool b)
1868     ///   {
1869     ///     if (b) {
1870     ///       baz(2);
1871     ///     } else {
1872     ///       baz(5);
1873     ///     }
1874     ///   }
1875     ///
1876     ///   void bar() { foo(true); }
1877     ///   } // namespace N
1878     /// \endcode
1879     BS_Linux,
1880     /// Like ``Attach``, but break before braces on enum, function, and record
1881     /// definitions.
1882     /// \code
1883     ///   namespace N {
1884     ///   enum E
1885     ///   {
1886     ///     E1,
1887     ///     E2,
1888     ///   };
1889     ///
1890     ///   class C
1891     ///   {
1892     ///   public:
1893     ///     C();
1894     ///   };
1895     ///
1896     ///   bool baz(int i)
1897     ///   {
1898     ///     try {
1899     ///       do {
1900     ///         switch (i) {
1901     ///         case 1: {
1902     ///           foobar();
1903     ///           break;
1904     ///         }
1905     ///         default: {
1906     ///           break;
1907     ///         }
1908     ///         }
1909     ///       } while (--i);
1910     ///       return true;
1911     ///     } catch (...) {
1912     ///       handleError();
1913     ///       return false;
1914     ///     }
1915     ///   }
1916     ///
1917     ///   void foo(bool b)
1918     ///   {
1919     ///     if (b) {
1920     ///       baz(2);
1921     ///     } else {
1922     ///       baz(5);
1923     ///     }
1924     ///   }
1925     ///
1926     ///   void bar() { foo(true); }
1927     ///   } // namespace N
1928     /// \endcode
1929     BS_Mozilla,
1930     /// Like ``Attach``, but break before function definitions, ``catch``, and
1931     /// ``else``.
1932     /// \code
1933     ///   namespace N {
1934     ///   enum E {
1935     ///     E1,
1936     ///     E2,
1937     ///   };
1938     ///
1939     ///   class C {
1940     ///   public:
1941     ///     C();
1942     ///   };
1943     ///
1944     ///   bool baz(int i)
1945     ///   {
1946     ///     try {
1947     ///       do {
1948     ///         switch (i) {
1949     ///         case 1: {
1950     ///           foobar();
1951     ///           break;
1952     ///         }
1953     ///         default: {
1954     ///           break;
1955     ///         }
1956     ///         }
1957     ///       } while (--i);
1958     ///       return true;
1959     ///     }
1960     ///     catch (...) {
1961     ///       handleError();
1962     ///       return false;
1963     ///     }
1964     ///   }
1965     ///
1966     ///   void foo(bool b)
1967     ///   {
1968     ///     if (b) {
1969     ///       baz(2);
1970     ///     }
1971     ///     else {
1972     ///       baz(5);
1973     ///     }
1974     ///   }
1975     ///
1976     ///   void bar() { foo(true); }
1977     ///   } // namespace N
1978     /// \endcode
1979     BS_Stroustrup,
1980     /// Always break before braces.
1981     /// \code
1982     ///   namespace N
1983     ///   {
1984     ///   enum E
1985     ///   {
1986     ///     E1,
1987     ///     E2,
1988     ///   };
1989     ///
1990     ///   class C
1991     ///   {
1992     ///   public:
1993     ///     C();
1994     ///   };
1995     ///
1996     ///   bool baz(int i)
1997     ///   {
1998     ///     try
1999     ///     {
2000     ///       do
2001     ///       {
2002     ///         switch (i)
2003     ///         {
2004     ///         case 1:
2005     ///         {
2006     ///           foobar();
2007     ///           break;
2008     ///         }
2009     ///         default:
2010     ///         {
2011     ///           break;
2012     ///         }
2013     ///         }
2014     ///       } while (--i);
2015     ///       return true;
2016     ///     }
2017     ///     catch (...)
2018     ///     {
2019     ///       handleError();
2020     ///       return false;
2021     ///     }
2022     ///   }
2023     ///
2024     ///   void foo(bool b)
2025     ///   {
2026     ///     if (b)
2027     ///     {
2028     ///       baz(2);
2029     ///     }
2030     ///     else
2031     ///     {
2032     ///       baz(5);
2033     ///     }
2034     ///   }
2035     ///
2036     ///   void bar() { foo(true); }
2037     ///   } // namespace N
2038     /// \endcode
2039     BS_Allman,
2040     /// Like ``Allman`` but always indent braces and line up code with braces.
2041     /// \code
2042     ///   namespace N
2043     ///     {
2044     ///   enum E
2045     ///     {
2046     ///     E1,
2047     ///     E2,
2048     ///     };
2049     ///
2050     ///   class C
2051     ///     {
2052     ///   public:
2053     ///     C();
2054     ///     };
2055     ///
2056     ///   bool baz(int i)
2057     ///     {
2058     ///     try
2059     ///       {
2060     ///       do
2061     ///         {
2062     ///         switch (i)
2063     ///           {
2064     ///           case 1:
2065     ///           {
2066     ///           foobar();
2067     ///           break;
2068     ///           }
2069     ///           default:
2070     ///           {
2071     ///           break;
2072     ///           }
2073     ///           }
2074     ///         } while (--i);
2075     ///       return true;
2076     ///       }
2077     ///     catch (...)
2078     ///       {
2079     ///       handleError();
2080     ///       return false;
2081     ///       }
2082     ///     }
2083     ///
2084     ///   void foo(bool b)
2085     ///     {
2086     ///     if (b)
2087     ///       {
2088     ///       baz(2);
2089     ///       }
2090     ///     else
2091     ///       {
2092     ///       baz(5);
2093     ///       }
2094     ///     }
2095     ///
2096     ///   void bar() { foo(true); }
2097     ///     } // namespace N
2098     /// \endcode
2099     BS_Whitesmiths,
2100     /// Always break before braces and add an extra level of indentation to
2101     /// braces of control statements, not to those of class, function
2102     /// or other definitions.
2103     /// \code
2104     ///   namespace N
2105     ///   {
2106     ///   enum E
2107     ///   {
2108     ///     E1,
2109     ///     E2,
2110     ///   };
2111     ///
2112     ///   class C
2113     ///   {
2114     ///   public:
2115     ///     C();
2116     ///   };
2117     ///
2118     ///   bool baz(int i)
2119     ///   {
2120     ///     try
2121     ///       {
2122     ///         do
2123     ///           {
2124     ///             switch (i)
2125     ///               {
2126     ///               case 1:
2127     ///                 {
2128     ///                   foobar();
2129     ///                   break;
2130     ///                 }
2131     ///               default:
2132     ///                 {
2133     ///                   break;
2134     ///                 }
2135     ///               }
2136     ///           }
2137     ///         while (--i);
2138     ///         return true;
2139     ///       }
2140     ///     catch (...)
2141     ///       {
2142     ///         handleError();
2143     ///         return false;
2144     ///       }
2145     ///   }
2146     ///
2147     ///   void foo(bool b)
2148     ///   {
2149     ///     if (b)
2150     ///       {
2151     ///         baz(2);
2152     ///       }
2153     ///     else
2154     ///       {
2155     ///         baz(5);
2156     ///       }
2157     ///   }
2158     ///
2159     ///   void bar() { foo(true); }
2160     ///   } // namespace N
2161     /// \endcode
2162     BS_GNU,
2163     /// Like ``Attach``, but break before functions.
2164     /// \code
2165     ///   namespace N {
2166     ///   enum E {
2167     ///     E1,
2168     ///     E2,
2169     ///   };
2170     ///
2171     ///   class C {
2172     ///   public:
2173     ///     C();
2174     ///   };
2175     ///
2176     ///   bool baz(int i)
2177     ///   {
2178     ///     try {
2179     ///       do {
2180     ///         switch (i) {
2181     ///         case 1: {
2182     ///           foobar();
2183     ///           break;
2184     ///         }
2185     ///         default: {
2186     ///           break;
2187     ///         }
2188     ///         }
2189     ///       } while (--i);
2190     ///       return true;
2191     ///     } catch (...) {
2192     ///       handleError();
2193     ///       return false;
2194     ///     }
2195     ///   }
2196     ///
2197     ///   void foo(bool b)
2198     ///   {
2199     ///     if (b) {
2200     ///       baz(2);
2201     ///     } else {
2202     ///       baz(5);
2203     ///     }
2204     ///   }
2205     ///
2206     ///   void bar() { foo(true); }
2207     ///   } // namespace N
2208     /// \endcode
2209     BS_WebKit,
2210     /// Configure each individual brace in ``BraceWrapping``.
2211     BS_Custom
2212   };
2213 
2214   /// The brace breaking style to use.
2215   /// \version 3.7
2216   BraceBreakingStyle BreakBeforeBraces;
2217 
2218   /// Different ways to break before concept declarations.
2219   enum BreakBeforeConceptDeclarationsStyle : int8_t {
2220     /// Keep the template declaration line together with ``concept``.
2221     /// \code
2222     ///   template <typename T> concept C = ...;
2223     /// \endcode
2224     BBCDS_Never,
2225     /// Breaking between template declaration and ``concept`` is allowed. The
2226     /// actual behavior depends on the content and line breaking rules and
2227     /// penalties.
2228     BBCDS_Allowed,
2229     /// Always break before ``concept``, putting it in the line after the
2230     /// template declaration.
2231     /// \code
2232     ///   template <typename T>
2233     ///   concept C = ...;
2234     /// \endcode
2235     BBCDS_Always,
2236   };
2237 
2238   /// The concept declaration style to use.
2239   /// \version 12
2240   BreakBeforeConceptDeclarationsStyle BreakBeforeConceptDeclarations;
2241 
2242   /// Different ways to break ASM parameters.
2243   enum BreakBeforeInlineASMColonStyle : int8_t {
2244     /// No break before inline ASM colon.
2245     /// \code
2246     ///    asm volatile("string", : : val);
2247     /// \endcode
2248     BBIAS_Never,
2249     /// Break before inline ASM colon if the line length is longer than column
2250     /// limit.
2251     /// \code
2252     ///    asm volatile("string", : : val);
2253     ///    asm("cmoveq %1, %2, %[result]"
2254     ///        : [result] "=r"(result)
2255     ///        : "r"(test), "r"(new), "[result]"(old));
2256     /// \endcode
2257     BBIAS_OnlyMultiline,
2258     /// Always break before inline ASM colon.
2259     /// \code
2260     ///    asm volatile("string",
2261     ///                 :
2262     ///                 : val);
2263     /// \endcode
2264     BBIAS_Always,
2265   };
2266 
2267   /// The inline ASM colon style to use.
2268   /// \version 16
2269   BreakBeforeInlineASMColonStyle BreakBeforeInlineASMColon;
2270 
2271   /// If ``true``, break before a template closing bracket (``>``) when there is
2272   /// a line break after the matching opening bracket (``<``).
2273   /// \code
2274   ///    true:
2275   ///    template <typename Foo, typename Bar>
2276   ///
2277   ///    template <typename Foo,
2278   ///              typename Bar>
2279   ///
2280   ///    template <
2281   ///        typename Foo,
2282   ///        typename Bar
2283   ///    >
2284   ///
2285   ///    false:
2286   ///    template <typename Foo, typename Bar>
2287   ///
2288   ///    template <typename Foo,
2289   ///              typename Bar>
2290   ///
2291   ///    template <
2292   ///        typename Foo,
2293   ///        typename Bar>
2294   /// \endcode
2295   /// \version 21
2296   bool BreakBeforeTemplateCloser;
2297 
2298   /// If ``true``, ternary operators will be placed after line breaks.
2299   /// \code
2300   ///    true:
2301   ///    veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongDescription
2302   ///        ? firstValue
2303   ///        : SecondValueVeryVeryVeryVeryLong;
2304   ///
2305   ///    false:
2306   ///    veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongDescription ?
2307   ///        firstValue :
2308   ///        SecondValueVeryVeryVeryVeryLong;
2309   /// \endcode
2310   /// \version 3.7
2311   bool BreakBeforeTernaryOperators;
2312 
2313   /// Different ways to break binary operations.
2314   enum BreakBinaryOperationsStyle : int8_t {
2315     /// Don't break binary operations
2316     /// \code
2317     ///    aaa + bbbb * ccccc - ddddd +
2318     ///    eeeeeeeeeeeeeeee;
2319     /// \endcode
2320     BBO_Never,
2321 
2322     /// Binary operations will either be all on the same line, or each operation
2323     /// will have one line each.
2324     /// \code
2325     ///    aaa +
2326     ///    bbbb *
2327     ///    ccccc -
2328     ///    ddddd +
2329     ///    eeeeeeeeeeeeeeee;
2330     /// \endcode
2331     BBO_OnePerLine,
2332 
2333     /// Binary operations of a particular precedence that exceed the column
2334     /// limit will have one line each.
2335     /// \code
2336     ///    aaa +
2337     ///    bbbb * ccccc -
2338     ///    ddddd +
2339     ///    eeeeeeeeeeeeeeee;
2340     /// \endcode
2341     BBO_RespectPrecedence
2342   };
2343 
2344   /// The break binary operations style to use.
2345   /// \version 20
2346   BreakBinaryOperationsStyle BreakBinaryOperations;
2347 
2348   /// Different ways to break initializers.
2349   enum BreakConstructorInitializersStyle : int8_t {
2350     /// Break constructor initializers before the colon and after the commas.
2351     /// \code
2352     ///    Constructor()
2353     ///        : initializer1(),
2354     ///          initializer2()
2355     /// \endcode
2356     BCIS_BeforeColon,
2357     /// Break constructor initializers before the colon and commas, and align
2358     /// the commas with the colon.
2359     /// \code
2360     ///    Constructor()
2361     ///        : initializer1()
2362     ///        , initializer2()
2363     /// \endcode
2364     BCIS_BeforeComma,
2365     /// Break constructor initializers after the colon and commas.
2366     /// \code
2367     ///    Constructor() :
2368     ///        initializer1(),
2369     ///        initializer2()
2370     /// \endcode
2371     BCIS_AfterColon
2372   };
2373 
2374   /// The break constructor initializers style to use.
2375   /// \version 5
2376   BreakConstructorInitializersStyle BreakConstructorInitializers;
2377 
2378   /// If ``true``, clang-format will always break before function definition
2379   /// parameters.
2380   /// \code
2381   ///    true:
2382   ///    void functionDefinition(
2383   ///             int A, int B) {}
2384   ///
2385   ///    false:
2386   ///    void functionDefinition(int A, int B) {}
2387   ///
2388   /// \endcode
2389   /// \version 19
2390   bool BreakFunctionDefinitionParameters;
2391 
2392   /// Break after each annotation on a field in Java files.
2393   /// \code{.java}
2394   ///    true:                                  false:
2395   ///    @Partial                       vs.     @Partial @Mock DataLoad loader;
2396   ///    @Mock
2397   ///    DataLoad loader;
2398   /// \endcode
2399   /// \version 3.8
2400   bool BreakAfterJavaFieldAnnotations;
2401 
2402   /// Allow breaking string literals when formatting.
2403   ///
2404   /// In C, C++, and Objective-C:
2405   /// \code
2406   ///    true:
2407   ///    const char* x = "veryVeryVeryVeryVeryVe"
2408   ///                    "ryVeryVeryVeryVeryVery"
2409   ///                    "VeryLongString";
2410   ///
2411   ///    false:
2412   ///    const char* x =
2413   ///        "veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongString";
2414   /// \endcode
2415   ///
2416   /// In C# and Java:
2417   /// \code
2418   ///    true:
2419   ///    string x = "veryVeryVeryVeryVeryVe" +
2420   ///               "ryVeryVeryVeryVeryVery" +
2421   ///               "VeryLongString";
2422   ///
2423   ///    false:
2424   ///    string x =
2425   ///        "veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongString";
2426   /// \endcode
2427   ///
2428   /// C# interpolated strings are not broken.
2429   ///
2430   /// In Verilog:
2431   /// \code
2432   ///    true:
2433   ///    string x = {"veryVeryVeryVeryVeryVe",
2434   ///                "ryVeryVeryVeryVeryVery",
2435   ///                "VeryLongString"};
2436   ///
2437   ///    false:
2438   ///    string x =
2439   ///        "veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongString";
2440   /// \endcode
2441   ///
2442   /// \version 3.9
2443   bool BreakStringLiterals;
2444 
2445   /// The column limit.
2446   ///
2447   /// A column limit of ``0`` means that there is no column limit. In this case,
2448   /// clang-format will respect the input's line breaking decisions within
2449   /// statements unless they contradict other rules.
2450   /// \version 3.7
2451   unsigned ColumnLimit;
2452 
2453   /// A regular expression that describes comments with special meaning,
2454   /// which should not be split into lines or otherwise changed.
2455   /// \code
2456   ///    // CommentPragmas: '^ FOOBAR pragma:'
2457   ///    // Will leave the following line unaffected
2458   ///    #include <vector> // FOOBAR pragma: keep
2459   /// \endcode
2460   /// \version 3.7
2461   std::string CommentPragmas;
2462 
2463   /// Different ways to break inheritance list.
2464   enum BreakInheritanceListStyle : int8_t {
2465     /// Break inheritance list before the colon and after the commas.
2466     /// \code
2467     ///    class Foo
2468     ///        : Base1,
2469     ///          Base2
2470     ///    {};
2471     /// \endcode
2472     BILS_BeforeColon,
2473     /// Break inheritance list before the colon and commas, and align
2474     /// the commas with the colon.
2475     /// \code
2476     ///    class Foo
2477     ///        : Base1
2478     ///        , Base2
2479     ///    {};
2480     /// \endcode
2481     BILS_BeforeComma,
2482     /// Break inheritance list after the colon and commas.
2483     /// \code
2484     ///    class Foo :
2485     ///        Base1,
2486     ///        Base2
2487     ///    {};
2488     /// \endcode
2489     BILS_AfterColon,
2490     /// Break inheritance list only after the commas.
2491     /// \code
2492     ///    class Foo : Base1,
2493     ///                Base2
2494     ///    {};
2495     /// \endcode
2496     BILS_AfterComma,
2497   };
2498 
2499   /// The inheritance list style to use.
2500   /// \version 7
2501   BreakInheritanceListStyle BreakInheritanceList;
2502 
2503   /// The template declaration breaking style to use.
2504   /// \version 19
2505   BreakTemplateDeclarationsStyle BreakTemplateDeclarations;
2506 
2507   /// If ``true``, consecutive namespace declarations will be on the same
2508   /// line. If ``false``, each namespace is declared on a new line.
2509   /// \code
2510   ///   true:
2511   ///   namespace Foo { namespace Bar {
2512   ///   }}
2513   ///
2514   ///   false:
2515   ///   namespace Foo {
2516   ///   namespace Bar {
2517   ///   }
2518   ///   }
2519   /// \endcode
2520   ///
2521   /// If it does not fit on a single line, the overflowing namespaces get
2522   /// wrapped:
2523   /// \code
2524   ///   namespace Foo { namespace Bar {
2525   ///   namespace Extra {
2526   ///   }}}
2527   /// \endcode
2528   /// \version 5
2529   bool CompactNamespaces;
2530 
2531   /// This option is **deprecated**. See ``CurrentLine`` of
2532   /// ``PackConstructorInitializers``.
2533   /// \version 3.7
2534   // bool ConstructorInitializerAllOnOneLineOrOnePerLine;
2535 
2536   /// The number of characters to use for indentation of constructor
2537   /// initializer lists as well as inheritance lists.
2538   /// \version 3.7
2539   unsigned ConstructorInitializerIndentWidth;
2540 
2541   /// Indent width for line continuations.
2542   /// \code
2543   ///    ContinuationIndentWidth: 2
2544   ///
2545   ///    int i =         //  VeryVeryVeryVeryVeryLongComment
2546   ///      longFunction( // Again a long comment
2547   ///        arg);
2548   /// \endcode
2549   /// \version 3.7
2550   unsigned ContinuationIndentWidth;
2551 
2552   /// If ``true``, format braced lists as best suited for C++11 braced
2553   /// lists.
2554   ///
2555   /// Important differences:
2556   ///
2557   /// * No spaces inside the braced list.
2558   /// * No line break before the closing brace.
2559   /// * Indentation with the continuation indent, not with the block indent.
2560   ///
2561   /// Fundamentally, C++11 braced lists are formatted exactly like function
2562   /// calls would be formatted in their place. If the braced list follows a name
2563   /// (e.g. a type or variable name), clang-format formats as if the ``{}`` were
2564   /// the parentheses of a function call with that name. If there is no name,
2565   /// a zero-length name is assumed.
2566   /// \code
2567   ///    true:                                  false:
2568   ///    vector<int> x{1, 2, 3, 4};     vs.     vector<int> x{ 1, 2, 3, 4 };
2569   ///    vector<T> x{{}, {}, {}, {}};           vector<T> x{ {}, {}, {}, {} };
2570   ///    f(MyMap[{composite, key}]);            f(MyMap[{ composite, key }]);
2571   ///    new int[3]{1, 2, 3};                   new int[3]{ 1, 2, 3 };
2572   /// \endcode
2573   /// \version 3.4
2574   bool Cpp11BracedListStyle;
2575 
2576   /// This option is **deprecated**. See ``DeriveLF`` and ``DeriveCRLF`` of
2577   /// ``LineEnding``.
2578   /// \version 10
2579   // bool DeriveLineEnding;
2580 
2581   /// If ``true``, analyze the formatted file for the most common
2582   /// alignment of ``&`` and ``*``.
2583   /// Pointer and reference alignment styles are going to be updated according
2584   /// to the preferences found in the file.
2585   /// ``PointerAlignment`` is then used only as fallback.
2586   /// \version 3.7
2587   bool DerivePointerAlignment;
2588 
2589   /// Disables formatting completely.
2590   /// \version 3.7
2591   bool DisableFormat;
2592 
2593   /// Different styles for empty line after access modifiers.
2594   /// ``EmptyLineBeforeAccessModifier`` configuration handles the number of
2595   /// empty lines between two access modifiers.
2596   enum EmptyLineAfterAccessModifierStyle : int8_t {
2597     /// Remove all empty lines after access modifiers.
2598     /// \code
2599     ///   struct foo {
2600     ///   private:
2601     ///     int i;
2602     ///   protected:
2603     ///     int j;
2604     ///     /* comment */
2605     ///   public:
2606     ///     foo() {}
2607     ///   private:
2608     ///   protected:
2609     ///   };
2610     /// \endcode
2611     ELAAMS_Never,
2612     /// Keep existing empty lines after access modifiers.
2613     /// MaxEmptyLinesToKeep is applied instead.
2614     ELAAMS_Leave,
2615     /// Always add empty line after access modifiers if there are none.
2616     /// MaxEmptyLinesToKeep is applied also.
2617     /// \code
2618     ///   struct foo {
2619     ///   private:
2620     ///
2621     ///     int i;
2622     ///   protected:
2623     ///
2624     ///     int j;
2625     ///     /* comment */
2626     ///   public:
2627     ///
2628     ///     foo() {}
2629     ///   private:
2630     ///
2631     ///   protected:
2632     ///
2633     ///   };
2634     /// \endcode
2635     ELAAMS_Always,
2636   };
2637 
2638   /// Defines when to put an empty line after access modifiers.
2639   /// ``EmptyLineBeforeAccessModifier`` configuration handles the number of
2640   /// empty lines between two access modifiers.
2641   /// \version 13
2642   EmptyLineAfterAccessModifierStyle EmptyLineAfterAccessModifier;
2643 
2644   /// Different styles for empty line before access modifiers.
2645   enum EmptyLineBeforeAccessModifierStyle : int8_t {
2646     /// Remove all empty lines before access modifiers.
2647     /// \code
2648     ///   struct foo {
2649     ///   private:
2650     ///     int i;
2651     ///   protected:
2652     ///     int j;
2653     ///     /* comment */
2654     ///   public:
2655     ///     foo() {}
2656     ///   private:
2657     ///   protected:
2658     ///   };
2659     /// \endcode
2660     ELBAMS_Never,
2661     /// Keep existing empty lines before access modifiers.
2662     ELBAMS_Leave,
2663     /// Add empty line only when access modifier starts a new logical block.
2664     /// Logical block is a group of one or more member fields or functions.
2665     /// \code
2666     ///   struct foo {
2667     ///   private:
2668     ///     int i;
2669     ///
2670     ///   protected:
2671     ///     int j;
2672     ///     /* comment */
2673     ///   public:
2674     ///     foo() {}
2675     ///
2676     ///   private:
2677     ///   protected:
2678     ///   };
2679     /// \endcode
2680     ELBAMS_LogicalBlock,
2681     /// Always add empty line before access modifiers unless access modifier
2682     /// is at the start of struct or class definition.
2683     /// \code
2684     ///   struct foo {
2685     ///   private:
2686     ///     int i;
2687     ///
2688     ///   protected:
2689     ///     int j;
2690     ///     /* comment */
2691     ///
2692     ///   public:
2693     ///     foo() {}
2694     ///
2695     ///   private:
2696     ///
2697     ///   protected:
2698     ///   };
2699     /// \endcode
2700     ELBAMS_Always,
2701   };
2702 
2703   /// Defines in which cases to put empty line before access modifiers.
2704   /// \version 12
2705   EmptyLineBeforeAccessModifierStyle EmptyLineBeforeAccessModifier;
2706 
2707   /// Styles for ``enum`` trailing commas.
2708   enum EnumTrailingCommaStyle : int8_t {
2709     /// Don't insert or remove trailing commas.
2710     /// \code
2711     ///   enum { a, b, c, };
2712     ///   enum Color { red, green, blue };
2713     /// \endcode
2714     ETC_Leave,
2715     /// Insert trailing commas.
2716     /// \code
2717     ///   enum { a, b, c, };
2718     ///   enum Color { red, green, blue, };
2719     /// \endcode
2720     ETC_Insert,
2721     /// Remove trailing commas.
2722     /// \code
2723     ///   enum { a, b, c };
2724     ///   enum Color { red, green, blue };
2725     /// \endcode
2726     ETC_Remove,
2727   };
2728 
2729   /// Insert a comma (if missing) or remove the comma at the end of an ``enum``
2730   /// enumerator list.
2731   /// \warning
2732   ///  Setting this option to any value other than ``Leave`` could lead to
2733   ///  incorrect code formatting due to clang-format's lack of complete semantic
2734   ///  information. As such, extra care should be taken to review code changes
2735   ///  made by this option.
2736   /// \endwarning
2737   /// \version 21
2738   EnumTrailingCommaStyle EnumTrailingComma;
2739 
2740   /// If ``true``, clang-format detects whether function calls and
2741   /// definitions are formatted with one parameter per line.
2742   ///
2743   /// Each call can be bin-packed, one-per-line or inconclusive. If it is
2744   /// inconclusive, e.g. completely on one line, but a decision needs to be
2745   /// made, clang-format analyzes whether there are other bin-packed cases in
2746   /// the input file and act accordingly.
2747   ///
2748   /// \note
2749   ///  This is an experimental flag, that might go away or be renamed. Do
2750   ///  not use this in config files, etc. Use at your own risk.
2751   /// \endnote
2752   /// \version 3.7
2753   bool ExperimentalAutoDetectBinPacking;
2754 
2755   /// If ``true``, clang-format adds missing namespace end comments for
2756   /// namespaces and fixes invalid existing ones. This doesn't affect short
2757   /// namespaces, which are controlled by ``ShortNamespaceLines``.
2758   /// \code
2759   ///    true:                                  false:
2760   ///    namespace longNamespace {      vs.     namespace longNamespace {
2761   ///    void foo();                            void foo();
2762   ///    void bar();                            void bar();
2763   ///    } // namespace a                       }
2764   ///    namespace shortNamespace {             namespace shortNamespace {
2765   ///    void baz();                            void baz();
2766   ///    }                                      }
2767   /// \endcode
2768   /// \version 5
2769   bool FixNamespaceComments;
2770 
2771   /// A vector of macros that should be interpreted as foreach loops
2772   /// instead of as function calls.
2773   ///
2774   /// These are expected to be macros of the form:
2775   /// \code
2776   ///   FOREACH(<variable-declaration>, ...)
2777   ///     <loop-body>
2778   /// \endcode
2779   ///
2780   /// In the .clang-format configuration file, this can be configured like:
2781   /// \code{.yaml}
2782   ///   ForEachMacros: [RANGES_FOR, FOREACH]
2783   /// \endcode
2784   ///
2785   /// For example: BOOST_FOREACH.
2786   /// \version 3.7
2787   std::vector<std::string> ForEachMacros;
2788 
2789   tooling::IncludeStyle IncludeStyle;
2790 
2791   /// A vector of macros that should be interpreted as conditionals
2792   /// instead of as function calls.
2793   ///
2794   /// These are expected to be macros of the form:
2795   /// \code
2796   ///   IF(...)
2797   ///     <conditional-body>
2798   ///   else IF(...)
2799   ///     <conditional-body>
2800   /// \endcode
2801   ///
2802   /// In the .clang-format configuration file, this can be configured like:
2803   /// \code{.yaml}
2804   ///   IfMacros: [IF]
2805   /// \endcode
2806   ///
2807   /// For example: `KJ_IF_MAYBE
2808   /// <https://github.com/capnproto/capnproto/blob/master/kjdoc/tour.md#maybes>`_
2809   /// \version 13
2810   std::vector<std::string> IfMacros;
2811 
2812   /// Specify whether access modifiers should have their own indentation level.
2813   ///
2814   /// When ``false``, access modifiers are indented (or outdented) relative to
2815   /// the record members, respecting the ``AccessModifierOffset``. Record
2816   /// members are indented one level below the record.
2817   /// When ``true``, access modifiers get their own indentation level. As a
2818   /// consequence, record members are always indented 2 levels below the record,
2819   /// regardless of the access modifier presence. Value of the
2820   /// ``AccessModifierOffset`` is ignored.
2821   /// \code
2822   ///    false:                                 true:
2823   ///    class C {                      vs.     class C {
2824   ///      class D {                                class D {
2825   ///        void bar();                                void bar();
2826   ///      protected:                                 protected:
2827   ///        D();                                       D();
2828   ///      };                                       };
2829   ///    public:                                  public:
2830   ///      C();                                     C();
2831   ///    };                                     };
2832   ///    void foo() {                           void foo() {
2833   ///      return 1;                              return 1;
2834   ///    }                                      }
2835   /// \endcode
2836   /// \version 13
2837   bool IndentAccessModifiers;
2838 
2839   /// Indent case label blocks one level from the case label.
2840   ///
2841   /// When ``false``, the block following the case label uses the same
2842   /// indentation level as for the case label, treating the case label the same
2843   /// as an if-statement.
2844   /// When ``true``, the block gets indented as a scope block.
2845   /// \code
2846   ///    false:                                 true:
2847   ///    switch (fool) {                vs.     switch (fool) {
2848   ///    case 1: {                              case 1:
2849   ///      bar();                                 {
2850   ///    } break;                                   bar();
2851   ///    default: {                               }
2852   ///      plop();                                break;
2853   ///    }                                      default:
2854   ///    }                                        {
2855   ///                                               plop();
2856   ///                                             }
2857   ///                                           }
2858   /// \endcode
2859   /// \version 11
2860   bool IndentCaseBlocks;
2861 
2862   /// Indent case labels one level from the switch statement.
2863   ///
2864   /// When ``false``, use the same indentation level as for the switch
2865   /// statement. Switch statement body is always indented one level more than
2866   /// case labels (except the first block following the case label, which
2867   /// itself indents the code - unless IndentCaseBlocks is enabled).
2868   /// \code
2869   ///    false:                                 true:
2870   ///    switch (fool) {                vs.     switch (fool) {
2871   ///    case 1:                                  case 1:
2872   ///      bar();                                   bar();
2873   ///      break;                                   break;
2874   ///    default:                                 default:
2875   ///      plop();                                  plop();
2876   ///    }                                      }
2877   /// \endcode
2878   /// \version 3.3
2879   bool IndentCaseLabels;
2880 
2881   /// If ``true``, clang-format will indent the body of an ``export { ... }``
2882   /// block. This doesn't affect the formatting of anything else related to
2883   /// exported declarations.
2884   /// \code
2885   ///    true:                     false:
2886   ///    export {          vs.     export {
2887   ///      void foo();             void foo();
2888   ///      void bar();             void bar();
2889   ///    }                         }
2890   /// \endcode
2891   /// \version 20
2892   bool IndentExportBlock;
2893 
2894   /// Indents extern blocks
2895   enum IndentExternBlockStyle : int8_t {
2896     /// Backwards compatible with AfterExternBlock's indenting.
2897     /// \code
2898     ///    IndentExternBlock: AfterExternBlock
2899     ///    BraceWrapping.AfterExternBlock: true
2900     ///    extern "C"
2901     ///    {
2902     ///        void foo();
2903     ///    }
2904     /// \endcode
2905     ///
2906     /// \code
2907     ///    IndentExternBlock: AfterExternBlock
2908     ///    BraceWrapping.AfterExternBlock: false
2909     ///    extern "C" {
2910     ///    void foo();
2911     ///    }
2912     /// \endcode
2913     IEBS_AfterExternBlock,
2914     /// Does not indent extern blocks.
2915     /// \code
2916     ///     extern "C" {
2917     ///     void foo();
2918     ///     }
2919     /// \endcode
2920     IEBS_NoIndent,
2921     /// Indents extern blocks.
2922     /// \code
2923     ///     extern "C" {
2924     ///       void foo();
2925     ///     }
2926     /// \endcode
2927     IEBS_Indent,
2928   };
2929 
2930   /// IndentExternBlockStyle is the type of indenting of extern blocks.
2931   /// \version 11
2932   IndentExternBlockStyle IndentExternBlock;
2933 
2934   /// Indent goto labels.
2935   ///
2936   /// When ``false``, goto labels are flushed left.
2937   /// \code
2938   ///    true:                                  false:
2939   ///    int f() {                      vs.     int f() {
2940   ///      if (foo()) {                           if (foo()) {
2941   ///      label1:                              label1:
2942   ///        bar();                                 bar();
2943   ///      }                                      }
2944   ///    label2:                                label2:
2945   ///      return 1;                              return 1;
2946   ///    }                                      }
2947   /// \endcode
2948   /// \version 10
2949   bool IndentGotoLabels;
2950 
2951   /// Options for indenting preprocessor directives.
2952   enum PPDirectiveIndentStyle : int8_t {
2953     /// Does not indent any directives.
2954     /// \code
2955     ///    #if FOO
2956     ///    #if BAR
2957     ///    #include <foo>
2958     ///    #endif
2959     ///    #endif
2960     /// \endcode
2961     PPDIS_None,
2962     /// Indents directives after the hash.
2963     /// \code
2964     ///    #if FOO
2965     ///    #  if BAR
2966     ///    #    include <foo>
2967     ///    #  endif
2968     ///    #endif
2969     /// \endcode
2970     PPDIS_AfterHash,
2971     /// Indents directives before the hash.
2972     /// \code
2973     ///    #if FOO
2974     ///      #if BAR
2975     ///        #include <foo>
2976     ///      #endif
2977     ///    #endif
2978     /// \endcode
2979     PPDIS_BeforeHash
2980   };
2981 
2982   /// The preprocessor directive indenting style to use.
2983   /// \version 6
2984   PPDirectiveIndentStyle IndentPPDirectives;
2985 
2986   /// Indent the requires clause in a template. This only applies when
2987   /// ``RequiresClausePosition`` is ``OwnLine``, ``OwnLineWithBrace``,
2988   /// or ``WithFollowing``.
2989   ///
2990   /// In clang-format 12, 13 and 14 it was named ``IndentRequires``.
2991   /// \code
2992   ///    true:
2993   ///    template <typename It>
2994   ///      requires Iterator<It>
2995   ///    void sort(It begin, It end) {
2996   ///      //....
2997   ///    }
2998   ///
2999   ///    false:
3000   ///    template <typename It>
3001   ///    requires Iterator<It>
3002   ///    void sort(It begin, It end) {
3003   ///      //....
3004   ///    }
3005   /// \endcode
3006   /// \version 15
3007   bool IndentRequiresClause;
3008 
3009   /// The number of columns to use for indentation.
3010   /// \code
3011   ///    IndentWidth: 3
3012   ///
3013   ///    void f() {
3014   ///       someFunction();
3015   ///       if (true, false) {
3016   ///          f();
3017   ///       }
3018   ///    }
3019   /// \endcode
3020   /// \version 3.7
3021   unsigned IndentWidth;
3022 
3023   /// Indent if a function definition or declaration is wrapped after the
3024   /// type.
3025   /// \code
3026   ///    true:
3027   ///    LoooooooooooooooooooooooooooooooooooooooongReturnType
3028   ///        LoooooooooooooooooooooooooooooooongFunctionDeclaration();
3029   ///
3030   ///    false:
3031   ///    LoooooooooooooooooooooooooooooooooooooooongReturnType
3032   ///    LoooooooooooooooooooooooooooooooongFunctionDeclaration();
3033   /// \endcode
3034   /// \version 3.7
3035   bool IndentWrappedFunctionNames;
3036 
3037   /// Insert braces after control statements (``if``, ``else``, ``for``, ``do``,
3038   /// and ``while``) in C++ unless the control statements are inside macro
3039   /// definitions or the braces would enclose preprocessor directives.
3040   /// \warning
3041   ///  Setting this option to ``true`` could lead to incorrect code formatting
3042   ///  due to clang-format's lack of complete semantic information. As such,
3043   ///  extra care should be taken to review code changes made by this option.
3044   /// \endwarning
3045   /// \code
3046   ///   false:                                    true:
3047   ///
3048   ///   if (isa<FunctionDecl>(D))        vs.      if (isa<FunctionDecl>(D)) {
3049   ///     handleFunctionDecl(D);                    handleFunctionDecl(D);
3050   ///   else if (isa<VarDecl>(D))                 } else if (isa<VarDecl>(D)) {
3051   ///     handleVarDecl(D);                         handleVarDecl(D);
3052   ///   else                                      } else {
3053   ///     return;                                   return;
3054   ///                                             }
3055   ///
3056   ///   while (i--)                      vs.      while (i--) {
3057   ///     for (auto *A : D.attrs())                 for (auto *A : D.attrs()) {
3058   ///       handleAttr(A);                            handleAttr(A);
3059   ///                                               }
3060   ///                                             }
3061   ///
3062   ///   do                               vs.      do {
3063   ///     --i;                                      --i;
3064   ///   while (i);                                } while (i);
3065   /// \endcode
3066   /// \version 15
3067   bool InsertBraces;
3068 
3069   /// Insert a newline at end of file if missing.
3070   /// \version 16
3071   bool InsertNewlineAtEOF;
3072 
3073   /// The style of inserting trailing commas into container literals.
3074   enum TrailingCommaStyle : int8_t {
3075     /// Do not insert trailing commas.
3076     TCS_None,
3077     /// Insert trailing commas in container literals that were wrapped over
3078     /// multiple lines. Note that this is conceptually incompatible with
3079     /// bin-packing, because the trailing comma is used as an indicator
3080     /// that a container should be formatted one-per-line (i.e. not bin-packed).
3081     /// So inserting a trailing comma counteracts bin-packing.
3082     TCS_Wrapped,
3083   };
3084 
3085   /// If set to ``TCS_Wrapped`` will insert trailing commas in container
3086   /// literals (arrays and objects) that wrap across multiple lines.
3087   /// It is currently only available for JavaScript
3088   /// and disabled by default ``TCS_None``.
3089   /// ``InsertTrailingCommas`` cannot be used together with ``BinPackArguments``
3090   /// as inserting the comma disables bin-packing.
3091   /// \code
3092   ///   TSC_Wrapped:
3093   ///   const someArray = [
3094   ///   aaaaaaaaaaaaaaaaaaaaaaaaaa,
3095   ///   aaaaaaaaaaaaaaaaaaaaaaaaaa,
3096   ///   aaaaaaaaaaaaaaaaaaaaaaaaaa,
3097   ///   //                        ^ inserted
3098   ///   ]
3099   /// \endcode
3100   /// \version 11
3101   TrailingCommaStyle InsertTrailingCommas;
3102 
3103   /// Separator format of integer literals of different bases.
3104   ///
3105   /// If negative, remove separators. If  ``0``, leave the literal as is. If
3106   /// positive, insert separators between digits starting from the rightmost
3107   /// digit.
3108   ///
3109   /// For example, the config below will leave separators in binary literals
3110   /// alone, insert separators in decimal literals to separate the digits into
3111   /// groups of 3, and remove separators in hexadecimal literals.
3112   /// \code
3113   ///   IntegerLiteralSeparator:
3114   ///     Binary: 0
3115   ///     Decimal: 3
3116   ///     Hex: -1
3117   /// \endcode
3118   ///
3119   /// You can also specify a minimum number of digits (``BinaryMinDigits``,
3120   /// ``DecimalMinDigits``, and ``HexMinDigits``) the integer literal must
3121   /// have in order for the separators to be inserted.
3122   struct IntegerLiteralSeparatorStyle {
3123     /// Format separators in binary literals.
3124     /// \code{.text}
3125     ///   /* -1: */ b = 0b100111101101;
3126     ///   /*  0: */ b = 0b10011'11'0110'1;
3127     ///   /*  3: */ b = 0b100'111'101'101;
3128     ///   /*  4: */ b = 0b1001'1110'1101;
3129     /// \endcode
3130     int8_t Binary;
3131     /// Format separators in binary literals with a minimum number of digits.
3132     /// \code{.text}
3133     ///   // Binary: 3
3134     ///   // BinaryMinDigits: 7
3135     ///   b1 = 0b101101;
3136     ///   b2 = 0b1'101'101;
3137     /// \endcode
3138     int8_t BinaryMinDigits;
3139     /// Format separators in decimal literals.
3140     /// \code{.text}
3141     ///   /* -1: */ d = 18446744073709550592ull;
3142     ///   /*  0: */ d = 184467'440737'0'95505'92ull;
3143     ///   /*  3: */ d = 18'446'744'073'709'550'592ull;
3144     /// \endcode
3145     int8_t Decimal;
3146     /// Format separators in decimal literals with a minimum number of digits.
3147     /// \code{.text}
3148     ///   // Decimal: 3
3149     ///   // DecimalMinDigits: 5
3150     ///   d1 = 2023;
3151     ///   d2 = 10'000;
3152     /// \endcode
3153     int8_t DecimalMinDigits;
3154     /// Format separators in hexadecimal literals.
3155     /// \code{.text}
3156     ///   /* -1: */ h = 0xDEADBEEFDEADBEEFuz;
3157     ///   /*  0: */ h = 0xDEAD'BEEF'DE'AD'BEE'Fuz;
3158     ///   /*  2: */ h = 0xDE'AD'BE'EF'DE'AD'BE'EFuz;
3159     /// \endcode
3160     int8_t Hex;
3161     /// Format separators in hexadecimal literals with a minimum number of
3162     /// digits.
3163     /// \code{.text}
3164     ///   // Hex: 2
3165     ///   // HexMinDigits: 6
3166     ///   h1 = 0xABCDE;
3167     ///   h2 = 0xAB'CD'EF;
3168     /// \endcode
3169     int8_t HexMinDigits;
3170     bool operator==(const IntegerLiteralSeparatorStyle &R) const {
3171       return Binary == R.Binary && BinaryMinDigits == R.BinaryMinDigits &&
3172              Decimal == R.Decimal && DecimalMinDigits == R.DecimalMinDigits &&
3173              Hex == R.Hex && HexMinDigits == R.HexMinDigits;
3174     }
3175   };
3176 
3177   /// Format integer literal separators (``'`` for C++ and ``_`` for C#, Java,
3178   /// and JavaScript).
3179   /// \version 16
3180   IntegerLiteralSeparatorStyle IntegerLiteralSeparator;
3181 
3182   /// A vector of prefixes ordered by the desired groups for Java imports.
3183   ///
3184   /// One group's prefix can be a subset of another - the longest prefix is
3185   /// always matched. Within a group, the imports are ordered lexicographically.
3186   /// Static imports are grouped separately and follow the same group rules.
3187   /// By default, static imports are placed before non-static imports,
3188   /// but this behavior is changed by another option,
3189   /// ``SortJavaStaticImport``.
3190   ///
3191   /// In the .clang-format configuration file, this can be configured like
3192   /// in the following yaml example. This will result in imports being
3193   /// formatted as in the Java example below.
3194   /// \code{.yaml}
3195   ///   JavaImportGroups: [com.example, com, org]
3196   /// \endcode
3197   ///
3198   /// \code{.java}
3199   ///    import static com.example.function1;
3200   ///
3201   ///    import static com.test.function2;
3202   ///
3203   ///    import static org.example.function3;
3204   ///
3205   ///    import com.example.ClassA;
3206   ///    import com.example.Test;
3207   ///    import com.example.a.ClassB;
3208   ///
3209   ///    import com.test.ClassC;
3210   ///
3211   ///    import org.example.ClassD;
3212   /// \endcode
3213   /// \version 8
3214   std::vector<std::string> JavaImportGroups;
3215 
3216   /// Quotation styles for JavaScript strings. Does not affect template
3217   /// strings.
3218   enum JavaScriptQuoteStyle : int8_t {
3219     /// Leave string quotes as they are.
3220     /// \code{.js}
3221     ///    string1 = "foo";
3222     ///    string2 = 'bar';
3223     /// \endcode
3224     JSQS_Leave,
3225     /// Always use single quotes.
3226     /// \code{.js}
3227     ///    string1 = 'foo';
3228     ///    string2 = 'bar';
3229     /// \endcode
3230     JSQS_Single,
3231     /// Always use double quotes.
3232     /// \code{.js}
3233     ///    string1 = "foo";
3234     ///    string2 = "bar";
3235     /// \endcode
3236     JSQS_Double
3237   };
3238 
3239   /// The JavaScriptQuoteStyle to use for JavaScript strings.
3240   /// \version 3.9
3241   JavaScriptQuoteStyle JavaScriptQuotes;
3242 
3243   // clang-format off
3244   /// Whether to wrap JavaScript import/export statements.
3245   /// \code{.js}
3246   ///    true:
3247   ///    import {
3248   ///        VeryLongImportsAreAnnoying,
3249   ///        VeryLongImportsAreAnnoying,
3250   ///        VeryLongImportsAreAnnoying,
3251   ///    } from "some/module.js"
3252   ///
3253   ///    false:
3254   ///    import {VeryLongImportsAreAnnoying, VeryLongImportsAreAnnoying, VeryLongImportsAreAnnoying,} from "some/module.js"
3255   /// \endcode
3256   /// \version 3.9
3257   bool JavaScriptWrapImports;
3258   // clang-format on
3259 
3260   /// Options regarding which empty lines are kept.
3261   ///
3262   /// For example, the config below will remove empty lines at start of the
3263   /// file, end of the file, and start of blocks.
3264   ///
3265   /// \code
3266   ///   KeepEmptyLines:
3267   ///     AtEndOfFile: false
3268   ///     AtStartOfBlock: false
3269   ///     AtStartOfFile: false
3270   /// \endcode
3271   struct KeepEmptyLinesStyle {
3272     /// Keep empty lines at end of file.
3273     bool AtEndOfFile;
3274     /// Keep empty lines at start of a block.
3275     /// \code
3276     ///    true:                                  false:
3277     ///    if (foo) {                     vs.     if (foo) {
3278     ///                                             bar();
3279     ///      bar();                               }
3280     ///    }
3281     /// \endcode
3282     bool AtStartOfBlock;
3283     /// Keep empty lines at start of file.
3284     bool AtStartOfFile;
3285     bool operator==(const KeepEmptyLinesStyle &R) const {
3286       return AtEndOfFile == R.AtEndOfFile &&
3287              AtStartOfBlock == R.AtStartOfBlock &&
3288              AtStartOfFile == R.AtStartOfFile;
3289     }
3290   };
3291   /// Which empty lines are kept.  See ``MaxEmptyLinesToKeep`` for how many
3292   /// consecutive empty lines are kept.
3293   /// \version 19
3294   KeepEmptyLinesStyle KeepEmptyLines;
3295 
3296   /// This option is **deprecated**. See ``AtEndOfFile`` of ``KeepEmptyLines``.
3297   /// \version 17
3298   // bool KeepEmptyLinesAtEOF;
3299 
3300   /// This option is **deprecated**. See ``AtStartOfBlock`` of
3301   /// ``KeepEmptyLines``.
3302   /// \version 3.7
3303   // bool KeepEmptyLinesAtTheStartOfBlocks;
3304 
3305   /// Keep the form feed character if it's immediately preceded and followed by
3306   /// a newline. Multiple form feeds and newlines within a whitespace range are
3307   /// replaced with a single newline and form feed followed by the remaining
3308   /// newlines.
3309   /// \version 20
3310   bool KeepFormFeed;
3311 
3312   /// Indentation logic for lambda bodies.
3313   enum LambdaBodyIndentationKind : int8_t {
3314     /// Align lambda body relative to the lambda signature. This is the default.
3315     /// \code
3316     ///    someMethod(
3317     ///        [](SomeReallyLongLambdaSignatureArgument foo) {
3318     ///          return;
3319     ///        });
3320     /// \endcode
3321     LBI_Signature,
3322     /// For statements within block scope, align lambda body relative to the
3323     /// indentation level of the outer scope the lambda signature resides in.
3324     /// \code
3325     ///    someMethod(
3326     ///        [](SomeReallyLongLambdaSignatureArgument foo) {
3327     ///      return;
3328     ///    });
3329     ///
3330     ///    someMethod(someOtherMethod(
3331     ///        [](SomeReallyLongLambdaSignatureArgument foo) {
3332     ///      return;
3333     ///    }));
3334     /// \endcode
3335     LBI_OuterScope,
3336   };
3337 
3338   /// The indentation style of lambda bodies. ``Signature`` (the default)
3339   /// causes the lambda body to be indented one additional level relative to
3340   /// the indentation level of the signature. ``OuterScope`` forces the lambda
3341   /// body to be indented one additional level relative to the parent scope
3342   /// containing the lambda signature.
3343   /// \version 13
3344   LambdaBodyIndentationKind LambdaBodyIndentation;
3345 
3346   /// Supported languages.
3347   ///
3348   /// When stored in a configuration file, specifies the language, that the
3349   /// configuration targets. When passed to the ``reformat()`` function, enables
3350   /// syntax features specific to the language.
3351   enum LanguageKind : int8_t {
3352     /// Do not use.
3353     LK_None,
3354     /// Should be used for C.
3355     LK_C,
3356     /// Should be used for C++.
3357     LK_Cpp,
3358     /// Should be used for C#.
3359     LK_CSharp,
3360     /// Should be used for Java.
3361     LK_Java,
3362     /// Should be used for JavaScript.
3363     LK_JavaScript,
3364     /// Should be used for JSON.
3365     LK_Json,
3366     /// Should be used for Objective-C, Objective-C++.
3367     LK_ObjC,
3368     /// Should be used for Protocol Buffers
3369     /// (https://developers.google.com/protocol-buffers/).
3370     LK_Proto,
3371     /// Should be used for TableGen code.
3372     LK_TableGen,
3373     /// Should be used for Protocol Buffer messages in text format
3374     /// (https://developers.google.com/protocol-buffers/).
3375     LK_TextProto,
3376     /// Should be used for Verilog and SystemVerilog.
3377     /// https://standards.ieee.org/ieee/1800/6700/
3378     /// https://sci-hub.st/10.1109/IEEESTD.2018.8299595
3379     LK_Verilog
3380   };
isCppFormatStyle3381   bool isCpp() const {
3382     return Language == LK_Cpp || Language == LK_C || Language == LK_ObjC;
3383   }
isCSharpFormatStyle3384   bool isCSharp() const { return Language == LK_CSharp; }
isJsonFormatStyle3385   bool isJson() const { return Language == LK_Json; }
isJavaFormatStyle3386   bool isJava() const { return Language == LK_Java; }
isJavaScriptFormatStyle3387   bool isJavaScript() const { return Language == LK_JavaScript; }
isVerilogFormatStyle3388   bool isVerilog() const { return Language == LK_Verilog; }
isTextProtoFormatStyle3389   bool isTextProto() const { return Language == LK_TextProto; }
isProtoFormatStyle3390   bool isProto() const { return Language == LK_Proto || isTextProto(); }
isTableGenFormatStyle3391   bool isTableGen() const { return Language == LK_TableGen; }
3392 
3393   /// The language that this format style targets.
3394   /// \note
3395   ///  You can specify the language (``C``, ``Cpp``, or ``ObjC``) for ``.h``
3396   ///  files by adding a ``// clang-format Language:`` line before the first
3397   ///  non-comment (and non-empty) line, e.g. ``// clang-format Language: Cpp``.
3398   /// \endnote
3399   /// \version 3.5
3400   LanguageKind Language;
3401 
3402   /// Line ending style.
3403   enum LineEndingStyle : int8_t {
3404     /// Use ``\n``.
3405     LE_LF,
3406     /// Use ``\r\n``.
3407     LE_CRLF,
3408     /// Use ``\n`` unless the input has more lines ending in ``\r\n``.
3409     LE_DeriveLF,
3410     /// Use ``\r\n`` unless the input has more lines ending in ``\n``.
3411     LE_DeriveCRLF,
3412   };
3413 
3414   /// Line ending style (``\n`` or ``\r\n``) to use.
3415   /// \version 16
3416   LineEndingStyle LineEnding;
3417 
3418   /// A regular expression matching macros that start a block.
3419   /// \code
3420   ///    # With:
3421   ///    MacroBlockBegin: "^NS_MAP_BEGIN|\
3422   ///    NS_TABLE_HEAD$"
3423   ///    MacroBlockEnd: "^\
3424   ///    NS_MAP_END|\
3425   ///    NS_TABLE_.*_END$"
3426   ///
3427   ///    NS_MAP_BEGIN
3428   ///      foo();
3429   ///    NS_MAP_END
3430   ///
3431   ///    NS_TABLE_HEAD
3432   ///      bar();
3433   ///    NS_TABLE_FOO_END
3434   ///
3435   ///    # Without:
3436   ///    NS_MAP_BEGIN
3437   ///    foo();
3438   ///    NS_MAP_END
3439   ///
3440   ///    NS_TABLE_HEAD
3441   ///    bar();
3442   ///    NS_TABLE_FOO_END
3443   /// \endcode
3444   /// \version 3.7
3445   std::string MacroBlockBegin;
3446 
3447   /// A regular expression matching macros that end a block.
3448   /// \version 3.7
3449   std::string MacroBlockEnd;
3450 
3451   /// A list of macros of the form \c <definition>=<expansion> .
3452   ///
3453   /// Code will be parsed with macros expanded, in order to determine how to
3454   /// interpret and format the macro arguments.
3455   ///
3456   /// For example, the code:
3457   /// \code
3458   ///   A(a*b);
3459   /// \endcode
3460   ///
3461   /// will usually be interpreted as a call to a function A, and the
3462   /// multiplication expression will be formatted as ``a * b``.
3463   ///
3464   /// If we specify the macro definition:
3465   /// \code{.yaml}
3466   ///   Macros:
3467   ///   - A(x)=x
3468   /// \endcode
3469   ///
3470   /// the code will now be parsed as a declaration of the variable b of type a*,
3471   /// and formatted as ``a* b`` (depending on pointer-binding rules).
3472   ///
3473   /// Features and restrictions:
3474   ///  * Both function-like macros and object-like macros are supported.
3475   ///  * Macro arguments must be used exactly once in the expansion.
3476   ///  * No recursive expansion; macros referencing other macros will be
3477   ///    ignored.
3478   ///  * Overloading by arity is supported: for example, given the macro
3479   ///    definitions A=x, A()=y, A(a)=a
3480   ///
3481   /// \code
3482   ///    A; -> x;
3483   ///    A(); -> y;
3484   ///    A(z); -> z;
3485   ///    A(a, b); // will not be expanded.
3486   /// \endcode
3487   ///
3488   /// \version 17
3489   std::vector<std::string> Macros;
3490 
3491   /// A vector of function-like macros whose invocations should be skipped by
3492   /// ``RemoveParentheses``.
3493   /// \version 21
3494   std::vector<std::string> MacrosSkippedByRemoveParentheses;
3495 
3496   /// The maximum number of consecutive empty lines to keep.
3497   /// \code
3498   ///    MaxEmptyLinesToKeep: 1         vs.     MaxEmptyLinesToKeep: 0
3499   ///    int f() {                              int f() {
3500   ///      int = 1;                                 int i = 1;
3501   ///                                               i = foo();
3502   ///      i = foo();                               return i;
3503   ///                                           }
3504   ///      return i;
3505   ///    }
3506   /// \endcode
3507   /// \version 3.7
3508   unsigned MaxEmptyLinesToKeep;
3509 
3510   /// Different ways to indent namespace contents.
3511   enum NamespaceIndentationKind : int8_t {
3512     /// Don't indent in namespaces.
3513     /// \code
3514     ///    namespace out {
3515     ///    int i;
3516     ///    namespace in {
3517     ///    int i;
3518     ///    }
3519     ///    }
3520     /// \endcode
3521     NI_None,
3522     /// Indent only in inner namespaces (nested in other namespaces).
3523     /// \code
3524     ///    namespace out {
3525     ///    int i;
3526     ///    namespace in {
3527     ///      int i;
3528     ///    }
3529     ///    }
3530     /// \endcode
3531     NI_Inner,
3532     /// Indent in all namespaces.
3533     /// \code
3534     ///    namespace out {
3535     ///      int i;
3536     ///      namespace in {
3537     ///        int i;
3538     ///      }
3539     ///    }
3540     /// \endcode
3541     NI_All
3542   };
3543 
3544   /// The indentation used for namespaces.
3545   /// \version 3.7
3546   NamespaceIndentationKind NamespaceIndentation;
3547 
3548   /// A vector of macros which are used to open namespace blocks.
3549   ///
3550   /// These are expected to be macros of the form:
3551   /// \code
3552   ///   NAMESPACE(<namespace-name>, ...) {
3553   ///     <namespace-content>
3554   ///   }
3555   /// \endcode
3556   ///
3557   /// For example: TESTSUITE
3558   /// \version 9
3559   std::vector<std::string> NamespaceMacros;
3560 
3561   /// Controls bin-packing Objective-C protocol conformance list
3562   /// items into as few lines as possible when they go over ``ColumnLimit``.
3563   ///
3564   /// If ``Auto`` (the default), delegates to the value in
3565   /// ``BinPackParameters``. If that is ``BinPack``, bin-packs Objective-C
3566   /// protocol conformance list items into as few lines as possible
3567   /// whenever they go over ``ColumnLimit``.
3568   ///
3569   /// If ``Always``, always bin-packs Objective-C protocol conformance
3570   /// list items into as few lines as possible whenever they go over
3571   /// ``ColumnLimit``.
3572   ///
3573   /// If ``Never``, lays out Objective-C protocol conformance list items
3574   /// onto individual lines whenever they go over ``ColumnLimit``.
3575   ///
3576   /// \code{.objc}
3577   ///    Always (or Auto, if BinPackParameters==BinPack):
3578   ///    @interface ccccccccccccc () <
3579   ///        ccccccccccccc, ccccccccccccc,
3580   ///        ccccccccccccc, ccccccccccccc> {
3581   ///    }
3582   ///
3583   ///    Never (or Auto, if BinPackParameters!=BinPack):
3584   ///    @interface ddddddddddddd () <
3585   ///        ddddddddddddd,
3586   ///        ddddddddddddd,
3587   ///        ddddddddddddd,
3588   ///        ddddddddddddd> {
3589   ///    }
3590   /// \endcode
3591   /// \version 7
3592   BinPackStyle ObjCBinPackProtocolList;
3593 
3594   /// The number of characters to use for indentation of ObjC blocks.
3595   /// \code{.objc}
3596   ///    ObjCBlockIndentWidth: 4
3597   ///
3598   ///    [operation setCompletionBlock:^{
3599   ///        [self onOperationDone];
3600   ///    }];
3601   /// \endcode
3602   /// \version 3.7
3603   unsigned ObjCBlockIndentWidth;
3604 
3605   /// Break parameters list into lines when there is nested block
3606   /// parameters in a function call.
3607   /// \code
3608   ///   false:
3609   ///    - (void)_aMethod
3610   ///    {
3611   ///        [self.test1 t:self w:self callback:^(typeof(self) self, NSNumber
3612   ///        *u, NSNumber *v) {
3613   ///            u = c;
3614   ///        }]
3615   ///    }
3616   ///    true:
3617   ///    - (void)_aMethod
3618   ///    {
3619   ///       [self.test1 t:self
3620   ///                    w:self
3621   ///           callback:^(typeof(self) self, NSNumber *u, NSNumber *v) {
3622   ///                u = c;
3623   ///            }]
3624   ///    }
3625   /// \endcode
3626   /// \version 11
3627   bool ObjCBreakBeforeNestedBlockParam;
3628 
3629   /// The order in which ObjC property attributes should appear.
3630   ///
3631   /// Attributes in code will be sorted in the order specified. Any attributes
3632   /// encountered that are not mentioned in this array will be sorted last, in
3633   /// stable order. Comments between attributes will leave the attributes
3634   /// untouched.
3635   /// \warning
3636   ///  Using this option could lead to incorrect code formatting due to
3637   ///  clang-format's lack of complete semantic information. As such, extra
3638   ///  care should be taken to review code changes made by this option.
3639   /// \endwarning
3640   /// \code{.yaml}
3641   ///   ObjCPropertyAttributeOrder: [
3642   ///       class, direct,
3643   ///       atomic, nonatomic,
3644   ///       assign, retain, strong, copy, weak, unsafe_unretained,
3645   ///       readonly, readwrite, getter, setter,
3646   ///       nullable, nonnull, null_resettable, null_unspecified
3647   ///   ]
3648   /// \endcode
3649   /// \version 18
3650   std::vector<std::string> ObjCPropertyAttributeOrder;
3651 
3652   /// Add a space after ``@property`` in Objective-C, i.e. use
3653   /// ``@property (readonly)`` instead of ``@property(readonly)``.
3654   /// \version 3.7
3655   bool ObjCSpaceAfterProperty;
3656 
3657   /// Add a space in front of an Objective-C protocol list, i.e. use
3658   /// ``Foo <Protocol>`` instead of ``Foo<Protocol>``.
3659   /// \version 3.7
3660   bool ObjCSpaceBeforeProtocolList;
3661 
3662   /// A regular expression that describes markers for turning formatting off for
3663   /// one line. If it matches a comment that is the only token of a line,
3664   /// clang-format skips the comment and the next line. Otherwise, clang-format
3665   /// skips lines containing a matched token.
3666   /// \code
3667   ///    // OneLineFormatOffRegex: ^(// NOLINT|logger$)
3668   ///    // results in the output below:
3669   ///    int a;
3670   ///    int b ;  // NOLINT
3671   ///    int c;
3672   ///     // NOLINTNEXTLINE
3673   ///    int d ;
3674   ///    int e;
3675   ///    s = "// NOLINT";
3676   ///     logger() ;
3677   ///    logger2();
3678   ///    my_logger();
3679   /// \endcode
3680   /// \version 21
3681   std::string OneLineFormatOffRegex;
3682 
3683   /// Different ways to try to fit all constructor initializers on a line.
3684   enum PackConstructorInitializersStyle : int8_t {
3685     /// Always put each constructor initializer on its own line.
3686     /// \code
3687     ///    Constructor()
3688     ///        : a(),
3689     ///          b()
3690     /// \endcode
3691     PCIS_Never,
3692     /// Bin-pack constructor initializers.
3693     /// \code
3694     ///    Constructor()
3695     ///        : aaaaaaaaaaaaaaaaaaaa(), bbbbbbbbbbbbbbbbbbbb(),
3696     ///          cccccccccccccccccccc()
3697     /// \endcode
3698     PCIS_BinPack,
3699     /// Put all constructor initializers on the current line if they fit.
3700     /// Otherwise, put each one on its own line.
3701     /// \code
3702     ///    Constructor() : a(), b()
3703     ///
3704     ///    Constructor()
3705     ///        : aaaaaaaaaaaaaaaaaaaa(),
3706     ///          bbbbbbbbbbbbbbbbbbbb(),
3707     ///          ddddddddddddd()
3708     /// \endcode
3709     PCIS_CurrentLine,
3710     /// Same as ``PCIS_CurrentLine`` except that if all constructor initializers
3711     /// do not fit on the current line, try to fit them on the next line.
3712     /// \code
3713     ///    Constructor() : a(), b()
3714     ///
3715     ///    Constructor()
3716     ///        : aaaaaaaaaaaaaaaaaaaa(), bbbbbbbbbbbbbbbbbbbb(), ddddddddddddd()
3717     ///
3718     ///    Constructor()
3719     ///        : aaaaaaaaaaaaaaaaaaaa(),
3720     ///          bbbbbbbbbbbbbbbbbbbb(),
3721     ///          cccccccccccccccccccc()
3722     /// \endcode
3723     PCIS_NextLine,
3724     /// Put all constructor initializers on the next line if they fit.
3725     /// Otherwise, put each one on its own line.
3726     /// \code
3727     ///    Constructor()
3728     ///        : a(), b()
3729     ///
3730     ///    Constructor()
3731     ///        : aaaaaaaaaaaaaaaaaaaa(), bbbbbbbbbbbbbbbbbbbb(), ddddddddddddd()
3732     ///
3733     ///    Constructor()
3734     ///        : aaaaaaaaaaaaaaaaaaaa(),
3735     ///          bbbbbbbbbbbbbbbbbbbb(),
3736     ///          cccccccccccccccccccc()
3737     /// \endcode
3738     PCIS_NextLineOnly,
3739   };
3740 
3741   /// The pack constructor initializers style to use.
3742   /// \version 14
3743   PackConstructorInitializersStyle PackConstructorInitializers;
3744 
3745   /// The penalty for breaking around an assignment operator.
3746   /// \version 5
3747   unsigned PenaltyBreakAssignment;
3748 
3749   /// The penalty for breaking a function call after ``call(``.
3750   /// \version 3.7
3751   unsigned PenaltyBreakBeforeFirstCallParameter;
3752 
3753   /// The penalty for breaking before a member access operator (``.``, ``->``).
3754   /// \version 20
3755   unsigned PenaltyBreakBeforeMemberAccess;
3756 
3757   /// The penalty for each line break introduced inside a comment.
3758   /// \version 3.7
3759   unsigned PenaltyBreakComment;
3760 
3761   /// The penalty for breaking before the first ``<<``.
3762   /// \version 3.7
3763   unsigned PenaltyBreakFirstLessLess;
3764 
3765   /// The penalty for breaking after ``(``.
3766   /// \version 14
3767   unsigned PenaltyBreakOpenParenthesis;
3768 
3769   /// The penalty for breaking after ``::``.
3770   /// \version 18
3771   unsigned PenaltyBreakScopeResolution;
3772 
3773   /// The penalty for each line break introduced inside a string literal.
3774   /// \version 3.7
3775   unsigned PenaltyBreakString;
3776 
3777   /// The penalty for breaking after template declaration.
3778   /// \version 7
3779   unsigned PenaltyBreakTemplateDeclaration;
3780 
3781   /// The penalty for each character outside of the column limit.
3782   /// \version 3.7
3783   unsigned PenaltyExcessCharacter;
3784 
3785   /// Penalty for each character of whitespace indentation
3786   /// (counted relative to leading non-whitespace column).
3787   /// \version 12
3788   unsigned PenaltyIndentedWhitespace;
3789 
3790   /// Penalty for putting the return type of a function onto its own line.
3791   /// \version 3.7
3792   unsigned PenaltyReturnTypeOnItsOwnLine;
3793 
3794   /// The ``&``, ``&&`` and ``*`` alignment style.
3795   enum PointerAlignmentStyle : int8_t {
3796     /// Align pointer to the left.
3797     /// \code
3798     ///   int* a;
3799     /// \endcode
3800     PAS_Left,
3801     /// Align pointer to the right.
3802     /// \code
3803     ///   int *a;
3804     /// \endcode
3805     PAS_Right,
3806     /// Align pointer in the middle.
3807     /// \code
3808     ///   int * a;
3809     /// \endcode
3810     PAS_Middle
3811   };
3812 
3813   /// Pointer and reference alignment style.
3814   /// \version 3.7
3815   PointerAlignmentStyle PointerAlignment;
3816 
3817   /// The number of columns to use for indentation of preprocessor statements.
3818   /// When set to -1 (default) ``IndentWidth`` is used also for preprocessor
3819   /// statements.
3820   /// \code
3821   ///    PPIndentWidth: 1
3822   ///
3823   ///    #ifdef __linux__
3824   ///    # define FOO
3825   ///    #else
3826   ///    # define BAR
3827   ///    #endif
3828   /// \endcode
3829   /// \version 13
3830   int PPIndentWidth;
3831 
3832   /// Different specifiers and qualifiers alignment styles.
3833   enum QualifierAlignmentStyle : int8_t {
3834     /// Don't change specifiers/qualifiers to either Left or Right alignment
3835     /// (default).
3836     /// \code
3837     ///    int const a;
3838     ///    const int *a;
3839     /// \endcode
3840     QAS_Leave,
3841     /// Change specifiers/qualifiers to be left-aligned.
3842     /// \code
3843     ///    const int a;
3844     ///    const int *a;
3845     /// \endcode
3846     QAS_Left,
3847     /// Change specifiers/qualifiers to be right-aligned.
3848     /// \code
3849     ///    int const a;
3850     ///    int const *a;
3851     /// \endcode
3852     QAS_Right,
3853     /// Change specifiers/qualifiers to be aligned based on ``QualifierOrder``.
3854     /// With:
3855     /// \code{.yaml}
3856     ///   QualifierOrder: [inline, static, type, const]
3857     /// \endcode
3858     ///
3859     /// \code
3860     ///
3861     ///    int const a;
3862     ///    int const *a;
3863     /// \endcode
3864     QAS_Custom
3865   };
3866 
3867   /// Different ways to arrange specifiers and qualifiers (e.g. const/volatile).
3868   /// \warning
3869   ///  Setting ``QualifierAlignment``  to something other than ``Leave``, COULD
3870   ///  lead to incorrect code formatting due to incorrect decisions made due to
3871   ///  clang-formats lack of complete semantic information.
3872   ///  As such extra care should be taken to review code changes made by the use
3873   ///  of this option.
3874   /// \endwarning
3875   /// \version 14
3876   QualifierAlignmentStyle QualifierAlignment;
3877 
3878   /// The order in which the qualifiers appear.
3879   /// The order is an array that can contain any of the following:
3880   ///
3881   ///   * ``const``
3882   ///   * ``inline``
3883   ///   * ``static``
3884   ///   * ``friend``
3885   ///   * ``constexpr``
3886   ///   * ``volatile``
3887   ///   * ``restrict``
3888   ///   * ``type``
3889   ///
3890   /// \note
3891   ///  It must contain ``type``.
3892   /// \endnote
3893   ///
3894   /// Items to the left of ``type`` will be placed to the left of the type and
3895   /// aligned in the order supplied. Items to the right of ``type`` will be
3896   /// placed to the right of the type and aligned in the order supplied.
3897   ///
3898   /// \code{.yaml}
3899   ///   QualifierOrder: [inline, static, type, const, volatile]
3900   /// \endcode
3901   /// \version 14
3902   std::vector<std::string> QualifierOrder;
3903 
3904   /// See documentation of ``RawStringFormats``.
3905   struct RawStringFormat {
3906     /// The language of this raw string.
3907     LanguageKind Language;
3908     /// A list of raw string delimiters that match this language.
3909     std::vector<std::string> Delimiters;
3910     /// A list of enclosing function names that match this language.
3911     std::vector<std::string> EnclosingFunctions;
3912     /// The canonical delimiter for this language.
3913     std::string CanonicalDelimiter;
3914     /// The style name on which this raw string format is based on.
3915     /// If not specified, the raw string format is based on the style that this
3916     /// format is based on.
3917     std::string BasedOnStyle;
3918     bool operator==(const RawStringFormat &Other) const {
3919       return Language == Other.Language && Delimiters == Other.Delimiters &&
3920              EnclosingFunctions == Other.EnclosingFunctions &&
3921              CanonicalDelimiter == Other.CanonicalDelimiter &&
3922              BasedOnStyle == Other.BasedOnStyle;
3923     }
3924   };
3925 
3926   /// Defines hints for detecting supported languages code blocks in raw
3927   /// strings.
3928   ///
3929   /// A raw string with a matching delimiter or a matching enclosing function
3930   /// name will be reformatted assuming the specified language based on the
3931   /// style for that language defined in the .clang-format file. If no style has
3932   /// been defined in the .clang-format file for the specific language, a
3933   /// predefined style given by ``BasedOnStyle`` is used. If ``BasedOnStyle`` is
3934   /// not found, the formatting is based on ``LLVM`` style. A matching delimiter
3935   /// takes precedence over a matching enclosing function name for determining
3936   /// the language of the raw string contents.
3937   ///
3938   /// If a canonical delimiter is specified, occurrences of other delimiters for
3939   /// the same language will be updated to the canonical if possible.
3940   ///
3941   /// There should be at most one specification per language and each delimiter
3942   /// and enclosing function should not occur in multiple specifications.
3943   ///
3944   /// To configure this in the .clang-format file, use:
3945   /// \code{.yaml}
3946   ///   RawStringFormats:
3947   ///     - Language: TextProto
3948   ///         Delimiters:
3949   ///           - pb
3950   ///           - proto
3951   ///         EnclosingFunctions:
3952   ///           - PARSE_TEXT_PROTO
3953   ///         BasedOnStyle: google
3954   ///     - Language: Cpp
3955   ///         Delimiters:
3956   ///           - cc
3957   ///           - cpp
3958   ///         BasedOnStyle: LLVM
3959   ///         CanonicalDelimiter: cc
3960   /// \endcode
3961   /// \version 6
3962   std::vector<RawStringFormat> RawStringFormats;
3963 
3964   /// The ``&`` and ``&&`` alignment style.
3965   enum ReferenceAlignmentStyle : int8_t {
3966     /// Align reference like ``PointerAlignment``.
3967     RAS_Pointer,
3968     /// Align reference to the left.
3969     /// \code
3970     ///   int& a;
3971     /// \endcode
3972     RAS_Left,
3973     /// Align reference to the right.
3974     /// \code
3975     ///   int &a;
3976     /// \endcode
3977     RAS_Right,
3978     /// Align reference in the middle.
3979     /// \code
3980     ///   int & a;
3981     /// \endcode
3982     RAS_Middle
3983   };
3984 
3985   /// Reference alignment style (overrides ``PointerAlignment`` for references).
3986   /// \version 13
3987   ReferenceAlignmentStyle ReferenceAlignment;
3988 
3989   // clang-format off
3990   /// Types of comment reflow style.
3991   enum ReflowCommentsStyle : int8_t {
3992     /// Leave comments untouched.
3993     /// \code
3994     ///    // veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of information
3995     ///    /* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of information */
3996     ///    /* third veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of information
3997     ///         * and a misaligned second line */
3998     /// \endcode
3999     RCS_Never,
4000     /// Only apply indentation rules, moving comments left or right, without
4001     /// changing formatting inside the comments.
4002     /// \code
4003     ///    // veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of information
4004     ///    /* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of information */
4005     ///    /* third veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of information
4006     ///     * and a misaligned second line */
4007     /// \endcode
4008     RCS_IndentOnly,
4009     /// Apply indentation rules and reflow long comments into new lines, trying
4010     /// to obey the ``ColumnLimit``.
4011     /// \code
4012     ///    // veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of
4013     ///    // information
4014     ///    /* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of
4015     ///     * information */
4016     ///    /* third veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of
4017     ///     * information and a misaligned second line */
4018     /// \endcode
4019     RCS_Always
4020   };
4021   // clang-format on
4022 
4023   /// Comment reformatting style.
4024   /// \version 3.8
4025   ReflowCommentsStyle ReflowComments;
4026 
4027   /// Remove optional braces of control statements (``if``, ``else``, ``for``,
4028   /// and ``while``) in C++ according to the LLVM coding style.
4029   /// \warning
4030   ///  This option will be renamed and expanded to support other styles.
4031   /// \endwarning
4032   /// \warning
4033   ///  Setting this option to ``true`` could lead to incorrect code formatting
4034   ///  due to clang-format's lack of complete semantic information. As such,
4035   ///  extra care should be taken to review code changes made by this option.
4036   /// \endwarning
4037   /// \code
4038   ///   false:                                     true:
4039   ///
4040   ///   if (isa<FunctionDecl>(D)) {        vs.     if (isa<FunctionDecl>(D))
4041   ///     handleFunctionDecl(D);                     handleFunctionDecl(D);
4042   ///   } else if (isa<VarDecl>(D)) {              else if (isa<VarDecl>(D))
4043   ///     handleVarDecl(D);                          handleVarDecl(D);
4044   ///   }
4045   ///
4046   ///   if (isa<VarDecl>(D)) {             vs.     if (isa<VarDecl>(D)) {
4047   ///     for (auto *A : D.attrs()) {                for (auto *A : D.attrs())
4048   ///       if (shouldProcessAttr(A)) {                if (shouldProcessAttr(A))
4049   ///         handleAttr(A);                             handleAttr(A);
4050   ///       }                                      }
4051   ///     }
4052   ///   }
4053   ///
4054   ///   if (isa<FunctionDecl>(D)) {        vs.     if (isa<FunctionDecl>(D))
4055   ///     for (auto *A : D.attrs()) {                for (auto *A : D.attrs())
4056   ///       handleAttr(A);                             handleAttr(A);
4057   ///     }
4058   ///   }
4059   ///
4060   ///   if (auto *D = (T)(D)) {            vs.     if (auto *D = (T)(D)) {
4061   ///     if (shouldProcess(D)) {                    if (shouldProcess(D))
4062   ///       handleVarDecl(D);                          handleVarDecl(D);
4063   ///     } else {                                   else
4064   ///       markAsIgnored(D);                          markAsIgnored(D);
4065   ///     }                                        }
4066   ///   }
4067   ///
4068   ///   if (a) {                           vs.     if (a)
4069   ///     b();                                       b();
4070   ///   } else {                                   else if (c)
4071   ///     if (c) {                                   d();
4072   ///       d();                                   else
4073   ///     } else {                                   e();
4074   ///       e();
4075   ///     }
4076   ///   }
4077   /// \endcode
4078   /// \version 14
4079   bool RemoveBracesLLVM;
4080 
4081   /// Remove empty lines within unwrapped lines.
4082   /// \code
4083   ///   false:                            true:
4084   ///
4085   ///   int c                  vs.        int c = a + b;
4086   ///
4087   ///       = a + b;
4088   ///
4089   ///   enum : unsigned        vs.        enum : unsigned {
4090   ///                                       AA = 0,
4091   ///   {                                   BB
4092   ///     AA = 0,                         } myEnum;
4093   ///     BB
4094   ///   } myEnum;
4095   ///
4096   ///   while (                vs.        while (true) {
4097   ///                                     }
4098   ///       true) {
4099   ///   }
4100   /// \endcode
4101   /// \version 20
4102   bool RemoveEmptyLinesInUnwrappedLines;
4103 
4104   /// Types of redundant parentheses to remove.
4105   enum RemoveParenthesesStyle : int8_t {
4106     /// Do not remove parentheses.
4107     /// \code
4108     ///   class __declspec((dllimport)) X {};
4109     ///   co_return (((0)));
4110     ///   return ((a + b) - ((c + d)));
4111     /// \endcode
4112     RPS_Leave,
4113     /// Replace multiple parentheses with single parentheses.
4114     /// \code
4115     ///   class __declspec(dllimport) X {};
4116     ///   co_return (0);
4117     ///   return ((a + b) - (c + d));
4118     /// \endcode
4119     RPS_MultipleParentheses,
4120     /// Also remove parentheses enclosing the expression in a
4121     /// ``return``/``co_return`` statement.
4122     /// \code
4123     ///   class __declspec(dllimport) X {};
4124     ///   co_return 0;
4125     ///   return (a + b) - (c + d);
4126     /// \endcode
4127     RPS_ReturnStatement,
4128   };
4129 
4130   /// Remove redundant parentheses.
4131   /// \warning
4132   ///  Setting this option to any value other than ``Leave`` could lead to
4133   ///  incorrect code formatting due to clang-format's lack of complete semantic
4134   ///  information. As such, extra care should be taken to review code changes
4135   ///  made by this option.
4136   /// \endwarning
4137   /// \version 17
4138   RemoveParenthesesStyle RemoveParentheses;
4139 
4140   /// Remove semicolons after the closing braces of functions and
4141   /// constructors/destructors.
4142   /// \warning
4143   ///  Setting this option to ``true`` could lead to incorrect code formatting
4144   ///  due to clang-format's lack of complete semantic information. As such,
4145   ///  extra care should be taken to review code changes made by this option.
4146   /// \endwarning
4147   /// \code
4148   ///   false:                                     true:
4149   ///
4150   ///   int max(int a, int b) {                    int max(int a, int b) {
4151   ///     return a > b ? a : b;                      return a > b ? a : b;
4152   ///   };                                         }
4153   ///
4154   /// \endcode
4155   /// \version 16
4156   bool RemoveSemicolon;
4157 
4158   /// The possible positions for the requires clause. The ``IndentRequires``
4159   /// option is only used if the ``requires`` is put on the start of a line.
4160   enum RequiresClausePositionStyle : int8_t {
4161     /// Always put the ``requires`` clause on its own line (possibly followed by
4162     /// a semicolon).
4163     /// \code
4164     ///   template <typename T>
4165     ///     requires C<T>
4166     ///   struct Foo {...
4167     ///
4168     ///   template <typename T>
4169     ///   void bar(T t)
4170     ///     requires C<T>;
4171     ///
4172     ///   template <typename T>
4173     ///     requires C<T>
4174     ///   void bar(T t) {...
4175     ///
4176     ///   template <typename T>
4177     ///   void baz(T t)
4178     ///     requires C<T>
4179     ///   {...
4180     /// \endcode
4181     RCPS_OwnLine,
4182     /// As with ``OwnLine``, except, unless otherwise prohibited, place a
4183     /// following open brace (of a function definition) to follow on the same
4184     /// line.
4185     /// \code
4186     ///   void bar(T t)
4187     ///     requires C<T> {
4188     ///     return;
4189     ///   }
4190     ///
4191     ///   void bar(T t)
4192     ///     requires C<T> {}
4193     ///
4194     ///   template <typename T>
4195     ///     requires C<T>
4196     ///   void baz(T t) {
4197     ///     ...
4198     /// \endcode
4199     RCPS_OwnLineWithBrace,
4200     /// Try to put the clause together with the preceding part of a declaration.
4201     /// For class templates: stick to the template declaration.
4202     /// For function templates: stick to the template declaration.
4203     /// For function declaration followed by a requires clause: stick to the
4204     /// parameter list.
4205     /// \code
4206     ///   template <typename T> requires C<T>
4207     ///   struct Foo {...
4208     ///
4209     ///   template <typename T> requires C<T>
4210     ///   void bar(T t) {...
4211     ///
4212     ///   template <typename T>
4213     ///   void baz(T t) requires C<T>
4214     ///   {...
4215     /// \endcode
4216     RCPS_WithPreceding,
4217     /// Try to put the ``requires`` clause together with the class or function
4218     /// declaration.
4219     /// \code
4220     ///   template <typename T>
4221     ///   requires C<T> struct Foo {...
4222     ///
4223     ///   template <typename T>
4224     ///   requires C<T> void bar(T t) {...
4225     ///
4226     ///   template <typename T>
4227     ///   void baz(T t)
4228     ///   requires C<T> {...
4229     /// \endcode
4230     RCPS_WithFollowing,
4231     /// Try to put everything in the same line if possible. Otherwise normal
4232     /// line breaking rules take over.
4233     /// \code
4234     ///   // Fitting:
4235     ///   template <typename T> requires C<T> struct Foo {...
4236     ///
4237     ///   template <typename T> requires C<T> void bar(T t) {...
4238     ///
4239     ///   template <typename T> void bar(T t) requires C<T> {...
4240     ///
4241     ///   // Not fitting, one possible example:
4242     ///   template <typename LongName>
4243     ///   requires C<LongName>
4244     ///   struct Foo {...
4245     ///
4246     ///   template <typename LongName>
4247     ///   requires C<LongName>
4248     ///   void bar(LongName ln) {
4249     ///
4250     ///   template <typename LongName>
4251     ///   void bar(LongName ln)
4252     ///       requires C<LongName> {
4253     /// \endcode
4254     RCPS_SingleLine,
4255   };
4256 
4257   /// The position of the ``requires`` clause.
4258   /// \version 15
4259   RequiresClausePositionStyle RequiresClausePosition;
4260 
4261   /// Indentation logic for requires expression bodies.
4262   enum RequiresExpressionIndentationKind : int8_t {
4263     /// Align requires expression body relative to the indentation level of the
4264     /// outer scope the requires expression resides in.
4265     /// This is the default.
4266     /// \code
4267     ///    template <typename T>
4268     ///    concept C = requires(T t) {
4269     ///      ...
4270     ///    }
4271     /// \endcode
4272     REI_OuterScope,
4273     /// Align requires expression body relative to the ``requires`` keyword.
4274     /// \code
4275     ///    template <typename T>
4276     ///    concept C = requires(T t) {
4277     ///                  ...
4278     ///                }
4279     /// \endcode
4280     REI_Keyword,
4281   };
4282 
4283   /// The indentation used for requires expression bodies.
4284   /// \version 16
4285   RequiresExpressionIndentationKind RequiresExpressionIndentation;
4286 
4287   /// The style if definition blocks should be separated.
4288   enum SeparateDefinitionStyle : int8_t {
4289     /// Leave definition blocks as they are.
4290     SDS_Leave,
4291     /// Insert an empty line between definition blocks.
4292     SDS_Always,
4293     /// Remove any empty line between definition blocks.
4294     SDS_Never
4295   };
4296 
4297   /// Specifies the use of empty lines to separate definition blocks, including
4298   /// classes, structs, enums, and functions.
4299   /// \code
4300   ///    Never                  v.s.     Always
4301   ///    #include <cstring>              #include <cstring>
4302   ///    struct Foo {
4303   ///      int a, b, c;                  struct Foo {
4304   ///    };                                int a, b, c;
4305   ///    namespace Ns {                  };
4306   ///    class Bar {
4307   ///    public:                         namespace Ns {
4308   ///      struct Foobar {               class Bar {
4309   ///        int a;                      public:
4310   ///        int b;                        struct Foobar {
4311   ///      };                                int a;
4312   ///    private:                            int b;
4313   ///      int t;                          };
4314   ///      int method1() {
4315   ///        // ...                      private:
4316   ///      }                               int t;
4317   ///      enum List {
4318   ///        ITEM1,                        int method1() {
4319   ///        ITEM2                           // ...
4320   ///      };                              }
4321   ///      template<typename T>
4322   ///      int method2(T x) {              enum List {
4323   ///        // ...                          ITEM1,
4324   ///      }                                 ITEM2
4325   ///      int i, j, k;                    };
4326   ///      int method3(int par) {
4327   ///        // ...                        template<typename T>
4328   ///      }                               int method2(T x) {
4329   ///    };                                  // ...
4330   ///    class C {};                       }
4331   ///    }
4332   ///                                      int i, j, k;
4333   ///
4334   ///                                      int method3(int par) {
4335   ///                                        // ...
4336   ///                                      }
4337   ///                                    };
4338   ///
4339   ///                                    class C {};
4340   ///                                    }
4341   /// \endcode
4342   /// \version 14
4343   SeparateDefinitionStyle SeparateDefinitionBlocks;
4344 
4345   /// The maximal number of unwrapped lines that a short namespace spans.
4346   /// Defaults to 1.
4347   ///
4348   /// This determines the maximum length of short namespaces by counting
4349   /// unwrapped lines (i.e. containing neither opening nor closing
4350   /// namespace brace) and makes ``FixNamespaceComments`` omit adding
4351   /// end comments for those.
4352   /// \code
4353   ///    ShortNamespaceLines: 1     vs.     ShortNamespaceLines: 0
4354   ///    namespace a {                      namespace a {
4355   ///      int foo;                           int foo;
4356   ///    }                                  } // namespace a
4357   ///
4358   ///    ShortNamespaceLines: 1     vs.     ShortNamespaceLines: 0
4359   ///    namespace b {                      namespace b {
4360   ///      int foo;                           int foo;
4361   ///      int bar;                           int bar;
4362   ///    } // namespace b                   } // namespace b
4363   /// \endcode
4364   /// \version 13
4365   unsigned ShortNamespaceLines;
4366 
4367   /// Do not format macro definition body.
4368   /// \version 18
4369   bool SkipMacroDefinitionBody;
4370 
4371   /// Includes sorting options.
4372   struct SortIncludesOptions {
4373     /// If ``true``, includes are sorted based on the other suboptions below.
4374     /// (``Never`` is deprecated by ``Enabled: false``.)
4375     bool Enabled;
4376     /// Whether or not includes are sorted in a case-insensitive fashion.
4377     /// (``CaseSensitive`` and ``CaseInsensitive`` are deprecated by
4378     /// ``IgnoreCase: false`` and ``IgnoreCase: true``, respectively.)
4379     /// \code
4380     ///    true:                      false:
4381     ///    #include "A/B.h"    vs.    #include "A/B.h"
4382     ///    #include "A/b.h"           #include "A/b.h"
4383     ///    #include "a/b.h"           #include "B/A.h"
4384     ///    #include "B/A.h"           #include "B/a.h"
4385     ///    #include "B/a.h"           #include "a/b.h"
4386     /// \endcode
4387     bool IgnoreCase;
4388     bool operator==(const SortIncludesOptions &R) const {
4389       return Enabled == R.Enabled && IgnoreCase == R.IgnoreCase;
4390     }
4391     bool operator!=(const SortIncludesOptions &R) const {
4392       return !(*this == R);
4393     }
4394   };
4395 
4396   /// Controls if and how clang-format will sort ``#includes``.
4397   /// \version 3.8
4398   SortIncludesOptions SortIncludes;
4399 
4400   /// Position for Java Static imports.
4401   enum SortJavaStaticImportOptions : int8_t {
4402     /// Static imports are placed before non-static imports.
4403     /// \code{.java}
4404     ///   import static org.example.function1;
4405     ///
4406     ///   import org.example.ClassA;
4407     /// \endcode
4408     SJSIO_Before,
4409     /// Static imports are placed after non-static imports.
4410     /// \code{.java}
4411     ///   import org.example.ClassA;
4412     ///
4413     ///   import static org.example.function1;
4414     /// \endcode
4415     SJSIO_After,
4416   };
4417 
4418   /// When sorting Java imports, by default static imports are placed before
4419   /// non-static imports. If ``JavaStaticImportAfterImport`` is ``After``,
4420   /// static imports are placed after non-static imports.
4421   /// \version 12
4422   SortJavaStaticImportOptions SortJavaStaticImport;
4423 
4424   /// Using declaration sorting options.
4425   enum SortUsingDeclarationsOptions : int8_t {
4426     /// Using declarations are never sorted.
4427     /// \code
4428     ///    using std::chrono::duration_cast;
4429     ///    using std::move;
4430     ///    using boost::regex;
4431     ///    using boost::regex_constants::icase;
4432     ///    using std::string;
4433     /// \endcode
4434     SUD_Never,
4435     /// Using declarations are sorted in the order defined as follows:
4436     /// Split the strings by ``::`` and discard any initial empty strings. Sort
4437     /// the lists of names lexicographically, and within those groups, names are
4438     /// in case-insensitive lexicographic order.
4439     /// \code
4440     ///    using boost::regex;
4441     ///    using boost::regex_constants::icase;
4442     ///    using std::chrono::duration_cast;
4443     ///    using std::move;
4444     ///    using std::string;
4445     /// \endcode
4446     SUD_Lexicographic,
4447     /// Using declarations are sorted in the order defined as follows:
4448     /// Split the strings by ``::`` and discard any initial empty strings. The
4449     /// last element of each list is a non-namespace name; all others are
4450     /// namespace names. Sort the lists of names lexicographically, where the
4451     /// sort order of individual names is that all non-namespace names come
4452     /// before all namespace names, and within those groups, names are in
4453     /// case-insensitive lexicographic order.
4454     /// \code
4455     ///    using boost::regex;
4456     ///    using boost::regex_constants::icase;
4457     ///    using std::move;
4458     ///    using std::string;
4459     ///    using std::chrono::duration_cast;
4460     /// \endcode
4461     SUD_LexicographicNumeric,
4462   };
4463 
4464   /// Controls if and how clang-format will sort using declarations.
4465   /// \version 5
4466   SortUsingDeclarationsOptions SortUsingDeclarations;
4467 
4468   /// If ``true``, a space is inserted after C style casts.
4469   /// \code
4470   ///    true:                                  false:
4471   ///    (int) i;                       vs.     (int)i;
4472   /// \endcode
4473   /// \version 3.5
4474   bool SpaceAfterCStyleCast;
4475 
4476   /// If ``true``, a space is inserted after the logical not operator (``!``).
4477   /// \code
4478   ///    true:                                  false:
4479   ///    ! someExpression();            vs.     !someExpression();
4480   /// \endcode
4481   /// \version 9
4482   bool SpaceAfterLogicalNot;
4483 
4484   /// If ``true``, a space will be inserted after the ``operator`` keyword.
4485   /// \code
4486   ///    true:                                false:
4487   ///    bool operator ==(int a);     vs.     bool operator==(int a);
4488   /// \endcode
4489   /// \version 21
4490   bool SpaceAfterOperatorKeyword;
4491 
4492   /// If \c true, a space will be inserted after the ``template`` keyword.
4493   /// \code
4494   ///    true:                                  false:
4495   ///    template <int> void foo();     vs.     template<int> void foo();
4496   /// \endcode
4497   /// \version 4
4498   bool SpaceAfterTemplateKeyword;
4499 
4500   /// Different ways to put a space before opening parentheses.
4501   enum SpaceAroundPointerQualifiersStyle : int8_t {
4502     /// Don't ensure spaces around pointer qualifiers and use PointerAlignment
4503     /// instead.
4504     /// \code
4505     ///    PointerAlignment: Left                 PointerAlignment: Right
4506     ///    void* const* x = NULL;         vs.     void *const *x = NULL;
4507     /// \endcode
4508     SAPQ_Default,
4509     /// Ensure that there is a space before pointer qualifiers.
4510     /// \code
4511     ///    PointerAlignment: Left                 PointerAlignment: Right
4512     ///    void* const* x = NULL;         vs.     void * const *x = NULL;
4513     /// \endcode
4514     SAPQ_Before,
4515     /// Ensure that there is a space after pointer qualifiers.
4516     /// \code
4517     ///    PointerAlignment: Left                 PointerAlignment: Right
4518     ///    void* const * x = NULL;         vs.     void *const *x = NULL;
4519     /// \endcode
4520     SAPQ_After,
4521     /// Ensure that there is a space both before and after pointer qualifiers.
4522     /// \code
4523     ///    PointerAlignment: Left                 PointerAlignment: Right
4524     ///    void* const * x = NULL;         vs.     void * const *x = NULL;
4525     /// \endcode
4526     SAPQ_Both,
4527   };
4528 
4529   ///  Defines in which cases to put a space before or after pointer qualifiers
4530   /// \version 12
4531   SpaceAroundPointerQualifiersStyle SpaceAroundPointerQualifiers;
4532 
4533   /// If ``false``, spaces will be removed before assignment operators.
4534   /// \code
4535   ///    true:                                  false:
4536   ///    int a = 5;                     vs.     int a= 5;
4537   ///    a += 42;                               a+= 42;
4538   /// \endcode
4539   /// \version 3.7
4540   bool SpaceBeforeAssignmentOperators;
4541 
4542   /// If ``false``, spaces will be removed before case colon.
4543   /// \code
4544   ///   true:                                   false
4545   ///   switch (x) {                    vs.     switch (x) {
4546   ///     case 1 : break;                         case 1: break;
4547   ///   }                                       }
4548   /// \endcode
4549   /// \version 12
4550   bool SpaceBeforeCaseColon;
4551 
4552   /// If ``true``, a space will be inserted before a C++11 braced list
4553   /// used to initialize an object (after the preceding identifier or type).
4554   /// \code
4555   ///    true:                                  false:
4556   ///    Foo foo { bar };               vs.     Foo foo{ bar };
4557   ///    Foo {};                                Foo{};
4558   ///    vector<int> { 1, 2, 3 };               vector<int>{ 1, 2, 3 };
4559   ///    new int[3] { 1, 2, 3 };                new int[3]{ 1, 2, 3 };
4560   /// \endcode
4561   /// \version 7
4562   bool SpaceBeforeCpp11BracedList;
4563 
4564   /// If ``false``, spaces will be removed before constructor initializer
4565   /// colon.
4566   /// \code
4567   ///    true:                                  false:
4568   ///    Foo::Foo() : a(a) {}                   Foo::Foo(): a(a) {}
4569   /// \endcode
4570   /// \version 7
4571   bool SpaceBeforeCtorInitializerColon;
4572 
4573   /// If ``false``, spaces will be removed before inheritance colon.
4574   /// \code
4575   ///    true:                                  false:
4576   ///    class Foo : Bar {}             vs.     class Foo: Bar {}
4577   /// \endcode
4578   /// \version 7
4579   bool SpaceBeforeInheritanceColon;
4580 
4581   /// If ``true``, a space will be added before a JSON colon. For other
4582   /// languages, e.g. JavaScript, use ``SpacesInContainerLiterals`` instead.
4583   /// \code
4584   ///    true:                                  false:
4585   ///    {                                      {
4586   ///      "key" : "value"              vs.       "key": "value"
4587   ///    }                                      }
4588   /// \endcode
4589   /// \version 17
4590   bool SpaceBeforeJsonColon;
4591 
4592   /// Different ways to put a space before opening parentheses.
4593   enum SpaceBeforeParensStyle : int8_t {
4594     /// This is **deprecated** and replaced by ``Custom`` below, with all
4595     /// ``SpaceBeforeParensOptions`` but ``AfterPlacementOperator`` set to
4596     /// ``false``.
4597     SBPO_Never,
4598     /// Put a space before opening parentheses only after control statement
4599     /// keywords (``for/if/while...``).
4600     /// \code
4601     ///    void f() {
4602     ///      if (true) {
4603     ///        f();
4604     ///      }
4605     ///    }
4606     /// \endcode
4607     SBPO_ControlStatements,
4608     /// Same as ``SBPO_ControlStatements`` except this option doesn't apply to
4609     /// ForEach and If macros. This is useful in projects where ForEach/If
4610     /// macros are treated as function calls instead of control statements.
4611     /// ``SBPO_ControlStatementsExceptForEachMacros`` remains an alias for
4612     /// backward compatibility.
4613     /// \code
4614     ///    void f() {
4615     ///      Q_FOREACH(...) {
4616     ///        f();
4617     ///      }
4618     ///    }
4619     /// \endcode
4620     SBPO_ControlStatementsExceptControlMacros,
4621     /// Put a space before opening parentheses only if the parentheses are not
4622     /// empty.
4623     /// \code
4624     ///   void() {
4625     ///     if (true) {
4626     ///       f();
4627     ///       g (x, y, z);
4628     ///     }
4629     ///   }
4630     /// \endcode
4631     SBPO_NonEmptyParentheses,
4632     /// Always put a space before opening parentheses, except when it's
4633     /// prohibited by the syntax rules (in function-like macro definitions) or
4634     /// when determined by other style rules (after unary operators, opening
4635     /// parentheses, etc.)
4636     /// \code
4637     ///    void f () {
4638     ///      if (true) {
4639     ///        f ();
4640     ///      }
4641     ///    }
4642     /// \endcode
4643     SBPO_Always,
4644     /// Configure each individual space before parentheses in
4645     /// ``SpaceBeforeParensOptions``.
4646     SBPO_Custom,
4647   };
4648 
4649   /// Defines in which cases to put a space before opening parentheses.
4650   /// \version 3.5
4651   SpaceBeforeParensStyle SpaceBeforeParens;
4652 
4653   /// Precise control over the spacing before parentheses.
4654   /// \code
4655   ///   # Should be declared this way:
4656   ///   SpaceBeforeParens: Custom
4657   ///   SpaceBeforeParensOptions:
4658   ///     AfterControlStatements: true
4659   ///     AfterFunctionDefinitionName: true
4660   /// \endcode
4661   struct SpaceBeforeParensCustom {
4662     /// If ``true``, put space between control statement keywords
4663     /// (for/if/while...) and opening parentheses.
4664     /// \code
4665     ///    true:                                  false:
4666     ///    if (...) {}                     vs.    if(...) {}
4667     /// \endcode
4668     bool AfterControlStatements;
4669     /// If ``true``, put space between foreach macros and opening parentheses.
4670     /// \code
4671     ///    true:                                  false:
4672     ///    FOREACH (...)                   vs.    FOREACH(...)
4673     ///      <loop-body>                            <loop-body>
4674     /// \endcode
4675     bool AfterForeachMacros;
4676     /// If ``true``, put a space between function declaration name and opening
4677     /// parentheses.
4678     /// \code
4679     ///    true:                                  false:
4680     ///    void f ();                      vs.    void f();
4681     /// \endcode
4682     bool AfterFunctionDeclarationName;
4683     /// If ``true``, put a space between function definition name and opening
4684     /// parentheses.
4685     /// \code
4686     ///    true:                                  false:
4687     ///    void f () {}                    vs.    void f() {}
4688     /// \endcode
4689     bool AfterFunctionDefinitionName;
4690     /// If ``true``, put space between if macros and opening parentheses.
4691     /// \code
4692     ///    true:                                  false:
4693     ///    IF (...)                        vs.    IF(...)
4694     ///      <conditional-body>                     <conditional-body>
4695     /// \endcode
4696     bool AfterIfMacros;
4697     /// If ``true``, put a space between alternative operator ``not`` and the
4698     /// opening parenthesis.
4699     /// \code
4700     ///    true:                                  false:
4701     ///    return not (a || b);            vs.    return not(a || b);
4702     /// \endcode
4703     bool AfterNot;
4704     /// If ``true``, put a space between operator overloading and opening
4705     /// parentheses.
4706     /// \code
4707     ///    true:                                  false:
4708     ///    void operator++ (int a);        vs.    void operator++(int a);
4709     ///    object.operator++ (10);                object.operator++(10);
4710     /// \endcode
4711     bool AfterOverloadedOperator;
4712     /// If ``true``, put a space between operator ``new``/``delete`` and opening
4713     /// parenthesis.
4714     /// \code
4715     ///    true:                                  false:
4716     ///    new (buf) T;                    vs.    new(buf) T;
4717     ///    delete (buf) T;                        delete(buf) T;
4718     /// \endcode
4719     bool AfterPlacementOperator;
4720     /// If ``true``, put space between requires keyword in a requires clause and
4721     /// opening parentheses, if there is one.
4722     /// \code
4723     ///    true:                                  false:
4724     ///    template<typename T>            vs.    template<typename T>
4725     ///    requires (A<T> && B<T>)                requires(A<T> && B<T>)
4726     ///    ...                                    ...
4727     /// \endcode
4728     bool AfterRequiresInClause;
4729     /// If ``true``, put space between requires keyword in a requires expression
4730     /// and opening parentheses.
4731     /// \code
4732     ///    true:                                  false:
4733     ///    template<typename T>            vs.    template<typename T>
4734     ///    concept C = requires (T t) {           concept C = requires(T t) {
4735     ///                  ...                                    ...
4736     ///                }                                      }
4737     /// \endcode
4738     bool AfterRequiresInExpression;
4739     /// If ``true``, put a space before opening parentheses only if the
4740     /// parentheses are not empty.
4741     /// \code
4742     ///    true:                                  false:
4743     ///    void f (int a);                 vs.    void f();
4744     ///    f (a);                                 f();
4745     /// \endcode
4746     bool BeforeNonEmptyParentheses;
4747 
SpaceBeforeParensCustomFormatStyle::SpaceBeforeParensCustom4748     SpaceBeforeParensCustom()
4749         : AfterControlStatements(false), AfterForeachMacros(false),
4750           AfterFunctionDeclarationName(false),
4751           AfterFunctionDefinitionName(false), AfterIfMacros(false),
4752           AfterNot(false), AfterOverloadedOperator(false),
4753           AfterPlacementOperator(true), AfterRequiresInClause(false),
4754           AfterRequiresInExpression(false), BeforeNonEmptyParentheses(false) {}
4755 
4756     bool operator==(const SpaceBeforeParensCustom &Other) const {
4757       return AfterControlStatements == Other.AfterControlStatements &&
4758              AfterForeachMacros == Other.AfterForeachMacros &&
4759              AfterFunctionDeclarationName ==
4760                  Other.AfterFunctionDeclarationName &&
4761              AfterFunctionDefinitionName == Other.AfterFunctionDefinitionName &&
4762              AfterIfMacros == Other.AfterIfMacros &&
4763              AfterNot == Other.AfterNot &&
4764              AfterOverloadedOperator == Other.AfterOverloadedOperator &&
4765              AfterPlacementOperator == Other.AfterPlacementOperator &&
4766              AfterRequiresInClause == Other.AfterRequiresInClause &&
4767              AfterRequiresInExpression == Other.AfterRequiresInExpression &&
4768              BeforeNonEmptyParentheses == Other.BeforeNonEmptyParentheses;
4769     }
4770   };
4771 
4772   /// Control of individual space before parentheses.
4773   ///
4774   /// If ``SpaceBeforeParens`` is set to ``Custom``, use this to specify
4775   /// how each individual space before parentheses case should be handled.
4776   /// Otherwise, this is ignored.
4777   /// \code{.yaml}
4778   ///   # Example of usage:
4779   ///   SpaceBeforeParens: Custom
4780   ///   SpaceBeforeParensOptions:
4781   ///     AfterControlStatements: true
4782   ///     AfterFunctionDefinitionName: true
4783   /// \endcode
4784   /// \version 14
4785   SpaceBeforeParensCustom SpaceBeforeParensOptions;
4786 
4787   /// If ``true``, spaces will be before  ``[``.
4788   /// Lambdas will not be affected. Only the first ``[`` will get a space added.
4789   /// \code
4790   ///    true:                                  false:
4791   ///    int a [5];                    vs.      int a[5];
4792   ///    int a [5][5];                 vs.      int a[5][5];
4793   /// \endcode
4794   /// \version 10
4795   bool SpaceBeforeSquareBrackets;
4796 
4797   /// If ``false``, spaces will be removed before range-based for loop
4798   /// colon.
4799   /// \code
4800   ///    true:                                  false:
4801   ///    for (auto v : values) {}       vs.     for(auto v: values) {}
4802   /// \endcode
4803   /// \version 7
4804   bool SpaceBeforeRangeBasedForLoopColon;
4805 
4806   /// If ``true``, spaces will be inserted into ``{}``.
4807   /// \code
4808   ///    true:                                false:
4809   ///    void f() { }                   vs.   void f() {}
4810   ///    while (true) { }                     while (true) {}
4811   /// \endcode
4812   /// \version 10
4813   bool SpaceInEmptyBlock;
4814 
4815   /// If ``true``, spaces may be inserted into ``()``.
4816   /// This option is **deprecated**. See ``InEmptyParentheses`` of
4817   /// ``SpacesInParensOptions``.
4818   /// \version 3.7
4819   // bool SpaceInEmptyParentheses;
4820 
4821   /// The number of spaces before trailing line comments
4822   /// (``//`` - comments).
4823   ///
4824   /// This does not affect trailing block comments (``/*`` - comments) as those
4825   /// commonly have different usage patterns and a number of special cases.  In
4826   /// the case of Verilog, it doesn't affect a comment right after the opening
4827   /// parenthesis in the port or parameter list in a module header, because it
4828   /// is probably for the port on the following line instead of the parenthesis
4829   /// it follows.
4830   /// \code
4831   ///    SpacesBeforeTrailingComments: 3
4832   ///    void f() {
4833   ///      if (true) {   // foo1
4834   ///        f();        // bar
4835   ///      }             // foo
4836   ///    }
4837   /// \endcode
4838   /// \version 3.7
4839   unsigned SpacesBeforeTrailingComments;
4840 
4841   /// Styles for adding spacing after ``<`` and before ``>``
4842   ///  in template argument lists.
4843   enum SpacesInAnglesStyle : int8_t {
4844     /// Remove spaces after ``<`` and before ``>``.
4845     /// \code
4846     ///    static_cast<int>(arg);
4847     ///    std::function<void(int)> fct;
4848     /// \endcode
4849     SIAS_Never,
4850     /// Add spaces after ``<`` and before ``>``.
4851     /// \code
4852     ///    static_cast< int >(arg);
4853     ///    std::function< void(int) > fct;
4854     /// \endcode
4855     SIAS_Always,
4856     /// Keep a single space after ``<`` and before ``>`` if any spaces were
4857     /// present. Option ``Standard: Cpp03`` takes precedence.
4858     SIAS_Leave
4859   };
4860   /// The SpacesInAnglesStyle to use for template argument lists.
4861   /// \version 3.4
4862   SpacesInAnglesStyle SpacesInAngles;
4863 
4864   /// If ``true``, spaces will be inserted around if/for/switch/while
4865   /// conditions.
4866   /// This option is **deprecated**. See ``InConditionalStatements`` of
4867   /// ``SpacesInParensOptions``.
4868   /// \version 10
4869   // bool SpacesInConditionalStatement;
4870 
4871   /// If ``true``, spaces are inserted inside container literals (e.g.  ObjC and
4872   /// Javascript array and dict literals). For JSON, use
4873   /// ``SpaceBeforeJsonColon`` instead.
4874   /// \code{.js}
4875   ///    true:                                  false:
4876   ///    var arr = [ 1, 2, 3 ];         vs.     var arr = [1, 2, 3];
4877   ///    f({a : 1, b : 2, c : 3});              f({a: 1, b: 2, c: 3});
4878   /// \endcode
4879   /// \version 3.7
4880   bool SpacesInContainerLiterals;
4881 
4882   /// If ``true``, spaces may be inserted into C style casts.
4883   /// This option is **deprecated**. See ``InCStyleCasts`` of
4884   /// ``SpacesInParensOptions``.
4885   /// \version 3.7
4886   // bool SpacesInCStyleCastParentheses;
4887 
4888   /// Control of spaces within a single line comment.
4889   struct SpacesInLineComment {
4890     /// The minimum number of spaces at the start of the comment.
4891     unsigned Minimum;
4892     /// The maximum number of spaces at the start of the comment.
4893     unsigned Maximum;
4894   };
4895 
4896   /// How many spaces are allowed at the start of a line comment. To disable the
4897   /// maximum set it to ``-1``, apart from that the maximum takes precedence
4898   /// over the minimum.
4899   /// \code
4900   ///   Minimum = 1
4901   ///   Maximum = -1
4902   ///   // One space is forced
4903   ///
4904   ///   //  but more spaces are possible
4905   ///
4906   ///   Minimum = 0
4907   ///   Maximum = 0
4908   ///   //Forces to start every comment directly after the slashes
4909   /// \endcode
4910   ///
4911   /// Note that in line comment sections the relative indent of the subsequent
4912   /// lines is kept, that means the following:
4913   /// \code
4914   ///   before:                                   after:
4915   ///   Minimum: 1
4916   ///   //if (b) {                                // if (b) {
4917   ///   //  return true;                          //   return true;
4918   ///   //}                                       // }
4919   ///
4920   ///   Maximum: 0
4921   ///   /// List:                                 ///List:
4922   ///   ///  - Foo                                /// - Foo
4923   ///   ///    - Bar                              ///   - Bar
4924   /// \endcode
4925   ///
4926   /// This option has only effect if ``ReflowComments`` is set to ``true``.
4927   /// \version 13
4928   SpacesInLineComment SpacesInLineCommentPrefix;
4929 
4930   /// Different ways to put a space before opening and closing parentheses.
4931   enum SpacesInParensStyle : int8_t {
4932     /// Never put a space in parentheses.
4933     /// \code
4934     ///    void f() {
4935     ///      if(true) {
4936     ///        f();
4937     ///      }
4938     ///    }
4939     /// \endcode
4940     SIPO_Never,
4941     /// Configure each individual space in parentheses in
4942     /// `SpacesInParensOptions`.
4943     SIPO_Custom,
4944   };
4945 
4946   /// If ``true``, spaces will be inserted after ``(`` and before ``)``.
4947   /// This option is **deprecated**. The previous behavior is preserved by using
4948   /// ``SpacesInParens`` with ``Custom`` and by setting all
4949   /// ``SpacesInParensOptions`` to ``true`` except for ``InCStyleCasts`` and
4950   /// ``InEmptyParentheses``.
4951   /// \version 3.7
4952   // bool SpacesInParentheses;
4953 
4954   /// Defines in which cases spaces will be inserted after ``(`` and before
4955   /// ``)``.
4956   /// \version 17
4957   SpacesInParensStyle SpacesInParens;
4958 
4959   /// Precise control over the spacing in parentheses.
4960   /// \code
4961   ///   # Should be declared this way:
4962   ///   SpacesInParens: Custom
4963   ///   SpacesInParensOptions:
4964   ///     ExceptDoubleParentheses: false
4965   ///     InConditionalStatements: true
4966   ///     Other: true
4967   /// \endcode
4968   struct SpacesInParensCustom {
4969     /// Override any of the following options to prevent addition of space
4970     /// when both opening and closing parentheses use multiple parentheses.
4971     /// \code
4972     ///   true:
4973     ///   __attribute__(( noreturn ))
4974     ///   __decltype__(( x ))
4975     ///   if (( a = b ))
4976     /// \endcode
4977     ///  false:
4978     ///    Uses the applicable option.
4979     bool ExceptDoubleParentheses;
4980     /// Put a space in parentheses only inside conditional statements
4981     /// (``for/if/while/switch...``).
4982     /// \code
4983     ///    true:                                  false:
4984     ///    if ( a )  { ... }              vs.     if (a) { ... }
4985     ///    while ( i < 5 )  { ... }               while (i < 5) { ... }
4986     /// \endcode
4987     bool InConditionalStatements;
4988     /// Put a space in C style casts.
4989     /// \code
4990     ///   true:                                  false:
4991     ///   x = ( int32 )y                  vs.    x = (int32)y
4992     ///   y = (( int (*)(int) )foo)(x);          y = ((int (*)(int))foo)(x);
4993     /// \endcode
4994     bool InCStyleCasts;
4995     /// Insert a space in empty parentheses, i.e. ``()``.
4996     /// \code
4997     ///    true:                                false:
4998     ///    void f( ) {                    vs.   void f() {
4999     ///      int x[] = {foo( ), bar( )};          int x[] = {foo(), bar()};
5000     ///      if (true) {                          if (true) {
5001     ///        f( );                                f();
5002     ///      }                                    }
5003     ///    }                                    }
5004     /// \endcode
5005     bool InEmptyParentheses;
5006     /// Put a space in parentheses not covered by preceding options.
5007     /// \code
5008     ///   true:                                 false:
5009     ///   t f( Deleted & ) & = delete;    vs.   t f(Deleted &) & = delete;
5010     /// \endcode
5011     bool Other;
5012 
SpacesInParensCustomFormatStyle::SpacesInParensCustom5013     SpacesInParensCustom()
5014         : ExceptDoubleParentheses(false), InConditionalStatements(false),
5015           InCStyleCasts(false), InEmptyParentheses(false), Other(false) {}
5016 
SpacesInParensCustomFormatStyle::SpacesInParensCustom5017     SpacesInParensCustom(bool ExceptDoubleParentheses,
5018                          bool InConditionalStatements, bool InCStyleCasts,
5019                          bool InEmptyParentheses, bool Other)
5020         : ExceptDoubleParentheses(ExceptDoubleParentheses),
5021           InConditionalStatements(InConditionalStatements),
5022           InCStyleCasts(InCStyleCasts), InEmptyParentheses(InEmptyParentheses),
5023           Other(Other) {}
5024 
5025     bool operator==(const SpacesInParensCustom &R) const {
5026       return ExceptDoubleParentheses == R.ExceptDoubleParentheses &&
5027              InConditionalStatements == R.InConditionalStatements &&
5028              InCStyleCasts == R.InCStyleCasts &&
5029              InEmptyParentheses == R.InEmptyParentheses && Other == R.Other;
5030     }
5031     bool operator!=(const SpacesInParensCustom &R) const {
5032       return !(*this == R);
5033     }
5034   };
5035 
5036   /// Control of individual spaces in parentheses.
5037   ///
5038   /// If ``SpacesInParens`` is set to ``Custom``, use this to specify
5039   /// how each individual space in parentheses case should be handled.
5040   /// Otherwise, this is ignored.
5041   /// \code{.yaml}
5042   ///   # Example of usage:
5043   ///   SpacesInParens: Custom
5044   ///   SpacesInParensOptions:
5045   ///     ExceptDoubleParentheses: false
5046   ///     InConditionalStatements: true
5047   ///     InEmptyParentheses: true
5048   /// \endcode
5049   /// \version 17
5050   SpacesInParensCustom SpacesInParensOptions;
5051 
5052   /// If ``true``, spaces will be inserted after ``[`` and before ``]``.
5053   /// Lambdas without arguments or unspecified size array declarations will not
5054   /// be affected.
5055   /// \code
5056   ///    true:                                  false:
5057   ///    int a[ 5 ];                    vs.     int a[5];
5058   ///    std::unique_ptr<int[]> foo() {} // Won't be affected
5059   /// \endcode
5060   /// \version 3.7
5061   bool SpacesInSquareBrackets;
5062 
5063   /// Supported language standards for parsing and formatting C++ constructs.
5064   /// \code
5065   ///    Latest:                                vector<set<int>>
5066   ///    c++03                          vs.     vector<set<int> >
5067   /// \endcode
5068   ///
5069   /// The correct way to spell a specific language version is e.g. ``c++11``.
5070   /// The historical aliases ``Cpp03`` and ``Cpp11`` are deprecated.
5071   enum LanguageStandard : int8_t {
5072     /// Parse and format as C++03.
5073     /// ``Cpp03`` is a deprecated alias for ``c++03``
5074     LS_Cpp03, // c++03
5075     /// Parse and format as C++11.
5076     LS_Cpp11, // c++11
5077     /// Parse and format as C++14.
5078     LS_Cpp14, // c++14
5079     /// Parse and format as C++17.
5080     LS_Cpp17, // c++17
5081     /// Parse and format as C++20.
5082     LS_Cpp20, // c++20
5083     /// Parse and format using the latest supported language version.
5084     /// ``Cpp11`` is a deprecated alias for ``Latest``
5085     LS_Latest,
5086     /// Automatic detection based on the input.
5087     LS_Auto,
5088   };
5089 
5090   /// Parse and format C++ constructs compatible with this standard.
5091   /// \code
5092   ///    c++03:                                 latest:
5093   ///    vector<set<int> > x;           vs.     vector<set<int>> x;
5094   /// \endcode
5095   /// \version 3.7
5096   LanguageStandard Standard;
5097 
5098   /// Macros which are ignored in front of a statement, as if they were an
5099   /// attribute. So that they are not parsed as identifier, for example for Qts
5100   /// emit.
5101   /// \code
5102   ///   AlignConsecutiveDeclarations: true
5103   ///   StatementAttributeLikeMacros: []
5104   ///   unsigned char data = 'x';
5105   ///   emit          signal(data); // This is parsed as variable declaration.
5106   ///
5107   ///   AlignConsecutiveDeclarations: true
5108   ///   StatementAttributeLikeMacros: [emit]
5109   ///   unsigned char data = 'x';
5110   ///   emit signal(data); // Now it's fine again.
5111   /// \endcode
5112   /// \version 12
5113   std::vector<std::string> StatementAttributeLikeMacros;
5114 
5115   /// A vector of macros that should be interpreted as complete statements.
5116   ///
5117   /// Typical macros are expressions and require a semicolon to be added.
5118   /// Sometimes this is not the case, and this allows to make clang-format aware
5119   /// of such cases.
5120   ///
5121   /// For example: Q_UNUSED
5122   /// \version 8
5123   std::vector<std::string> StatementMacros;
5124 
5125   /// Works only when TableGenBreakInsideDAGArg is not DontBreak.
5126   /// The string list needs to consist of identifiers in TableGen.
5127   /// If any identifier is specified, this limits the line breaks by
5128   /// TableGenBreakInsideDAGArg option only on DAGArg values beginning with
5129   /// the specified identifiers.
5130   ///
5131   /// For example the configuration,
5132   /// \code{.yaml}
5133   ///   TableGenBreakInsideDAGArg: BreakAll
5134   ///   TableGenBreakingDAGArgOperators: [ins, outs]
5135   /// \endcode
5136   ///
5137   /// makes the line break only occurs inside DAGArgs beginning with the
5138   /// specified identifiers ``ins`` and ``outs``.
5139   ///
5140   /// \code
5141   ///   let DAGArgIns = (ins
5142   ///       i32:$src1,
5143   ///       i32:$src2
5144   ///   );
5145   ///   let DAGArgOtherID = (other i32:$other1, i32:$other2);
5146   ///   let DAGArgBang = (!cast<SomeType>("Some") i32:$src1, i32:$src2)
5147   /// \endcode
5148   /// \version 19
5149   std::vector<std::string> TableGenBreakingDAGArgOperators;
5150 
5151   /// Different ways to control the format inside TableGen DAGArg.
5152   enum DAGArgStyle : int8_t {
5153     /// Never break inside DAGArg.
5154     /// \code
5155     ///   let DAGArgIns = (ins i32:$src1, i32:$src2);
5156     /// \endcode
5157     DAS_DontBreak,
5158     /// Break inside DAGArg after each list element but for the last.
5159     /// This aligns to the first element.
5160     /// \code
5161     ///   let DAGArgIns = (ins i32:$src1,
5162     ///                        i32:$src2);
5163     /// \endcode
5164     DAS_BreakElements,
5165     /// Break inside DAGArg after the operator and the all elements.
5166     /// \code
5167     ///   let DAGArgIns = (ins
5168     ///       i32:$src1,
5169     ///       i32:$src2
5170     ///   );
5171     /// \endcode
5172     DAS_BreakAll,
5173   };
5174 
5175   /// The styles of the line break inside the DAGArg in TableGen.
5176   /// \version 19
5177   DAGArgStyle TableGenBreakInsideDAGArg;
5178 
5179   /// The number of columns used for tab stops.
5180   /// \version 3.7
5181   unsigned TabWidth;
5182 
5183   /// A vector of non-keyword identifiers that should be interpreted as template
5184   /// names.
5185   ///
5186   /// A ``<`` after a template name is annotated as a template opener instead of
5187   /// a binary operator.
5188   ///
5189   /// \version 20
5190   std::vector<std::string> TemplateNames;
5191 
5192   /// A vector of non-keyword identifiers that should be interpreted as type
5193   /// names.
5194   ///
5195   /// A ``*``, ``&``, or ``&&`` between a type name and another non-keyword
5196   /// identifier is annotated as a pointer or reference token instead of a
5197   /// binary operator.
5198   ///
5199   /// \version 17
5200   std::vector<std::string> TypeNames;
5201 
5202   /// A vector of macros that should be interpreted as type declarations instead
5203   /// of as function calls.
5204   ///
5205   /// These are expected to be macros of the form:
5206   /// \code
5207   ///   STACK_OF(...)
5208   /// \endcode
5209   ///
5210   /// In the .clang-format configuration file, this can be configured like:
5211   /// \code{.yaml}
5212   ///   TypenameMacros: [STACK_OF, LIST]
5213   /// \endcode
5214   ///
5215   /// For example: OpenSSL STACK_OF, BSD LIST_ENTRY.
5216   /// \version 9
5217   std::vector<std::string> TypenameMacros;
5218 
5219   /// This option is **deprecated**. See ``LF`` and ``CRLF`` of ``LineEnding``.
5220   /// \version 10
5221   // bool UseCRLF;
5222 
5223   /// Different ways to use tab in formatting.
5224   enum UseTabStyle : int8_t {
5225     /// Never use tab.
5226     UT_Never,
5227     /// Use tabs only for indentation.
5228     UT_ForIndentation,
5229     /// Fill all leading whitespace with tabs, and use spaces for alignment that
5230     /// appears within a line (e.g. consecutive assignments and declarations).
5231     UT_ForContinuationAndIndentation,
5232     /// Use tabs for line continuation and indentation, and spaces for
5233     /// alignment.
5234     UT_AlignWithSpaces,
5235     /// Use tabs whenever we need to fill whitespace that spans at least from
5236     /// one tab stop to the next one.
5237     UT_Always
5238   };
5239 
5240   /// The way to use tab characters in the resulting file.
5241   /// \version 3.7
5242   UseTabStyle UseTab;
5243 
5244   /// A vector of non-keyword identifiers that should be interpreted as variable
5245   /// template names.
5246   ///
5247   /// A ``)`` after a variable template instantiation is **not** annotated as
5248   /// the closing parenthesis of C-style cast operator.
5249   ///
5250   /// \version 20
5251   std::vector<std::string> VariableTemplates;
5252 
5253   /// For Verilog, put each port on its own line in module instantiations.
5254   /// \code
5255   ///    true:
5256   ///    ffnand ff1(.q(),
5257   ///               .qbar(out1),
5258   ///               .clear(in1),
5259   ///               .preset(in2));
5260   ///
5261   ///    false:
5262   ///    ffnand ff1(.q(), .qbar(out1), .clear(in1), .preset(in2));
5263   /// \endcode
5264   /// \version 17
5265   bool VerilogBreakBetweenInstancePorts;
5266 
5267   /// A vector of macros which are whitespace-sensitive and should not
5268   /// be touched.
5269   ///
5270   /// These are expected to be macros of the form:
5271   /// \code
5272   ///   STRINGIZE(...)
5273   /// \endcode
5274   ///
5275   /// In the .clang-format configuration file, this can be configured like:
5276   /// \code{.yaml}
5277   ///   WhitespaceSensitiveMacros: [STRINGIZE, PP_STRINGIZE]
5278   /// \endcode
5279   ///
5280   /// For example: BOOST_PP_STRINGIZE
5281   /// \version 11
5282   std::vector<std::string> WhitespaceSensitiveMacros;
5283 
5284   /// Different styles for wrapping namespace body with empty lines.
5285   enum WrapNamespaceBodyWithEmptyLinesStyle : int8_t {
5286     /// Remove all empty lines at the beginning and the end of namespace body.
5287     /// \code
5288     ///   namespace N1 {
5289     ///   namespace N2 {
5290     ///   function();
5291     ///   }
5292     ///   }
5293     /// \endcode
5294     WNBWELS_Never,
5295     /// Always have at least one empty line at the beginning and the end of
5296     /// namespace body except that the number of empty lines between consecutive
5297     /// nested namespace definitions is not increased.
5298     /// \code
5299     ///   namespace N1 {
5300     ///   namespace N2 {
5301     ///
5302     ///   function();
5303     ///
5304     ///   }
5305     ///   }
5306     /// \endcode
5307     WNBWELS_Always,
5308     /// Keep existing newlines at the beginning and the end of namespace body.
5309     /// ``MaxEmptyLinesToKeep`` still applies.
5310     WNBWELS_Leave
5311   };
5312 
5313   /// Wrap namespace body with empty lines.
5314   /// \version 20
5315   WrapNamespaceBodyWithEmptyLinesStyle WrapNamespaceBodyWithEmptyLines;
5316 
5317   bool operator==(const FormatStyle &R) const {
5318     return AccessModifierOffset == R.AccessModifierOffset &&
5319            AlignAfterOpenBracket == R.AlignAfterOpenBracket &&
5320            AlignArrayOfStructures == R.AlignArrayOfStructures &&
5321            AlignConsecutiveAssignments == R.AlignConsecutiveAssignments &&
5322            AlignConsecutiveBitFields == R.AlignConsecutiveBitFields &&
5323            AlignConsecutiveDeclarations == R.AlignConsecutiveDeclarations &&
5324            AlignConsecutiveMacros == R.AlignConsecutiveMacros &&
5325            AlignConsecutiveShortCaseStatements ==
5326                R.AlignConsecutiveShortCaseStatements &&
5327            AlignConsecutiveTableGenBreakingDAGArgColons ==
5328                R.AlignConsecutiveTableGenBreakingDAGArgColons &&
5329            AlignConsecutiveTableGenCondOperatorColons ==
5330                R.AlignConsecutiveTableGenCondOperatorColons &&
5331            AlignConsecutiveTableGenDefinitionColons ==
5332                R.AlignConsecutiveTableGenDefinitionColons &&
5333            AlignEscapedNewlines == R.AlignEscapedNewlines &&
5334            AlignOperands == R.AlignOperands &&
5335            AlignTrailingComments == R.AlignTrailingComments &&
5336            AllowAllArgumentsOnNextLine == R.AllowAllArgumentsOnNextLine &&
5337            AllowAllParametersOfDeclarationOnNextLine ==
5338                R.AllowAllParametersOfDeclarationOnNextLine &&
5339            AllowBreakBeforeNoexceptSpecifier ==
5340                R.AllowBreakBeforeNoexceptSpecifier &&
5341            AllowShortBlocksOnASingleLine == R.AllowShortBlocksOnASingleLine &&
5342            AllowShortCaseExpressionOnASingleLine ==
5343                R.AllowShortCaseExpressionOnASingleLine &&
5344            AllowShortCaseLabelsOnASingleLine ==
5345                R.AllowShortCaseLabelsOnASingleLine &&
5346            AllowShortCompoundRequirementOnASingleLine ==
5347                R.AllowShortCompoundRequirementOnASingleLine &&
5348            AllowShortEnumsOnASingleLine == R.AllowShortEnumsOnASingleLine &&
5349            AllowShortFunctionsOnASingleLine ==
5350                R.AllowShortFunctionsOnASingleLine &&
5351            AllowShortIfStatementsOnASingleLine ==
5352                R.AllowShortIfStatementsOnASingleLine &&
5353            AllowShortLambdasOnASingleLine == R.AllowShortLambdasOnASingleLine &&
5354            AllowShortLoopsOnASingleLine == R.AllowShortLoopsOnASingleLine &&
5355            AllowShortNamespacesOnASingleLine ==
5356                R.AllowShortNamespacesOnASingleLine &&
5357            AlwaysBreakBeforeMultilineStrings ==
5358                R.AlwaysBreakBeforeMultilineStrings &&
5359            AttributeMacros == R.AttributeMacros &&
5360            BinPackArguments == R.BinPackArguments &&
5361            BinPackLongBracedList == R.BinPackLongBracedList &&
5362            BinPackParameters == R.BinPackParameters &&
5363            BitFieldColonSpacing == R.BitFieldColonSpacing &&
5364            BracedInitializerIndentWidth == R.BracedInitializerIndentWidth &&
5365            BreakAdjacentStringLiterals == R.BreakAdjacentStringLiterals &&
5366            BreakAfterAttributes == R.BreakAfterAttributes &&
5367            BreakAfterJavaFieldAnnotations == R.BreakAfterJavaFieldAnnotations &&
5368            BreakAfterReturnType == R.BreakAfterReturnType &&
5369            BreakArrays == R.BreakArrays &&
5370            BreakBeforeBinaryOperators == R.BreakBeforeBinaryOperators &&
5371            BreakBeforeBraces == R.BreakBeforeBraces &&
5372            BreakBeforeConceptDeclarations == R.BreakBeforeConceptDeclarations &&
5373            BreakBeforeInlineASMColon == R.BreakBeforeInlineASMColon &&
5374            BreakBeforeTemplateCloser == R.BreakBeforeTemplateCloser &&
5375            BreakBeforeTernaryOperators == R.BreakBeforeTernaryOperators &&
5376            BreakBinaryOperations == R.BreakBinaryOperations &&
5377            BreakConstructorInitializers == R.BreakConstructorInitializers &&
5378            BreakFunctionDefinitionParameters ==
5379                R.BreakFunctionDefinitionParameters &&
5380            BreakInheritanceList == R.BreakInheritanceList &&
5381            BreakStringLiterals == R.BreakStringLiterals &&
5382            BreakTemplateDeclarations == R.BreakTemplateDeclarations &&
5383            ColumnLimit == R.ColumnLimit && CommentPragmas == R.CommentPragmas &&
5384            CompactNamespaces == R.CompactNamespaces &&
5385            ConstructorInitializerIndentWidth ==
5386                R.ConstructorInitializerIndentWidth &&
5387            ContinuationIndentWidth == R.ContinuationIndentWidth &&
5388            Cpp11BracedListStyle == R.Cpp11BracedListStyle &&
5389            DerivePointerAlignment == R.DerivePointerAlignment &&
5390            DisableFormat == R.DisableFormat &&
5391            EmptyLineAfterAccessModifier == R.EmptyLineAfterAccessModifier &&
5392            EmptyLineBeforeAccessModifier == R.EmptyLineBeforeAccessModifier &&
5393            EnumTrailingComma == R.EnumTrailingComma &&
5394            ExperimentalAutoDetectBinPacking ==
5395                R.ExperimentalAutoDetectBinPacking &&
5396            FixNamespaceComments == R.FixNamespaceComments &&
5397            ForEachMacros == R.ForEachMacros &&
5398            IncludeStyle.IncludeBlocks == R.IncludeStyle.IncludeBlocks &&
5399            IncludeStyle.IncludeCategories == R.IncludeStyle.IncludeCategories &&
5400            IncludeStyle.IncludeIsMainRegex ==
5401                R.IncludeStyle.IncludeIsMainRegex &&
5402            IncludeStyle.IncludeIsMainSourceRegex ==
5403                R.IncludeStyle.IncludeIsMainSourceRegex &&
5404            IncludeStyle.MainIncludeChar == R.IncludeStyle.MainIncludeChar &&
5405            IndentAccessModifiers == R.IndentAccessModifiers &&
5406            IndentCaseBlocks == R.IndentCaseBlocks &&
5407            IndentCaseLabels == R.IndentCaseLabels &&
5408            IndentExportBlock == R.IndentExportBlock &&
5409            IndentExternBlock == R.IndentExternBlock &&
5410            IndentGotoLabels == R.IndentGotoLabels &&
5411            IndentPPDirectives == R.IndentPPDirectives &&
5412            IndentRequiresClause == R.IndentRequiresClause &&
5413            IndentWidth == R.IndentWidth &&
5414            IndentWrappedFunctionNames == R.IndentWrappedFunctionNames &&
5415            InsertBraces == R.InsertBraces &&
5416            InsertNewlineAtEOF == R.InsertNewlineAtEOF &&
5417            IntegerLiteralSeparator == R.IntegerLiteralSeparator &&
5418            JavaImportGroups == R.JavaImportGroups &&
5419            JavaScriptQuotes == R.JavaScriptQuotes &&
5420            JavaScriptWrapImports == R.JavaScriptWrapImports &&
5421            KeepEmptyLines == R.KeepEmptyLines &&
5422            KeepFormFeed == R.KeepFormFeed && Language == R.Language &&
5423            LambdaBodyIndentation == R.LambdaBodyIndentation &&
5424            LineEnding == R.LineEnding && MacroBlockBegin == R.MacroBlockBegin &&
5425            MacroBlockEnd == R.MacroBlockEnd && Macros == R.Macros &&
5426            MacrosSkippedByRemoveParentheses ==
5427                R.MacrosSkippedByRemoveParentheses &&
5428            MaxEmptyLinesToKeep == R.MaxEmptyLinesToKeep &&
5429            NamespaceIndentation == R.NamespaceIndentation &&
5430            NamespaceMacros == R.NamespaceMacros &&
5431            ObjCBinPackProtocolList == R.ObjCBinPackProtocolList &&
5432            ObjCBlockIndentWidth == R.ObjCBlockIndentWidth &&
5433            ObjCBreakBeforeNestedBlockParam ==
5434                R.ObjCBreakBeforeNestedBlockParam &&
5435            ObjCPropertyAttributeOrder == R.ObjCPropertyAttributeOrder &&
5436            ObjCSpaceAfterProperty == R.ObjCSpaceAfterProperty &&
5437            ObjCSpaceBeforeProtocolList == R.ObjCSpaceBeforeProtocolList &&
5438            OneLineFormatOffRegex == R.OneLineFormatOffRegex &&
5439            PackConstructorInitializers == R.PackConstructorInitializers &&
5440            PenaltyBreakAssignment == R.PenaltyBreakAssignment &&
5441            PenaltyBreakBeforeFirstCallParameter ==
5442                R.PenaltyBreakBeforeFirstCallParameter &&
5443            PenaltyBreakBeforeMemberAccess == R.PenaltyBreakBeforeMemberAccess &&
5444            PenaltyBreakComment == R.PenaltyBreakComment &&
5445            PenaltyBreakFirstLessLess == R.PenaltyBreakFirstLessLess &&
5446            PenaltyBreakOpenParenthesis == R.PenaltyBreakOpenParenthesis &&
5447            PenaltyBreakScopeResolution == R.PenaltyBreakScopeResolution &&
5448            PenaltyBreakString == R.PenaltyBreakString &&
5449            PenaltyBreakTemplateDeclaration ==
5450                R.PenaltyBreakTemplateDeclaration &&
5451            PenaltyExcessCharacter == R.PenaltyExcessCharacter &&
5452            PenaltyReturnTypeOnItsOwnLine == R.PenaltyReturnTypeOnItsOwnLine &&
5453            PointerAlignment == R.PointerAlignment &&
5454            QualifierAlignment == R.QualifierAlignment &&
5455            QualifierOrder == R.QualifierOrder &&
5456            RawStringFormats == R.RawStringFormats &&
5457            ReferenceAlignment == R.ReferenceAlignment &&
5458            RemoveBracesLLVM == R.RemoveBracesLLVM &&
5459            RemoveEmptyLinesInUnwrappedLines ==
5460                R.RemoveEmptyLinesInUnwrappedLines &&
5461            RemoveParentheses == R.RemoveParentheses &&
5462            RemoveSemicolon == R.RemoveSemicolon &&
5463            RequiresClausePosition == R.RequiresClausePosition &&
5464            RequiresExpressionIndentation == R.RequiresExpressionIndentation &&
5465            SeparateDefinitionBlocks == R.SeparateDefinitionBlocks &&
5466            ShortNamespaceLines == R.ShortNamespaceLines &&
5467            SkipMacroDefinitionBody == R.SkipMacroDefinitionBody &&
5468            SortIncludes == R.SortIncludes &&
5469            SortJavaStaticImport == R.SortJavaStaticImport &&
5470            SpaceAfterCStyleCast == R.SpaceAfterCStyleCast &&
5471            SpaceAfterLogicalNot == R.SpaceAfterLogicalNot &&
5472            SpaceAfterOperatorKeyword == R.SpaceAfterOperatorKeyword &&
5473            SpaceAfterTemplateKeyword == R.SpaceAfterTemplateKeyword &&
5474            SpaceBeforeAssignmentOperators == R.SpaceBeforeAssignmentOperators &&
5475            SpaceBeforeCaseColon == R.SpaceBeforeCaseColon &&
5476            SpaceBeforeCpp11BracedList == R.SpaceBeforeCpp11BracedList &&
5477            SpaceBeforeCtorInitializerColon ==
5478                R.SpaceBeforeCtorInitializerColon &&
5479            SpaceBeforeInheritanceColon == R.SpaceBeforeInheritanceColon &&
5480            SpaceBeforeJsonColon == R.SpaceBeforeJsonColon &&
5481            SpaceBeforeParens == R.SpaceBeforeParens &&
5482            SpaceBeforeParensOptions == R.SpaceBeforeParensOptions &&
5483            SpaceAroundPointerQualifiers == R.SpaceAroundPointerQualifiers &&
5484            SpaceBeforeRangeBasedForLoopColon ==
5485                R.SpaceBeforeRangeBasedForLoopColon &&
5486            SpaceBeforeSquareBrackets == R.SpaceBeforeSquareBrackets &&
5487            SpaceInEmptyBlock == R.SpaceInEmptyBlock &&
5488            SpacesBeforeTrailingComments == R.SpacesBeforeTrailingComments &&
5489            SpacesInAngles == R.SpacesInAngles &&
5490            SpacesInContainerLiterals == R.SpacesInContainerLiterals &&
5491            SpacesInLineCommentPrefix.Minimum ==
5492                R.SpacesInLineCommentPrefix.Minimum &&
5493            SpacesInLineCommentPrefix.Maximum ==
5494                R.SpacesInLineCommentPrefix.Maximum &&
5495            SpacesInParens == R.SpacesInParens &&
5496            SpacesInParensOptions == R.SpacesInParensOptions &&
5497            SpacesInSquareBrackets == R.SpacesInSquareBrackets &&
5498            Standard == R.Standard &&
5499            StatementAttributeLikeMacros == R.StatementAttributeLikeMacros &&
5500            StatementMacros == R.StatementMacros &&
5501            TableGenBreakingDAGArgOperators ==
5502                R.TableGenBreakingDAGArgOperators &&
5503            TableGenBreakInsideDAGArg == R.TableGenBreakInsideDAGArg &&
5504            TabWidth == R.TabWidth && TemplateNames == R.TemplateNames &&
5505            TypeNames == R.TypeNames && TypenameMacros == R.TypenameMacros &&
5506            UseTab == R.UseTab && VariableTemplates == R.VariableTemplates &&
5507            VerilogBreakBetweenInstancePorts ==
5508                R.VerilogBreakBetweenInstancePorts &&
5509            WhitespaceSensitiveMacros == R.WhitespaceSensitiveMacros &&
5510            WrapNamespaceBodyWithEmptyLines == R.WrapNamespaceBodyWithEmptyLines;
5511   }
5512 
5513   std::optional<FormatStyle> GetLanguageStyle(LanguageKind Language) const;
5514 
5515   // Stores per-language styles. A FormatStyle instance inside has an empty
5516   // StyleSet. A FormatStyle instance returned by the Get method has its
5517   // StyleSet set to a copy of the originating StyleSet, effectively keeping the
5518   // internal representation of that StyleSet alive.
5519   //
5520   // The memory management and ownership reminds of a birds nest: chicks
5521   // leaving the nest take photos of the nest with them.
5522   struct FormatStyleSet {
5523     typedef std::map<LanguageKind, FormatStyle> MapType;
5524 
5525     std::optional<FormatStyle> Get(LanguageKind Language) const;
5526 
5527     // Adds \p Style to this FormatStyleSet. Style must not have an associated
5528     // FormatStyleSet.
5529     // Style.Language should be different than LK_None. If this FormatStyleSet
5530     // already contains an entry for Style.Language, that gets replaced with the
5531     // passed Style.
5532     void Add(FormatStyle Style);
5533 
5534     // Clears this FormatStyleSet.
5535     void Clear();
5536 
5537   private:
5538     std::shared_ptr<MapType> Styles;
5539   };
5540 
5541   static FormatStyleSet BuildStyleSetFromConfiguration(
5542       const FormatStyle &MainStyle,
5543       const std::vector<FormatStyle> &ConfigurationStyles);
5544 
5545 private:
5546   FormatStyleSet StyleSet;
5547 
5548   friend std::error_code
5549   parseConfiguration(llvm::MemoryBufferRef Config, FormatStyle *Style,
5550                      bool AllowUnknownOptions,
5551                      llvm::SourceMgr::DiagHandlerTy DiagHandler,
5552                      void *DiagHandlerCtxt, bool IsDotHFile);
5553 };
5554 
5555 /// Returns a format style complying with the LLVM coding standards:
5556 /// http://llvm.org/docs/CodingStandards.html.
5557 FormatStyle
5558 getLLVMStyle(FormatStyle::LanguageKind Language = FormatStyle::LK_Cpp);
5559 
5560 /// Returns a format style complying with one of Google's style guides:
5561 /// http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml.
5562 /// http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml.
5563 /// https://developers.google.com/protocol-buffers/docs/style.
5564 FormatStyle getGoogleStyle(FormatStyle::LanguageKind Language);
5565 
5566 /// Returns a format style complying with Chromium's style guide:
5567 /// http://www.chromium.org/developers/coding-style.
5568 FormatStyle getChromiumStyle(FormatStyle::LanguageKind Language);
5569 
5570 /// Returns a format style complying with Mozilla's style guide:
5571 /// https://firefox-source-docs.mozilla.org/code-quality/coding-style/index.html.
5572 FormatStyle getMozillaStyle();
5573 
5574 /// Returns a format style complying with Webkit's style guide:
5575 /// http://www.webkit.org/coding/coding-style.html
5576 FormatStyle getWebKitStyle();
5577 
5578 /// Returns a format style complying with GNU Coding Standards:
5579 /// http://www.gnu.org/prep/standards/standards.html
5580 FormatStyle getGNUStyle();
5581 
5582 /// Returns a format style complying with Microsoft style guide:
5583 /// https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference?view=vs-2017
5584 FormatStyle getMicrosoftStyle(FormatStyle::LanguageKind Language);
5585 
5586 FormatStyle getClangFormatStyle();
5587 
5588 /// Returns style indicating formatting should be not applied at all.
5589 FormatStyle getNoStyle();
5590 
5591 /// Gets a predefined style for the specified language by name.
5592 ///
5593 /// Currently supported names: LLVM, Google, Chromium, Mozilla. Names are
5594 /// compared case-insensitively.
5595 ///
5596 /// Returns ``true`` if the Style has been set.
5597 bool getPredefinedStyle(StringRef Name, FormatStyle::LanguageKind Language,
5598                         FormatStyle *Style);
5599 
5600 /// Parse configuration from YAML-formatted text.
5601 ///
5602 /// Style->Language is used to get the base style, if the ``BasedOnStyle``
5603 /// option is present.
5604 ///
5605 /// The FormatStyleSet of Style is reset.
5606 ///
5607 /// When ``BasedOnStyle`` is not present, options not present in the YAML
5608 /// document, are retained in \p Style.
5609 ///
5610 /// If AllowUnknownOptions is true, no errors are emitted if unknown
5611 /// format options are occurred.
5612 ///
5613 /// If set all diagnostics are emitted through the DiagHandler.
5614 std::error_code
5615 parseConfiguration(llvm::MemoryBufferRef Config, FormatStyle *Style,
5616                    bool AllowUnknownOptions = false,
5617                    llvm::SourceMgr::DiagHandlerTy DiagHandler = nullptr,
5618                    void *DiagHandlerCtx = nullptr, bool IsDotHFile = false);
5619 
5620 /// Like above but accepts an unnamed buffer.
5621 inline std::error_code parseConfiguration(StringRef Config, FormatStyle *Style,
5622                                           bool AllowUnknownOptions = false,
5623                                           bool IsDotHFile = false) {
5624   return parseConfiguration(llvm::MemoryBufferRef(Config, "YAML"), Style,
5625                             AllowUnknownOptions, /*DiagHandler=*/nullptr,
5626                             /*DiagHandlerCtx=*/nullptr, IsDotHFile);
5627 }
5628 
5629 /// Gets configuration in a YAML string.
5630 std::string configurationAsText(const FormatStyle &Style);
5631 
5632 /// Returns the replacements necessary to sort all ``#include`` blocks
5633 /// that are affected by ``Ranges``.
5634 tooling::Replacements sortIncludes(const FormatStyle &Style, StringRef Code,
5635                                    ArrayRef<tooling::Range> Ranges,
5636                                    StringRef FileName,
5637                                    unsigned *Cursor = nullptr);
5638 
5639 /// Returns the replacements corresponding to applying and formatting
5640 /// \p Replaces on success; otheriwse, return an llvm::Error carrying
5641 /// llvm::StringError.
5642 Expected<tooling::Replacements>
5643 formatReplacements(StringRef Code, const tooling::Replacements &Replaces,
5644                    const FormatStyle &Style);
5645 
5646 /// Returns the replacements corresponding to applying \p Replaces and
5647 /// cleaning up the code after that on success; otherwise, return an llvm::Error
5648 /// carrying llvm::StringError.
5649 /// This also supports inserting/deleting C++ #include directives:
5650 /// * If a replacement has offset UINT_MAX, length 0, and a replacement text
5651 ///   that is an #include directive, this will insert the #include into the
5652 ///   correct block in the \p Code.
5653 /// * If a replacement has offset UINT_MAX, length 1, and a replacement text
5654 ///   that is the name of the header to be removed, the header will be removed
5655 ///   from \p Code if it exists.
5656 /// The include manipulation is done via ``tooling::HeaderInclude``, see its
5657 /// documentation for more details on how include insertion points are found and
5658 /// what edits are produced.
5659 Expected<tooling::Replacements>
5660 cleanupAroundReplacements(StringRef Code, const tooling::Replacements &Replaces,
5661                           const FormatStyle &Style);
5662 
5663 /// Represents the status of a formatting attempt.
5664 struct FormattingAttemptStatus {
5665   /// A value of ``false`` means that any of the affected ranges were not
5666   /// formatted due to a non-recoverable syntax error.
5667   bool FormatComplete = true;
5668 
5669   /// If ``FormatComplete`` is false, ``Line`` records a one-based
5670   /// original line number at which a syntax error might have occurred. This is
5671   /// based on a best-effort analysis and could be imprecise.
5672   unsigned Line = 0;
5673 };
5674 
5675 /// Reformats the given \p Ranges in \p Code.
5676 ///
5677 /// Each range is extended on either end to its next bigger logic unit, i.e.
5678 /// everything that might influence its formatting or might be influenced by its
5679 /// formatting.
5680 ///
5681 /// Returns the ``Replacements`` necessary to make all \p Ranges comply with
5682 /// \p Style.
5683 ///
5684 /// If ``Status`` is non-null, its value will be populated with the status of
5685 /// this formatting attempt. See \c FormattingAttemptStatus.
5686 tooling::Replacements reformat(const FormatStyle &Style, StringRef Code,
5687                                ArrayRef<tooling::Range> Ranges,
5688                                StringRef FileName = "<stdin>",
5689                                FormattingAttemptStatus *Status = nullptr);
5690 
5691 /// Same as above, except if ``IncompleteFormat`` is non-null, its value
5692 /// will be set to true if any of the affected ranges were not formatted due to
5693 /// a non-recoverable syntax error.
5694 tooling::Replacements reformat(const FormatStyle &Style, StringRef Code,
5695                                ArrayRef<tooling::Range> Ranges,
5696                                StringRef FileName, bool *IncompleteFormat);
5697 
5698 /// Clean up any erroneous/redundant code in the given \p Ranges in \p
5699 /// Code.
5700 ///
5701 /// Returns the ``Replacements`` that clean up all \p Ranges in \p Code.
5702 tooling::Replacements cleanup(const FormatStyle &Style, StringRef Code,
5703                               ArrayRef<tooling::Range> Ranges,
5704                               StringRef FileName = "<stdin>");
5705 
5706 /// Fix namespace end comments in the given \p Ranges in \p Code.
5707 ///
5708 /// Returns the ``Replacements`` that fix the namespace comments in all
5709 /// \p Ranges in \p Code.
5710 tooling::Replacements fixNamespaceEndComments(const FormatStyle &Style,
5711                                               StringRef Code,
5712                                               ArrayRef<tooling::Range> Ranges,
5713                                               StringRef FileName = "<stdin>");
5714 
5715 /// Inserts or removes empty lines separating definition blocks including
5716 /// classes, structs, functions, namespaces, and enums in the given \p Ranges in
5717 /// \p Code.
5718 ///
5719 /// Returns the ``Replacements`` that inserts or removes empty lines separating
5720 /// definition blocks in all \p Ranges in \p Code.
5721 tooling::Replacements separateDefinitionBlocks(const FormatStyle &Style,
5722                                                StringRef Code,
5723                                                ArrayRef<tooling::Range> Ranges,
5724                                                StringRef FileName = "<stdin>");
5725 
5726 /// Sort consecutive using declarations in the given \p Ranges in
5727 /// \p Code.
5728 ///
5729 /// Returns the ``Replacements`` that sort the using declarations in all
5730 /// \p Ranges in \p Code.
5731 tooling::Replacements sortUsingDeclarations(const FormatStyle &Style,
5732                                             StringRef Code,
5733                                             ArrayRef<tooling::Range> Ranges,
5734                                             StringRef FileName = "<stdin>");
5735 
5736 /// Returns the ``LangOpts`` that the formatter expects you to set.
5737 ///
5738 /// \param Style determines specific settings for lexing mode.
5739 LangOptions getFormattingLangOpts(const FormatStyle &Style = getLLVMStyle());
5740 
5741 /// Description to be used for help text for a ``llvm::cl`` option for
5742 /// specifying format style. The description is closely related to the operation
5743 /// of ``getStyle()``.
5744 extern const char *StyleOptionHelpDescription;
5745 
5746 /// The suggested format style to use by default. This allows tools using
5747 /// ``getStyle`` to have a consistent default style.
5748 /// Different builds can modify the value to the preferred styles.
5749 extern const char *DefaultFormatStyle;
5750 
5751 /// The suggested predefined style to use as the fallback style in ``getStyle``.
5752 /// Different builds can modify the value to the preferred styles.
5753 extern const char *DefaultFallbackStyle;
5754 
5755 /// Construct a FormatStyle based on ``StyleName``.
5756 ///
5757 /// ``StyleName`` can take several forms:
5758 /// * "{<key>: <value>, ...}" - Set specic style parameters.
5759 /// * "<style name>" - One of the style names supported by getPredefinedStyle().
5760 /// * "file" - Load style configuration from a file called ``.clang-format``
5761 ///   located in one of the parent directories of ``FileName`` or the current
5762 ///   directory if ``FileName`` is empty.
5763 /// * "file:<format_file_path>" to explicitly specify the configuration file to
5764 ///   use.
5765 ///
5766 /// \param[in] StyleName Style name to interpret according to the description
5767 /// above.
5768 /// \param[in] FileName Path to start search for .clang-format if ``StyleName``
5769 /// == "file".
5770 /// \param[in] FallbackStyle The name of a predefined style used to fallback to
5771 /// in case \p StyleName is "file" and no file can be found.
5772 /// \param[in] Code The actual code to be formatted. Used to determine the
5773 /// language if the filename isn't sufficient.
5774 /// \param[in] FS The underlying file system, in which the file resides. By
5775 /// default, the file system is the real file system.
5776 /// \param[in] AllowUnknownOptions If true, unknown format options only
5777 ///             emit a warning. If false, errors are emitted on unknown format
5778 ///             options.
5779 ///
5780 /// \returns FormatStyle as specified by ``StyleName``. If ``StyleName`` is
5781 /// "file" and no file is found, returns ``FallbackStyle``. If no style could be
5782 /// determined, returns an Error.
5783 Expected<FormatStyle>
5784 getStyle(StringRef StyleName, StringRef FileName, StringRef FallbackStyle,
5785          StringRef Code = "", llvm::vfs::FileSystem *FS = nullptr,
5786          bool AllowUnknownOptions = false,
5787          llvm::SourceMgr::DiagHandlerTy DiagHandler = nullptr);
5788 
5789 // Guesses the language from the ``FileName`` and ``Code`` to be formatted.
5790 // Defaults to FormatStyle::LK_Cpp.
5791 FormatStyle::LanguageKind guessLanguage(StringRef FileName, StringRef Code);
5792 
5793 // Returns a string representation of ``Language``.
getLanguageName(FormatStyle::LanguageKind Language)5794 inline StringRef getLanguageName(FormatStyle::LanguageKind Language) {
5795   switch (Language) {
5796   case FormatStyle::LK_C:
5797     return "C";
5798   case FormatStyle::LK_Cpp:
5799     return "C++";
5800   case FormatStyle::LK_CSharp:
5801     return "CSharp";
5802   case FormatStyle::LK_ObjC:
5803     return "Objective-C";
5804   case FormatStyle::LK_Java:
5805     return "Java";
5806   case FormatStyle::LK_JavaScript:
5807     return "JavaScript";
5808   case FormatStyle::LK_Json:
5809     return "Json";
5810   case FormatStyle::LK_Proto:
5811     return "Proto";
5812   case FormatStyle::LK_TableGen:
5813     return "TableGen";
5814   case FormatStyle::LK_TextProto:
5815     return "TextProto";
5816   case FormatStyle::LK_Verilog:
5817     return "Verilog";
5818   default:
5819     return "Unknown";
5820   }
5821 }
5822 
5823 bool isClangFormatOn(StringRef Comment);
5824 bool isClangFormatOff(StringRef Comment);
5825 
5826 } // end namespace format
5827 } // end namespace clang
5828 
5829 template <>
5830 struct std::is_error_code_enum<clang::format::ParseError> : std::true_type {};
5831 
5832 #endif // LLVM_CLANG_FORMAT_FORMAT_H
5833