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