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