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