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