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 /// If ``true``, clang-format will indent the body of an ``export { ... }``
2806 /// block. This doesn't affect the formatting of anything else related to
2807 /// exported declarations.
2808 /// \code
2809 /// true: false:
2810 /// export { vs. export {
2811 /// void foo(); void foo();
2812 /// void bar(); void bar();
2813 /// } }
2814 /// \endcode
2815 /// \version 20
2817
2818 /// Indents extern blocks
2820 /// Backwards compatible with AfterExternBlock's indenting.
2821 /// \code
2822 /// IndentExternBlock: AfterExternBlock
2823 /// BraceWrapping.AfterExternBlock: true
2824 /// extern "C"
2825 /// {
2826 /// void foo();
2827 /// }
2828 /// \endcode
2829 ///
2830 /// \code
2831 /// IndentExternBlock: AfterExternBlock
2832 /// BraceWrapping.AfterExternBlock: false
2833 /// extern "C" {
2834 /// void foo();
2835 /// }
2836 /// \endcode
2838 /// Does not indent extern blocks.
2839 /// \code
2840 /// extern "C" {
2841 /// void foo();
2842 /// }
2843 /// \endcode
2845 /// Indents extern blocks.
2846 /// \code
2847 /// extern "C" {
2848 /// void foo();
2849 /// }
2850 /// \endcode
2852 };
2853
2854 /// IndentExternBlockStyle is the type of indenting of extern blocks.
2855 /// \version 11
2857
2858 /// Indent goto labels.
2859 ///
2860 /// When ``false``, goto labels are flushed left.
2861 /// \code
2862 /// true: false:
2863 /// int f() { vs. int f() {
2864 /// if (foo()) { if (foo()) {
2865 /// label1: label1:
2866 /// bar(); bar();
2867 /// } }
2868 /// label2: label2:
2869 /// return 1; return 1;
2870 /// } }
2871 /// \endcode
2872 /// \version 10
2874
2875 /// Options for indenting preprocessor directives.
2877 /// Does not indent any directives.
2878 /// \code
2879 /// #if FOO
2880 /// #if BAR
2881 /// #include <foo>
2882 /// #endif
2883 /// #endif
2884 /// \endcode
2886 /// Indents directives after the hash.
2887 /// \code
2888 /// #if FOO
2889 /// # if BAR
2890 /// # include <foo>
2891 /// # endif
2892 /// #endif
2893 /// \endcode
2895 /// Indents directives before the hash.
2896 /// \code
2897 /// #if FOO
2898 /// #if BAR
2899 /// #include <foo>
2900 /// #endif
2901 /// #endif
2902 /// \endcode
2905
2906 /// The preprocessor directive indenting style to use.
2907 /// \version 6
2909
2910 /// Indent the requires clause in a template. This only applies when
2911 /// ``RequiresClausePosition`` is ``OwnLine``, ``OwnLineWithBrace``,
2912 /// or ``WithFollowing``.
2913 ///
2914 /// In clang-format 12, 13 and 14 it was named ``IndentRequires``.
2915 /// \code
2916 /// true:
2917 /// template <typename It>
2918 /// requires Iterator<It>
2919 /// void sort(It begin, It end) {
2920 /// //....
2921 /// }
2922 ///
2923 /// false:
2924 /// template <typename It>
2925 /// requires Iterator<It>
2926 /// void sort(It begin, It end) {
2927 /// //....
2928 /// }
2929 /// \endcode
2930 /// \version 15
2932
2933 /// The number of columns to use for indentation.
2934 /// \code
2935 /// IndentWidth: 3
2936 ///
2937 /// void f() {
2938 /// someFunction();
2939 /// if (true, false) {
2940 /// f();
2941 /// }
2942 /// }
2943 /// \endcode
2944 /// \version 3.7
2945 unsigned IndentWidth;
2946
2947 /// Indent if a function definition or declaration is wrapped after the
2948 /// type.
2949 /// \code
2950 /// true:
2951 /// LoooooooooooooooooooooooooooooooooooooooongReturnType
2952 /// LoooooooooooooooooooooooooooooooongFunctionDeclaration();
2953 ///
2954 /// false:
2955 /// LoooooooooooooooooooooooooooooooooooooooongReturnType
2956 /// LoooooooooooooooooooooooooooooooongFunctionDeclaration();
2957 /// \endcode
2958 /// \version 3.7
2960
2961 /// Insert braces after control statements (``if``, ``else``, ``for``, ``do``,
2962 /// and ``while``) in C++ unless the control statements are inside macro
2963 /// definitions or the braces would enclose preprocessor directives.
2964 /// \warning
2965 /// Setting this option to ``true`` could lead to incorrect code formatting
2966 /// due to clang-format's lack of complete semantic information. As such,
2967 /// extra care should be taken to review code changes made by this option.
2968 /// \endwarning
2969 /// \code
2970 /// false: true:
2971 ///
2972 /// if (isa<FunctionDecl>(D)) vs. if (isa<FunctionDecl>(D)) {
2973 /// handleFunctionDecl(D); handleFunctionDecl(D);
2974 /// else if (isa<VarDecl>(D)) } else if (isa<VarDecl>(D)) {
2975 /// handleVarDecl(D); handleVarDecl(D);
2976 /// else } else {
2977 /// return; return;
2978 /// }
2979 ///
2980 /// while (i--) vs. while (i--) {
2981 /// for (auto *A : D.attrs()) for (auto *A : D.attrs()) {
2982 /// handleAttr(A); handleAttr(A);
2983 /// }
2984 /// }
2985 ///
2986 /// do vs. do {
2987 /// --i; --i;
2988 /// while (i); } while (i);
2989 /// \endcode
2990 /// \version 15
2992
2993 /// Insert a newline at end of file if missing.
2994 /// \version 16
2996
2997 /// The style of inserting trailing commas into container literals.
2998 enum TrailingCommaStyle : int8_t {
2999 /// Do not insert trailing commas.
3001 /// Insert trailing commas in container literals that were wrapped over
3002 /// multiple lines. Note that this is conceptually incompatible with
3003 /// bin-packing, because the trailing comma is used as an indicator
3004 /// that a container should be formatted one-per-line (i.e. not bin-packed).
3005 /// So inserting a trailing comma counteracts bin-packing.
3007 };
3008
3009 /// If set to ``TCS_Wrapped`` will insert trailing commas in container
3010 /// literals (arrays and objects) that wrap across multiple lines.
3011 /// It is currently only available for JavaScript
3012 /// and disabled by default ``TCS_None``.
3013 /// ``InsertTrailingCommas`` cannot be used together with ``BinPackArguments``
3014 /// as inserting the comma disables bin-packing.
3015 /// \code
3016 /// TSC_Wrapped:
3017 /// const someArray = [
3018 /// aaaaaaaaaaaaaaaaaaaaaaaaaa,
3019 /// aaaaaaaaaaaaaaaaaaaaaaaaaa,
3020 /// aaaaaaaaaaaaaaaaaaaaaaaaaa,
3021 /// // ^ inserted
3022 /// ]
3023 /// \endcode
3024 /// \version 11
3026
3027 /// Separator format of integer literals of different bases.
3028 ///
3029 /// If negative, remove separators. If ``0``, leave the literal as is. If
3030 /// positive, insert separators between digits starting from the rightmost
3031 /// digit.
3032 ///
3033 /// For example, the config below will leave separators in binary literals
3034 /// alone, insert separators in decimal literals to separate the digits into
3035 /// groups of 3, and remove separators in hexadecimal literals.
3036 /// \code
3037 /// IntegerLiteralSeparator:
3038 /// Binary: 0
3039 /// Decimal: 3
3040 /// Hex: -1
3041 /// \endcode
3042 ///
3043 /// You can also specify a minimum number of digits (``BinaryMinDigits``,
3044 /// ``DecimalMinDigits``, and ``HexMinDigits``) the integer literal must
3045 /// have in order for the separators to be inserted.
3047 /// Format separators in binary literals.
3048 /// \code{.text}
3049 /// /* -1: */ b = 0b100111101101;
3050 /// /* 0: */ b = 0b10011'11'0110'1;
3051 /// /* 3: */ b = 0b100'111'101'101;
3052 /// /* 4: */ b = 0b1001'1110'1101;
3053 /// \endcode
3054 int8_t Binary;
3055 /// Format separators in binary literals with a minimum number of digits.
3056 /// \code{.text}
3057 /// // Binary: 3
3058 /// // BinaryMinDigits: 7
3059 /// b1 = 0b101101;
3060 /// b2 = 0b1'101'101;
3061 /// \endcode
3063 /// Format separators in decimal literals.
3064 /// \code{.text}
3065 /// /* -1: */ d = 18446744073709550592ull;
3066 /// /* 0: */ d = 184467'440737'0'95505'92ull;
3067 /// /* 3: */ d = 18'446'744'073'709'550'592ull;
3068 /// \endcode
3069 int8_t Decimal;
3070 /// Format separators in decimal literals with a minimum number of digits.
3071 /// \code{.text}
3072 /// // Decimal: 3
3073 /// // DecimalMinDigits: 5
3074 /// d1 = 2023;
3075 /// d2 = 10'000;
3076 /// \endcode
3078 /// Format separators in hexadecimal literals.
3079 /// \code{.text}
3080 /// /* -1: */ h = 0xDEADBEEFDEADBEEFuz;
3081 /// /* 0: */ h = 0xDEAD'BEEF'DE'AD'BEE'Fuz;
3082 /// /* 2: */ h = 0xDE'AD'BE'EF'DE'AD'BE'EFuz;
3083 /// \endcode
3084 int8_t Hex;
3085 /// Format separators in hexadecimal literals with a minimum number of
3086 /// digits.
3087 /// \code{.text}
3088 /// // Hex: 2
3089 /// // HexMinDigits: 6
3090 /// h1 = 0xABCDE;
3091 /// h2 = 0xAB'CD'EF;
3092 /// \endcode
3095 return Binary == R.Binary && BinaryMinDigits == R.BinaryMinDigits &&
3097 Hex == R.Hex && HexMinDigits == R.HexMinDigits;
3098 }
3099 };
3100
3101 /// Format integer literal separators (``'`` for C++ and ``_`` for C#, Java,
3102 /// and JavaScript).
3103 /// \version 16
3105
3106 /// A vector of prefixes ordered by the desired groups for Java imports.
3107 ///
3108 /// One group's prefix can be a subset of another - the longest prefix is
3109 /// always matched. Within a group, the imports are ordered lexicographically.
3110 /// Static imports are grouped separately and follow the same group rules.
3111 /// By default, static imports are placed before non-static imports,
3112 /// but this behavior is changed by another option,
3113 /// ``SortJavaStaticImport``.
3114 ///
3115 /// In the .clang-format configuration file, this can be configured like
3116 /// in the following yaml example. This will result in imports being
3117 /// formatted as in the Java example below.
3118 /// \code{.yaml}
3119 /// JavaImportGroups: [com.example, com, org]
3120 /// \endcode
3121 ///
3122 /// \code{.java}
3123 /// import static com.example.function1;
3124 ///
3125 /// import static com.test.function2;
3126 ///
3127 /// import static org.example.function3;
3128 ///
3129 /// import com.example.ClassA;
3130 /// import com.example.Test;
3131 /// import com.example.a.ClassB;
3132 ///
3133 /// import com.test.ClassC;
3134 ///
3135 /// import org.example.ClassD;
3136 /// \endcode
3137 /// \version 8
3138 std::vector<std::string> JavaImportGroups;
3139
3140 /// Quotation styles for JavaScript strings. Does not affect template
3141 /// strings.
3142 enum JavaScriptQuoteStyle : int8_t {
3143 /// Leave string quotes as they are.
3144 /// \code{.js}
3145 /// string1 = "foo";
3146 /// string2 = 'bar';
3147 /// \endcode
3149 /// Always use single quotes.
3150 /// \code{.js}
3151 /// string1 = 'foo';
3152 /// string2 = 'bar';
3153 /// \endcode
3155 /// Always use double quotes.
3156 /// \code{.js}
3157 /// string1 = "foo";
3158 /// string2 = "bar";
3159 /// \endcode
3162
3163 /// The JavaScriptQuoteStyle to use for JavaScript strings.
3164 /// \version 3.9
3166
3167 // clang-format off
3168 /// Whether to wrap JavaScript import/export statements.
3169 /// \code{.js}
3170 /// true:
3171 /// import {
3172 /// VeryLongImportsAreAnnoying,
3173 /// VeryLongImportsAreAnnoying,
3174 /// VeryLongImportsAreAnnoying,
3175 /// } from "some/module.js"
3176 ///
3177 /// false:
3178 /// import {VeryLongImportsAreAnnoying, VeryLongImportsAreAnnoying, VeryLongImportsAreAnnoying,} from "some/module.js"
3179 /// \endcode
3180 /// \version 3.9
3182 // clang-format on
3183
3184 /// Options regarding which empty lines are kept.
3185 ///
3186 /// For example, the config below will remove empty lines at start of the
3187 /// file, end of the file, and start of blocks.
3188 ///
3189 /// \code
3190 /// KeepEmptyLines:
3191 /// AtEndOfFile: false
3192 /// AtStartOfBlock: false
3193 /// AtStartOfFile: false
3194 /// \endcode
3196 /// Keep empty lines at end of file.
3198 /// Keep empty lines at start of a block.
3199 /// \code
3200 /// true: false:
3201 /// if (foo) { vs. if (foo) {
3202 /// bar();
3203 /// bar(); }
3204 /// }
3205 /// \endcode
3207 /// Keep empty lines at start of file.
3209 bool operator==(const KeepEmptyLinesStyle &R) const {
3210 return AtEndOfFile == R.AtEndOfFile &&
3213 }
3214 };
3215 /// Which empty lines are kept. See ``MaxEmptyLinesToKeep`` for how many
3216 /// consecutive empty lines are kept.
3217 /// \version 19
3219
3220 /// This option is **deprecated**. See ``AtEndOfFile`` of ``KeepEmptyLines``.
3221 /// \version 17
3222 // bool KeepEmptyLinesAtEOF;
3223
3224 /// This option is **deprecated**. See ``AtStartOfBlock`` of
3225 /// ``KeepEmptyLines``.
3226 /// \version 3.7
3227 // bool KeepEmptyLinesAtTheStartOfBlocks;
3228
3229 /// Keep the form feed character if it's immediately preceded and followed by
3230 /// a newline. Multiple form feeds and newlines within a whitespace range are
3231 /// replaced with a single newline and form feed followed by the remaining
3232 /// newlines.
3233 /// \version 20
3235
3236 /// Indentation logic for lambda bodies.
3238 /// Align lambda body relative to the lambda signature. This is the default.
3239 /// \code
3240 /// someMethod(
3241 /// [](SomeReallyLongLambdaSignatureArgument foo) {
3242 /// return;
3243 /// });
3244 /// \endcode
3246 /// For statements within block scope, align lambda body relative to the
3247 /// indentation level of the outer scope the lambda signature resides in.
3248 /// \code
3249 /// someMethod(
3250 /// [](SomeReallyLongLambdaSignatureArgument foo) {
3251 /// return;
3252 /// });
3253 ///
3254 /// someMethod(someOtherMethod(
3255 /// [](SomeReallyLongLambdaSignatureArgument foo) {
3256 /// return;
3257 /// }));
3258 /// \endcode
3260 };
3261
3262 /// The indentation style of lambda bodies. ``Signature`` (the default)
3263 /// causes the lambda body to be indented one additional level relative to
3264 /// the indentation level of the signature. ``OuterScope`` forces the lambda
3265 /// body to be indented one additional level relative to the parent scope
3266 /// containing the lambda signature.
3267 /// \version 13
3269
3270 /// Supported languages.
3271 ///
3272 /// When stored in a configuration file, specifies the language, that the
3273 /// configuration targets. When passed to the ``reformat()`` function, enables
3274 /// syntax features specific to the language.
3275 enum LanguageKind : int8_t {
3276 /// Do not use.
3278 /// Should be used for C, C++.
3280 /// Should be used for C#.
3282 /// Should be used for Java.
3284 /// Should be used for JavaScript.
3286 /// Should be used for JSON.
3288 /// Should be used for Objective-C, Objective-C++.
3290 /// Should be used for Protocol Buffers
3291 /// (https://developers.google.com/protocol-buffers/).
3293 /// Should be used for TableGen code.
3295 /// Should be used for Protocol Buffer messages in text format
3296 /// (https://developers.google.com/protocol-buffers/).
3298 /// Should be used for Verilog and SystemVerilog.
3299 /// https://standards.ieee.org/ieee/1800/6700/
3300 /// https://sci-hub.st/10.1109/IEEESTD.2018.8299595
3303 bool isCpp() const { return Language == LK_Cpp || Language == LK_ObjC; }
3304 bool isCSharp() const { return Language == LK_CSharp; }
3305 bool isJson() const { return Language == LK_Json; }
3306 bool isJavaScript() const { return Language == LK_JavaScript; }
3307 bool isVerilog() const { return Language == LK_Verilog; }
3308 bool isProto() const {
3309 return Language == LK_Proto || Language == LK_TextProto;
3310 }
3311 bool isTableGen() const { return Language == LK_TableGen; }
3312
3313 /// Language, this format style is targeted at.
3314 /// \version 3.5
3316
3317 /// Line ending style.
3318 enum LineEndingStyle : int8_t {
3319 /// Use ``\n``.
3321 /// Use ``\r\n``.
3323 /// Use ``\n`` unless the input has more lines ending in ``\r\n``.
3325 /// Use ``\r\n`` unless the input has more lines ending in ``\n``.
3327 };
3328
3329 /// Line ending style (``\n`` or ``\r\n``) to use.
3330 /// \version 16
3332
3333 /// A regular expression matching macros that start a block.
3334 /// \code
3335 /// # With:
3336 /// MacroBlockBegin: "^NS_MAP_BEGIN|\
3337 /// NS_TABLE_HEAD$"
3338 /// MacroBlockEnd: "^\
3339 /// NS_MAP_END|\
3340 /// NS_TABLE_.*_END$"
3341 ///
3342 /// NS_MAP_BEGIN
3343 /// foo();
3344 /// NS_MAP_END
3345 ///
3346 /// NS_TABLE_HEAD
3347 /// bar();
3348 /// NS_TABLE_FOO_END
3349 ///
3350 /// # Without:
3351 /// NS_MAP_BEGIN
3352 /// foo();
3353 /// NS_MAP_END
3354 ///
3355 /// NS_TABLE_HEAD
3356 /// bar();
3357 /// NS_TABLE_FOO_END
3358 /// \endcode
3359 /// \version 3.7
3360 std::string MacroBlockBegin;
3361
3362 /// A regular expression matching macros that end a block.
3363 /// \version 3.7
3364 std::string MacroBlockEnd;
3365
3366 /// A list of macros of the form \c <definition>=<expansion> .
3367 ///
3368 /// Code will be parsed with macros expanded, in order to determine how to
3369 /// interpret and format the macro arguments.
3370 ///
3371 /// For example, the code:
3372 /// \code
3373 /// A(a*b);
3374 /// \endcode
3375 ///
3376 /// will usually be interpreted as a call to a function A, and the
3377 /// multiplication expression will be formatted as ``a * b``.
3378 ///
3379 /// If we specify the macro definition:
3380 /// \code{.yaml}
3381 /// Macros:
3382 /// - A(x)=x
3383 /// \endcode
3384 ///
3385 /// the code will now be parsed as a declaration of the variable b of type a*,
3386 /// and formatted as ``a* b`` (depending on pointer-binding rules).
3387 ///
3388 /// Features and restrictions:
3389 /// * Both function-like macros and object-like macros are supported.
3390 /// * Macro arguments must be used exactly once in the expansion.
3391 /// * No recursive expansion; macros referencing other macros will be
3392 /// ignored.
3393 /// * Overloading by arity is supported: for example, given the macro
3394 /// definitions A=x, A()=y, A(a)=a
3395 ///
3396 /// \code
3397 /// A; -> x;
3398 /// A(); -> y;
3399 /// A(z); -> z;
3400 /// A(a, b); // will not be expanded.
3401 /// \endcode
3402 ///
3403 /// \version 17
3404 std::vector<std::string> Macros;
3405
3406 /// The maximum number of consecutive empty lines to keep.
3407 /// \code
3408 /// MaxEmptyLinesToKeep: 1 vs. MaxEmptyLinesToKeep: 0
3409 /// int f() { int f() {
3410 /// int = 1; int i = 1;
3411 /// i = foo();
3412 /// i = foo(); return i;
3413 /// }
3414 /// return i;
3415 /// }
3416 /// \endcode
3417 /// \version 3.7
3419
3420 /// Different ways to indent namespace contents.
3422 /// Don't indent in namespaces.
3423 /// \code
3424 /// namespace out {
3425 /// int i;
3426 /// namespace in {
3427 /// int i;
3428 /// }
3429 /// }
3430 /// \endcode
3432 /// Indent only in inner namespaces (nested in other namespaces).
3433 /// \code
3434 /// namespace out {
3435 /// int i;
3436 /// namespace in {
3437 /// int i;
3438 /// }
3439 /// }
3440 /// \endcode
3442 /// Indent in all namespaces.
3443 /// \code
3444 /// namespace out {
3445 /// int i;
3446 /// namespace in {
3447 /// int i;
3448 /// }
3449 /// }
3450 /// \endcode
3451 NI_All
3453
3454 /// The indentation used for namespaces.
3455 /// \version 3.7
3457
3458 /// A vector of macros which are used to open namespace blocks.
3459 ///
3460 /// These are expected to be macros of the form:
3461 /// \code
3462 /// NAMESPACE(<namespace-name>, ...) {
3463 /// <namespace-content>
3464 /// }
3465 /// \endcode
3466 ///
3467 /// For example: TESTSUITE
3468 /// \version 9
3469 std::vector<std::string> NamespaceMacros;
3470
3471 /// Controls bin-packing Objective-C protocol conformance list
3472 /// items into as few lines as possible when they go over ``ColumnLimit``.
3473 ///
3474 /// If ``Auto`` (the default), delegates to the value in
3475 /// ``BinPackParameters``. If that is ``BinPack``, bin-packs Objective-C
3476 /// protocol conformance list items into as few lines as possible
3477 /// whenever they go over ``ColumnLimit``.
3478 ///
3479 /// If ``Always``, always bin-packs Objective-C protocol conformance
3480 /// list items into as few lines as possible whenever they go over
3481 /// ``ColumnLimit``.
3482 ///
3483 /// If ``Never``, lays out Objective-C protocol conformance list items
3484 /// onto individual lines whenever they go over ``ColumnLimit``.
3485 ///
3486 /// \code{.objc}
3487 /// Always (or Auto, if BinPackParameters==BinPack):
3488 /// @interface ccccccccccccc () <
3489 /// ccccccccccccc, ccccccccccccc,
3490 /// ccccccccccccc, ccccccccccccc> {
3491 /// }
3492 ///
3493 /// Never (or Auto, if BinPackParameters!=BinPack):
3494 /// @interface ddddddddddddd () <
3495 /// ddddddddddddd,
3496 /// ddddddddddddd,
3497 /// ddddddddddddd,
3498 /// ddddddddddddd> {
3499 /// }
3500 /// \endcode
3501 /// \version 7
3503
3504 /// The number of characters to use for indentation of ObjC blocks.
3505 /// \code{.objc}
3506 /// ObjCBlockIndentWidth: 4
3507 ///
3508 /// [operation setCompletionBlock:^{
3509 /// [self onOperationDone];
3510 /// }];
3511 /// \endcode
3512 /// \version 3.7
3514
3515 /// Break parameters list into lines when there is nested block
3516 /// parameters in a function call.
3517 /// \code
3518 /// false:
3519 /// - (void)_aMethod
3520 /// {
3521 /// [self.test1 t:self w:self callback:^(typeof(self) self, NSNumber
3522 /// *u, NSNumber *v) {
3523 /// u = c;
3524 /// }]
3525 /// }
3526 /// true:
3527 /// - (void)_aMethod
3528 /// {
3529 /// [self.test1 t:self
3530 /// w:self
3531 /// callback:^(typeof(self) self, NSNumber *u, NSNumber *v) {
3532 /// u = c;
3533 /// }]
3534 /// }
3535 /// \endcode
3536 /// \version 11
3538
3539 /// The order in which ObjC property attributes should appear.
3540 ///
3541 /// Attributes in code will be sorted in the order specified. Any attributes
3542 /// encountered that are not mentioned in this array will be sorted last, in
3543 /// stable order. Comments between attributes will leave the attributes
3544 /// untouched.
3545 /// \warning
3546 /// Using this option could lead to incorrect code formatting due to
3547 /// clang-format's lack of complete semantic information. As such, extra
3548 /// care should be taken to review code changes made by this option.
3549 /// \endwarning
3550 /// \code{.yaml}
3551 /// ObjCPropertyAttributeOrder: [
3552 /// class, direct,
3553 /// atomic, nonatomic,
3554 /// assign, retain, strong, copy, weak, unsafe_unretained,
3555 /// readonly, readwrite, getter, setter,
3556 /// nullable, nonnull, null_resettable, null_unspecified
3557 /// ]
3558 /// \endcode
3559 /// \version 18
3560 std::vector<std::string> ObjCPropertyAttributeOrder;
3561
3562 /// Add a space after ``@property`` in Objective-C, i.e. use
3563 /// ``@property (readonly)`` instead of ``@property(readonly)``.
3564 /// \version 3.7
3566
3567 /// Add a space in front of an Objective-C protocol list, i.e. use
3568 /// ``Foo <Protocol>`` instead of ``Foo<Protocol>``.
3569 /// \version 3.7
3571
3572 /// Different ways to try to fit all constructor initializers on a line.
3574 /// Always put each constructor initializer on its own line.
3575 /// \code
3576 /// Constructor()
3577 /// : a(),
3578 /// b()
3579 /// \endcode
3581 /// Bin-pack constructor initializers.
3582 /// \code
3583 /// Constructor()
3584 /// : aaaaaaaaaaaaaaaaaaaa(), bbbbbbbbbbbbbbbbbbbb(),
3585 /// cccccccccccccccccccc()
3586 /// \endcode
3588 /// Put all constructor initializers on the current line if they fit.
3589 /// Otherwise, put each one on its own line.
3590 /// \code
3591 /// Constructor() : a(), b()
3592 ///
3593 /// Constructor()
3594 /// : aaaaaaaaaaaaaaaaaaaa(),
3595 /// bbbbbbbbbbbbbbbbbbbb(),
3596 /// ddddddddddddd()
3597 /// \endcode
3599 /// Same as ``PCIS_CurrentLine`` except that if all constructor initializers
3600 /// do not fit on the current line, try to fit them on the next line.
3601 /// \code
3602 /// Constructor() : a(), b()
3603 ///
3604 /// Constructor()
3605 /// : aaaaaaaaaaaaaaaaaaaa(), bbbbbbbbbbbbbbbbbbbb(), ddddddddddddd()
3606 ///
3607 /// Constructor()
3608 /// : aaaaaaaaaaaaaaaaaaaa(),
3609 /// bbbbbbbbbbbbbbbbbbbb(),
3610 /// cccccccccccccccccccc()
3611 /// \endcode
3613 /// Put all constructor initializers on the next line if they fit.
3614 /// Otherwise, put each one on its own line.
3615 /// \code
3616 /// Constructor()
3617 /// : a(), b()
3618 ///
3619 /// Constructor()
3620 /// : aaaaaaaaaaaaaaaaaaaa(), bbbbbbbbbbbbbbbbbbbb(), ddddddddddddd()
3621 ///
3622 /// Constructor()
3623 /// : aaaaaaaaaaaaaaaaaaaa(),
3624 /// bbbbbbbbbbbbbbbbbbbb(),
3625 /// cccccccccccccccccccc()
3626 /// \endcode
3628 };
3629
3630 /// The pack constructor initializers style to use.
3631 /// \version 14
3633
3634 /// The penalty for breaking around an assignment operator.
3635 /// \version 5
3637
3638 /// The penalty for breaking a function call after ``call(``.
3639 /// \version 3.7
3641
3642 /// The penalty for breaking before a member access operator (``.``, ``->``).
3643 /// \version 20
3645
3646 /// The penalty for each line break introduced inside a comment.
3647 /// \version 3.7
3649
3650 /// The penalty for breaking before the first ``<<``.
3651 /// \version 3.7
3653
3654 /// The penalty for breaking after ``(``.
3655 /// \version 14
3657
3658 /// The penalty for breaking after ``::``.
3659 /// \version 18
3661
3662 /// The penalty for each line break introduced inside a string literal.
3663 /// \version 3.7
3665
3666 /// The penalty for breaking after template declaration.
3667 /// \version 7
3669
3670 /// The penalty for each character outside of the column limit.
3671 /// \version 3.7
3673
3674 /// Penalty for each character of whitespace indentation
3675 /// (counted relative to leading non-whitespace column).
3676 /// \version 12
3678
3679 /// Penalty for putting the return type of a function onto its own line.
3680 /// \version 3.7
3682
3683 /// The ``&``, ``&&`` and ``*`` alignment style.
3685 /// Align pointer to the left.
3686 /// \code
3687 /// int* a;
3688 /// \endcode
3690 /// Align pointer to the right.
3691 /// \code
3692 /// int *a;
3693 /// \endcode
3695 /// Align pointer in the middle.
3696 /// \code
3697 /// int * a;
3698 /// \endcode
3701
3702 /// Pointer and reference alignment style.
3703 /// \version 3.7
3705
3706 /// The number of columns to use for indentation of preprocessor statements.
3707 /// When set to -1 (default) ``IndentWidth`` is used also for preprocessor
3708 /// statements.
3709 /// \code
3710 /// PPIndentWidth: 1
3711 ///
3712 /// #ifdef __linux__
3713 /// # define FOO
3714 /// #else
3715 /// # define BAR
3716 /// #endif
3717 /// \endcode
3718 /// \version 13
3720
3721 /// Different specifiers and qualifiers alignment styles.
3723 /// Don't change specifiers/qualifiers to either Left or Right alignment
3724 /// (default).
3725 /// \code
3726 /// int const a;
3727 /// const int *a;
3728 /// \endcode
3730 /// Change specifiers/qualifiers to be left-aligned.
3731 /// \code
3732 /// const int a;
3733 /// const int *a;
3734 /// \endcode
3736 /// Change specifiers/qualifiers to be right-aligned.
3737 /// \code
3738 /// int const a;
3739 /// int const *a;
3740 /// \endcode
3742 /// Change specifiers/qualifiers to be aligned based on ``QualifierOrder``.
3743 /// With:
3744 /// \code{.yaml}
3745 /// QualifierOrder: [inline, static, type, const]
3746 /// \endcode
3747 ///
3748 /// \code
3749 ///
3750 /// int const a;
3751 /// int const *a;
3752 /// \endcode
3755
3756 /// Different ways to arrange specifiers and qualifiers (e.g. const/volatile).
3757 /// \warning
3758 /// Setting ``QualifierAlignment`` to something other than ``Leave``, COULD
3759 /// lead to incorrect code formatting due to incorrect decisions made due to
3760 /// clang-formats lack of complete semantic information.
3761 /// As such extra care should be taken to review code changes made by the use
3762 /// of this option.
3763 /// \endwarning
3764 /// \version 14
3766
3767 /// The order in which the qualifiers appear.
3768 /// The order is an array that can contain any of the following:
3769 ///
3770 /// * ``const``
3771 /// * ``inline``
3772 /// * ``static``
3773 /// * ``friend``
3774 /// * ``constexpr``
3775 /// * ``volatile``
3776 /// * ``restrict``
3777 /// * ``type``
3778 ///
3779 /// \note
3780 /// It must contain ``type``.
3781 /// \endnote
3782 ///
3783 /// Items to the left of ``type`` will be placed to the left of the type and
3784 /// aligned in the order supplied. Items to the right of ``type`` will be
3785 /// placed to the right of the type and aligned in the order supplied.
3786 ///
3787 /// \code{.yaml}
3788 /// QualifierOrder: [inline, static, type, const, volatile]
3789 /// \endcode
3790 /// \version 14
3791 std::vector<std::string> QualifierOrder;
3792
3793 /// See documentation of ``RawStringFormats``.
3795 /// The language of this raw string.
3797 /// A list of raw string delimiters that match this language.
3798 std::vector<std::string> Delimiters;
3799 /// A list of enclosing function names that match this language.
3800 std::vector<std::string> EnclosingFunctions;
3801 /// The canonical delimiter for this language.
3803 /// The style name on which this raw string format is based on.
3804 /// If not specified, the raw string format is based on the style that this
3805 /// format is based on.
3806 std::string BasedOnStyle;
3807 bool operator==(const RawStringFormat &Other) const {
3808 return Language == Other.Language && Delimiters == Other.Delimiters &&
3809 EnclosingFunctions == Other.EnclosingFunctions &&
3810 CanonicalDelimiter == Other.CanonicalDelimiter &&
3811 BasedOnStyle == Other.BasedOnStyle;
3812 }
3813 };
3814
3815 /// Defines hints for detecting supported languages code blocks in raw
3816 /// strings.
3817 ///
3818 /// A raw string with a matching delimiter or a matching enclosing function
3819 /// name will be reformatted assuming the specified language based on the
3820 /// style for that language defined in the .clang-format file. If no style has
3821 /// been defined in the .clang-format file for the specific language, a
3822 /// predefined style given by ``BasedOnStyle`` is used. If ``BasedOnStyle`` is
3823 /// not found, the formatting is based on ``LLVM`` style. A matching delimiter
3824 /// takes precedence over a matching enclosing function name for determining
3825 /// the language of the raw string contents.
3826 ///
3827 /// If a canonical delimiter is specified, occurrences of other delimiters for
3828 /// the same language will be updated to the canonical if possible.
3829 ///
3830 /// There should be at most one specification per language and each delimiter
3831 /// and enclosing function should not occur in multiple specifications.
3832 ///
3833 /// To configure this in the .clang-format file, use:
3834 /// \code{.yaml}
3835 /// RawStringFormats:
3836 /// - Language: TextProto
3837 /// Delimiters:
3838 /// - pb
3839 /// - proto
3840 /// EnclosingFunctions:
3841 /// - PARSE_TEXT_PROTO
3842 /// BasedOnStyle: google
3843 /// - Language: Cpp
3844 /// Delimiters:
3845 /// - cc
3846 /// - cpp
3847 /// BasedOnStyle: LLVM
3848 /// CanonicalDelimiter: cc
3849 /// \endcode
3850 /// \version 6
3851 std::vector<RawStringFormat> RawStringFormats;
3852
3853 /// \brief The ``&`` and ``&&`` alignment style.
3855 /// Align reference like ``PointerAlignment``.
3857 /// Align reference to the left.
3858 /// \code
3859 /// int& a;
3860 /// \endcode
3862 /// Align reference to the right.
3863 /// \code
3864 /// int &a;
3865 /// \endcode
3867 /// Align reference in the middle.
3868 /// \code
3869 /// int & a;
3870 /// \endcode
3873
3874 /// \brief Reference alignment style (overrides ``PointerAlignment`` for
3875 /// references).
3876 /// \version 13
3878
3879 // clang-format off
3880 /// \brief Types of comment reflow style.
3881 enum ReflowCommentsStyle : int8_t {
3882 /// Leave comments untouched.
3883 /// \code
3884 /// // veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of information
3885 /// /* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of information */
3886 /// /* third veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of information
3887 /// * and a misaligned second line */
3888 /// \endcode
3890 /// Only apply indentation rules, moving comments left or right, without
3891 /// changing formatting inside the comments.
3892 /// \code
3893 /// // veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of information
3894 /// /* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of information */
3895 /// /* third veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of information
3896 /// * and a misaligned second line */
3897 /// \endcode
3899 /// Apply indentation rules and reflow long comments into new lines, trying
3900 /// to obey the ``ColumnLimit``.
3901 /// \code
3902 /// // veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of
3903 /// // information
3904 /// /* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of
3905 /// * information */
3906 /// /* third veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of
3907 /// * information and a misaligned second line */
3908 /// \endcode
3911 // clang-format on
3912
3913 /// \brief Comment reformatting style.
3914 /// \version 3.8
3916
3917 /// Remove optional braces of control statements (``if``, ``else``, ``for``,
3918 /// and ``while``) in C++ according to the LLVM coding style.
3919 /// \warning
3920 /// This option will be renamed and expanded to support other styles.
3921 /// \endwarning
3922 /// \warning
3923 /// Setting this option to ``true`` could lead to incorrect code formatting
3924 /// due to clang-format's lack of complete semantic information. As such,
3925 /// extra care should be taken to review code changes made by this option.
3926 /// \endwarning
3927 /// \code
3928 /// false: true:
3929 ///
3930 /// if (isa<FunctionDecl>(D)) { vs. if (isa<FunctionDecl>(D))
3931 /// handleFunctionDecl(D); handleFunctionDecl(D);
3932 /// } else if (isa<VarDecl>(D)) { else if (isa<VarDecl>(D))
3933 /// handleVarDecl(D); handleVarDecl(D);
3934 /// }
3935 ///
3936 /// if (isa<VarDecl>(D)) { vs. if (isa<VarDecl>(D)) {
3937 /// for (auto *A : D.attrs()) { for (auto *A : D.attrs())
3938 /// if (shouldProcessAttr(A)) { if (shouldProcessAttr(A))
3939 /// handleAttr(A); handleAttr(A);
3940 /// } }
3941 /// }
3942 /// }
3943 ///
3944 /// if (isa<FunctionDecl>(D)) { vs. if (isa<FunctionDecl>(D))
3945 /// for (auto *A : D.attrs()) { for (auto *A : D.attrs())
3946 /// handleAttr(A); handleAttr(A);
3947 /// }
3948 /// }
3949 ///
3950 /// if (auto *D = (T)(D)) { vs. if (auto *D = (T)(D)) {
3951 /// if (shouldProcess(D)) { if (shouldProcess(D))
3952 /// handleVarDecl(D); handleVarDecl(D);
3953 /// } else { else
3954 /// markAsIgnored(D); markAsIgnored(D);
3955 /// } }
3956 /// }
3957 ///
3958 /// if (a) { vs. if (a)
3959 /// b(); b();
3960 /// } else { else if (c)
3961 /// if (c) { d();
3962 /// d(); else
3963 /// } else { e();
3964 /// e();
3965 /// }
3966 /// }
3967 /// \endcode
3968 /// \version 14
3970
3971 /// Remove empty lines within unwrapped lines.
3972 /// \code
3973 /// false: true:
3974 ///
3975 /// int c vs. int c = a + b;
3976 ///
3977 /// = a + b;
3978 ///
3979 /// enum : unsigned vs. enum : unsigned {
3980 /// AA = 0,
3981 /// { BB
3982 /// AA = 0, } myEnum;
3983 /// BB
3984 /// } myEnum;
3985 ///
3986 /// while ( vs. while (true) {
3987 /// }
3988 /// true) {
3989 /// }
3990 /// \endcode
3991 /// \version 20
3993
3994 /// Types of redundant parentheses to remove.
3996 /// Do not remove parentheses.
3997 /// \code
3998 /// class __declspec((dllimport)) X {};
3999 /// co_return (((0)));
4000 /// return ((a + b) - ((c + d)));
4001 /// \endcode
4003 /// Replace multiple parentheses with single parentheses.
4004 /// \code
4005 /// class __declspec(dllimport) X {};
4006 /// co_return (0);
4007 /// return ((a + b) - (c + d));
4008 /// \endcode
4010 /// Also remove parentheses enclosing the expression in a
4011 /// ``return``/``co_return`` statement.
4012 /// \code
4013 /// class __declspec(dllimport) X {};
4014 /// co_return 0;
4015 /// return (a + b) - (c + d);
4016 /// \endcode
4018 };
4019
4020 /// Remove redundant parentheses.
4021 /// \warning
4022 /// Setting this option to any value other than ``Leave`` could lead to
4023 /// incorrect code formatting due to clang-format's lack of complete semantic
4024 /// information. As such, extra care should be taken to review code changes
4025 /// made by this option.
4026 /// \endwarning
4027 /// \version 17
4029
4030 /// Remove semicolons after the closing braces of functions and
4031 /// constructors/destructors.
4032 /// \warning
4033 /// Setting this option to ``true`` could lead to incorrect code formatting
4034 /// due to clang-format's lack of complete semantic information. As such,
4035 /// extra care should be taken to review code changes made by this option.
4036 /// \endwarning
4037 /// \code
4038 /// false: true:
4039 ///
4040 /// int max(int a, int b) { int max(int a, int b) {
4041 /// return a > b ? a : b; return a > b ? a : b;
4042 /// }; }
4043 ///
4044 /// \endcode
4045 /// \version 16
4047
4048 /// \brief The possible positions for the requires clause. The
4049 /// ``IndentRequires`` option is only used if the ``requires`` is put on the
4050 /// start of a line.
4052 /// Always put the ``requires`` clause on its own line (possibly followed by
4053 /// a semicolon).
4054 /// \code
4055 /// template <typename T>
4056 /// requires C<T>
4057 /// struct Foo {...
4058 ///
4059 /// template <typename T>
4060 /// void bar(T t)
4061 /// requires C<T>;
4062 ///
4063 /// template <typename T>
4064 /// requires C<T>
4065 /// void bar(T t) {...
4066 ///
4067 /// template <typename T>
4068 /// void baz(T t)
4069 /// requires C<T>
4070 /// {...
4071 /// \endcode
4073 /// As with ``OwnLine``, except, unless otherwise prohibited, place a
4074 /// following open brace (of a function definition) to follow on the same
4075 /// line.
4076 /// \code
4077 /// void bar(T t)
4078 /// requires C<T> {
4079 /// return;
4080 /// }
4081 ///
4082 /// void bar(T t)
4083 /// requires C<T> {}
4084 ///
4085 /// template <typename T>
4086 /// requires C<T>
4087 /// void baz(T t) {
4088 /// ...
4089 /// \endcode
4091 /// Try to put the clause together with the preceding part of a declaration.
4092 /// For class templates: stick to the template declaration.
4093 /// For function templates: stick to the template declaration.
4094 /// For function declaration followed by a requires clause: stick to the
4095 /// parameter list.
4096 /// \code
4097 /// template <typename T> requires C<T>
4098 /// struct Foo {...
4099 ///
4100 /// template <typename T> requires C<T>
4101 /// void bar(T t) {...
4102 ///
4103 /// template <typename T>
4104 /// void baz(T t) requires C<T>
4105 /// {...
4106 /// \endcode
4108 /// Try to put the ``requires`` clause together with the class or function
4109 /// declaration.
4110 /// \code
4111 /// template <typename T>
4112 /// requires C<T> struct Foo {...
4113 ///
4114 /// template <typename T>
4115 /// requires C<T> void bar(T t) {...
4116 ///
4117 /// template <typename T>
4118 /// void baz(T t)
4119 /// requires C<T> {...
4120 /// \endcode
4122 /// Try to put everything in the same line if possible. Otherwise normal
4123 /// line breaking rules take over.
4124 /// \code
4125 /// // Fitting:
4126 /// template <typename T> requires C<T> struct Foo {...
4127 ///
4128 /// template <typename T> requires C<T> void bar(T t) {...
4129 ///
4130 /// template <typename T> void bar(T t) requires C<T> {...
4131 ///
4132 /// // Not fitting, one possible example:
4133 /// template <typename LongName>
4134 /// requires C<LongName>
4135 /// struct Foo {...
4136 ///
4137 /// template <typename LongName>
4138 /// requires C<LongName>
4139 /// void bar(LongName ln) {
4140 ///
4141 /// template <typename LongName>
4142 /// void bar(LongName ln)
4143 /// requires C<LongName> {
4144 /// \endcode
4146 };
4147
4148 /// \brief The position of the ``requires`` clause.
4149 /// \version 15
4151
4152 /// Indentation logic for requires expression bodies.
4154 /// Align requires expression body relative to the indentation level of the
4155 /// outer scope the requires expression resides in.
4156 /// This is the default.
4157 /// \code
4158 /// template <typename T>
4159 /// concept C = requires(T t) {
4160 /// ...
4161 /// }
4162 /// \endcode
4164 /// Align requires expression body relative to the ``requires`` keyword.
4165 /// \code
4166 /// template <typename T>
4167 /// concept C = requires(T t) {
4168 /// ...
4169 /// }
4170 /// \endcode
4172 };
4173
4174 /// The indentation used for requires expression bodies.
4175 /// \version 16
4177
4178 /// \brief The style if definition blocks should be separated.
4180 /// Leave definition blocks as they are.
4182 /// Insert an empty line between definition blocks.
4184 /// Remove any empty line between definition blocks.
4185 SDS_Never
4187
4188 /// Specifies the use of empty lines to separate definition blocks, including
4189 /// classes, structs, enums, and functions.
4190 /// \code
4191 /// Never v.s. Always
4192 /// #include <cstring> #include <cstring>
4193 /// struct Foo {
4194 /// int a, b, c; struct Foo {
4195 /// }; int a, b, c;
4196 /// namespace Ns { };
4197 /// class Bar {
4198 /// public: namespace Ns {
4199 /// struct Foobar { class Bar {
4200 /// int a; public:
4201 /// int b; struct Foobar {
4202 /// }; int a;
4203 /// private: int b;
4204 /// int t; };
4205 /// int method1() {
4206 /// // ... private:
4207 /// } int t;
4208 /// enum List {
4209 /// ITEM1, int method1() {
4210 /// ITEM2 // ...
4211 /// }; }
4212 /// template<typename T>
4213 /// int method2(T x) { enum List {
4214 /// // ... ITEM1,
4215 /// } ITEM2
4216 /// int i, j, k; };
4217 /// int method3(int par) {
4218 /// // ... template<typename T>
4219 /// } int method2(T x) {
4220 /// }; // ...
4221 /// class C {}; }
4222 /// }
4223 /// int i, j, k;
4224 ///
4225 /// int method3(int par) {
4226 /// // ...
4227 /// }
4228 /// };
4229 ///
4230 /// class C {};
4231 /// }
4232 /// \endcode
4233 /// \version 14
4235
4236 /// The maximal number of unwrapped lines that a short namespace spans.
4237 /// Defaults to 1.
4238 ///
4239 /// This determines the maximum length of short namespaces by counting
4240 /// unwrapped lines (i.e. containing neither opening nor closing
4241 /// namespace brace) and makes ``FixNamespaceComments`` omit adding
4242 /// end comments for those.
4243 /// \code
4244 /// ShortNamespaceLines: 1 vs. ShortNamespaceLines: 0
4245 /// namespace a { namespace a {
4246 /// int foo; int foo;
4247 /// } } // namespace a
4248 ///
4249 /// ShortNamespaceLines: 1 vs. ShortNamespaceLines: 0
4250 /// namespace b { namespace b {
4251 /// int foo; int foo;
4252 /// int bar; int bar;
4253 /// } // namespace b } // namespace b
4254 /// \endcode
4255 /// \version 13
4257
4258 /// Do not format macro definition body.
4259 /// \version 18
4261
4262 /// Include sorting options.
4263 enum SortIncludesOptions : int8_t {
4264 /// Includes are never sorted.
4265 /// \code
4266 /// #include "B/A.h"
4267 /// #include "A/B.h"
4268 /// #include "a/b.h"
4269 /// #include "A/b.h"
4270 /// #include "B/a.h"
4271 /// \endcode
4273 /// Includes are sorted in an ASCIIbetical or case sensitive fashion.
4274 /// \code
4275 /// #include "A/B.h"
4276 /// #include "A/b.h"
4277 /// #include "B/A.h"
4278 /// #include "B/a.h"
4279 /// #include "a/b.h"
4280 /// \endcode
4282 /// Includes are sorted in an alphabetical or case insensitive fashion.
4283 /// \code
4284 /// #include "A/B.h"
4285 /// #include "A/b.h"
4286 /// #include "a/b.h"
4287 /// #include "B/A.h"
4288 /// #include "B/a.h"
4289 /// \endcode
4291 };
4292
4293 /// Controls if and how clang-format will sort ``#includes``.
4294 /// \version 3.8
4296
4297 /// Position for Java Static imports.
4299 /// Static imports are placed before non-static imports.
4300 /// \code{.java}
4301 /// import static org.example.function1;
4302 ///
4303 /// import org.example.ClassA;
4304 /// \endcode
4306 /// Static imports are placed after non-static imports.
4307 /// \code{.java}
4308 /// import org.example.ClassA;
4309 ///
4310 /// import static org.example.function1;
4311 /// \endcode
4313 };
4314
4315 /// When sorting Java imports, by default static imports are placed before
4316 /// non-static imports. If ``JavaStaticImportAfterImport`` is ``After``,
4317 /// static imports are placed after non-static imports.
4318 /// \version 12
4320
4321 /// Using declaration sorting options.
4323 /// Using declarations are never sorted.
4324 /// \code
4325 /// using std::chrono::duration_cast;
4326 /// using std::move;
4327 /// using boost::regex;
4328 /// using boost::regex_constants::icase;
4329 /// using std::string;
4330 /// \endcode
4332 /// Using declarations are sorted in the order defined as follows:
4333 /// Split the strings by ``::`` and discard any initial empty strings. Sort
4334 /// the lists of names lexicographically, and within those groups, names are
4335 /// in case-insensitive lexicographic order.
4336 /// \code
4337 /// using boost::regex;
4338 /// using boost::regex_constants::icase;
4339 /// using std::chrono::duration_cast;
4340 /// using std::move;
4341 /// using std::string;
4342 /// \endcode
4344 /// Using declarations are sorted in the order defined as follows:
4345 /// Split the strings by ``::`` and discard any initial empty strings. The
4346 /// last element of each list is a non-namespace name; all others are
4347 /// namespace names. Sort the lists of names lexicographically, where the
4348 /// sort order of individual names is that all non-namespace names come
4349 /// before all namespace names, and within those groups, names are in
4350 /// case-insensitive lexicographic order.
4351 /// \code
4352 /// using boost::regex;
4353 /// using boost::regex_constants::icase;
4354 /// using std::move;
4355 /// using std::string;
4356 /// using std::chrono::duration_cast;
4357 /// \endcode
4359 };
4360
4361 /// Controls if and how clang-format will sort using declarations.
4362 /// \version 5
4364
4365 /// If ``true``, a space is inserted after C style casts.
4366 /// \code
4367 /// true: false:
4368 /// (int) i; vs. (int)i;
4369 /// \endcode
4370 /// \version 3.5
4372
4373 /// If ``true``, a space is inserted after the logical not operator (``!``).
4374 /// \code
4375 /// true: false:
4376 /// ! someExpression(); vs. !someExpression();
4377 /// \endcode
4378 /// \version 9
4380
4381 /// If \c true, a space will be inserted after the ``template`` keyword.
4382 /// \code
4383 /// true: false:
4384 /// template <int> void foo(); vs. template<int> void foo();
4385 /// \endcode
4386 /// \version 4
4388
4389 /// Different ways to put a space before opening parentheses.
4391 /// Don't ensure spaces around pointer qualifiers and use PointerAlignment
4392 /// instead.
4393 /// \code
4394 /// PointerAlignment: Left PointerAlignment: Right
4395 /// void* const* x = NULL; vs. void *const *x = NULL;
4396 /// \endcode
4398 /// Ensure that there is a space before pointer qualifiers.
4399 /// \code
4400 /// PointerAlignment: Left PointerAlignment: Right
4401 /// void* const* x = NULL; vs. void * const *x = NULL;
4402 /// \endcode
4404 /// Ensure that there is a space after pointer qualifiers.
4405 /// \code
4406 /// PointerAlignment: Left PointerAlignment: Right
4407 /// void* const * x = NULL; vs. void *const *x = NULL;
4408 /// \endcode
4410 /// Ensure that there is a space both before and after pointer qualifiers.
4411 /// \code
4412 /// PointerAlignment: Left PointerAlignment: Right
4413 /// void* const * x = NULL; vs. void * const *x = NULL;
4414 /// \endcode
4416 };
4417
4418 /// Defines in which cases to put a space before or after pointer qualifiers
4419 /// \version 12
4421
4422 /// If ``false``, spaces will be removed before assignment operators.
4423 /// \code
4424 /// true: false:
4425 /// int a = 5; vs. int a= 5;
4426 /// a += 42; a+= 42;
4427 /// \endcode
4428 /// \version 3.7
4430
4431 /// If ``false``, spaces will be removed before case colon.
4432 /// \code
4433 /// true: false
4434 /// switch (x) { vs. switch (x) {
4435 /// case 1 : break; case 1: break;
4436 /// } }
4437 /// \endcode
4438 /// \version 12
4440
4441 /// If ``true``, a space will be inserted before a C++11 braced list
4442 /// used to initialize an object (after the preceding identifier or type).
4443 /// \code
4444 /// true: false:
4445 /// Foo foo { bar }; vs. Foo foo{ bar };
4446 /// Foo {}; Foo{};
4447 /// vector<int> { 1, 2, 3 }; vector<int>{ 1, 2, 3 };
4448 /// new int[3] { 1, 2, 3 }; new int[3]{ 1, 2, 3 };
4449 /// \endcode
4450 /// \version 7
4452
4453 /// If ``false``, spaces will be removed before constructor initializer
4454 /// colon.
4455 /// \code
4456 /// true: false:
4457 /// Foo::Foo() : a(a) {} Foo::Foo(): a(a) {}
4458 /// \endcode
4459 /// \version 7
4461
4462 /// If ``false``, spaces will be removed before inheritance colon.
4463 /// \code
4464 /// true: false:
4465 /// class Foo : Bar {} vs. class Foo: Bar {}
4466 /// \endcode
4467 /// \version 7
4469
4470 /// If ``true``, a space will be added before a JSON colon. For other
4471 /// languages, e.g. JavaScript, use ``SpacesInContainerLiterals`` instead.
4472 /// \code
4473 /// true: false:
4474 /// { {
4475 /// "key" : "value" vs. "key": "value"
4476 /// } }
4477 /// \endcode
4478 /// \version 17
4480
4481 /// Different ways to put a space before opening parentheses.
4483 /// This is **deprecated** and replaced by ``Custom`` below, with all
4484 /// ``SpaceBeforeParensOptions`` but ``AfterPlacementOperator`` set to
4485 /// ``false``.
4487 /// Put a space before opening parentheses only after control statement
4488 /// keywords (``for/if/while...``).
4489 /// \code
4490 /// void f() {
4491 /// if (true) {
4492 /// f();
4493 /// }
4494 /// }
4495 /// \endcode
4497 /// Same as ``SBPO_ControlStatements`` except this option doesn't apply to
4498 /// ForEach and If macros. This is useful in projects where ForEach/If
4499 /// macros are treated as function calls instead of control statements.
4500 /// ``SBPO_ControlStatementsExceptForEachMacros`` remains an alias for
4501 /// backward compatibility.
4502 /// \code
4503 /// void f() {
4504 /// Q_FOREACH(...) {
4505 /// f();
4506 /// }
4507 /// }
4508 /// \endcode
4510 /// Put a space before opening parentheses only if the parentheses are not
4511 /// empty.
4512 /// \code
4513 /// void() {
4514 /// if (true) {
4515 /// f();
4516 /// g (x, y, z);
4517 /// }
4518 /// }
4519 /// \endcode
4521 /// Always put a space before opening parentheses, except when it's
4522 /// prohibited by the syntax rules (in function-like macro definitions) or
4523 /// when determined by other style rules (after unary operators, opening
4524 /// parentheses, etc.)
4525 /// \code
4526 /// void f () {
4527 /// if (true) {
4528 /// f ();
4529 /// }
4530 /// }
4531 /// \endcode
4533 /// Configure each individual space before parentheses in
4534 /// ``SpaceBeforeParensOptions``.
4536 };
4537
4538 /// Defines in which cases to put a space before opening parentheses.
4539 /// \version 3.5
4541
4542 /// Precise control over the spacing before parentheses.
4543 /// \code
4544 /// # Should be declared this way:
4545 /// SpaceBeforeParens: Custom
4546 /// SpaceBeforeParensOptions:
4547 /// AfterControlStatements: true
4548 /// AfterFunctionDefinitionName: true
4549 /// \endcode
4551 /// If ``true``, put space between control statement keywords
4552 /// (for/if/while...) and opening parentheses.
4553 /// \code
4554 /// true: false:
4555 /// if (...) {} vs. if(...) {}
4556 /// \endcode
4558 /// If ``true``, put space between foreach macros and opening parentheses.
4559 /// \code
4560 /// true: false:
4561 /// FOREACH (...) vs. FOREACH(...)
4562 /// <loop-body> <loop-body>
4563 /// \endcode
4565 /// If ``true``, put a space between function declaration name and opening
4566 /// parentheses.
4567 /// \code
4568 /// true: false:
4569 /// void f (); vs. void f();
4570 /// \endcode
4572 /// If ``true``, put a space between function definition name and opening
4573 /// parentheses.
4574 /// \code
4575 /// true: false:
4576 /// void f () {} vs. void f() {}
4577 /// \endcode
4579 /// If ``true``, put space between if macros and opening parentheses.
4580 /// \code
4581 /// true: false:
4582 /// IF (...) vs. IF(...)
4583 /// <conditional-body> <conditional-body>
4584 /// \endcode
4586 /// If ``true``, put a space between operator overloading and opening
4587 /// parentheses.
4588 /// \code
4589 /// true: false:
4590 /// void operator++ (int a); vs. void operator++(int a);
4591 /// object.operator++ (10); object.operator++(10);
4592 /// \endcode
4594 /// If ``true``, put a space between operator ``new``/``delete`` and opening
4595 /// parenthesis.
4596 /// \code
4597 /// true: false:
4598 /// new (buf) T; vs. new(buf) T;
4599 /// delete (buf) T; delete(buf) T;
4600 /// \endcode
4602 /// If ``true``, put space between requires keyword in a requires clause and
4603 /// opening parentheses, if there is one.
4604 /// \code
4605 /// true: false:
4606 /// template<typename T> vs. template<typename T>
4607 /// requires (A<T> && B<T>) requires(A<T> && B<T>)
4608 /// ... ...
4609 /// \endcode
4611 /// If ``true``, put space between requires keyword in a requires expression
4612 /// and opening parentheses.
4613 /// \code
4614 /// true: false:
4615 /// template<typename T> vs. template<typename T>
4616 /// concept C = requires (T t) { concept C = requires(T t) {
4617 /// ... ...
4618 /// } }
4619 /// \endcode
4621 /// If ``true``, put a space before opening parentheses only if the
4622 /// parentheses are not empty.
4623 /// \code
4624 /// true: false:
4625 /// void f (int a); vs. void f();
4626 /// f (a); f();
4627 /// \endcode
4629
4637
4639 return AfterControlStatements == Other.AfterControlStatements &&
4640 AfterForeachMacros == Other.AfterForeachMacros &&
4642 Other.AfterFunctionDeclarationName &&
4643 AfterFunctionDefinitionName == Other.AfterFunctionDefinitionName &&
4644 AfterIfMacros == Other.AfterIfMacros &&
4645 AfterOverloadedOperator == Other.AfterOverloadedOperator &&
4646 AfterPlacementOperator == Other.AfterPlacementOperator &&
4647 AfterRequiresInClause == Other.AfterRequiresInClause &&
4648 AfterRequiresInExpression == Other.AfterRequiresInExpression &&
4649 BeforeNonEmptyParentheses == Other.BeforeNonEmptyParentheses;
4650 }
4651 };
4652
4653 /// Control of individual space before parentheses.
4654 ///
4655 /// If ``SpaceBeforeParens`` is set to ``Custom``, use this to specify
4656 /// how each individual space before parentheses case should be handled.
4657 /// Otherwise, this is ignored.
4658 /// \code{.yaml}
4659 /// # Example of usage:
4660 /// SpaceBeforeParens: Custom
4661 /// SpaceBeforeParensOptions:
4662 /// AfterControlStatements: true
4663 /// AfterFunctionDefinitionName: true
4664 /// \endcode
4665 /// \version 14
4667
4668 /// If ``true``, spaces will be before ``[``.
4669 /// Lambdas will not be affected. Only the first ``[`` will get a space added.
4670 /// \code
4671 /// true: false:
4672 /// int a [5]; vs. int a[5];
4673 /// int a [5][5]; vs. int a[5][5];
4674 /// \endcode
4675 /// \version 10
4677
4678 /// If ``false``, spaces will be removed before range-based for loop
4679 /// colon.
4680 /// \code
4681 /// true: false:
4682 /// for (auto v : values) {} vs. for(auto v: values) {}
4683 /// \endcode
4684 /// \version 7
4686
4687 /// If ``true``, spaces will be inserted into ``{}``.
4688 /// \code
4689 /// true: false:
4690 /// void f() { } vs. void f() {}
4691 /// while (true) { } while (true) {}
4692 /// \endcode
4693 /// \version 10
4695
4696 /// If ``true``, spaces may be inserted into ``()``.
4697 /// This option is **deprecated**. See ``InEmptyParentheses`` of
4698 /// ``SpacesInParensOptions``.
4699 /// \version 3.7
4700 // bool SpaceInEmptyParentheses;
4701
4702 /// The number of spaces before trailing line comments
4703 /// (``//`` - comments).
4704 ///
4705 /// This does not affect trailing block comments (``/*`` - comments) as those
4706 /// commonly have different usage patterns and a number of special cases. In
4707 /// the case of Verilog, it doesn't affect a comment right after the opening
4708 /// parenthesis in the port or parameter list in a module header, because it
4709 /// is probably for the port on the following line instead of the parenthesis
4710 /// it follows.
4711 /// \code
4712 /// SpacesBeforeTrailingComments: 3
4713 /// void f() {
4714 /// if (true) { // foo1
4715 /// f(); // bar
4716 /// } // foo
4717 /// }
4718 /// \endcode
4719 /// \version 3.7
4721
4722 /// Styles for adding spacing after ``<`` and before ``>``
4723 /// in template argument lists.
4724 enum SpacesInAnglesStyle : int8_t {
4725 /// Remove spaces after ``<`` and before ``>``.
4726 /// \code
4727 /// static_cast<int>(arg);
4728 /// std::function<void(int)> fct;
4729 /// \endcode
4731 /// Add spaces after ``<`` and before ``>``.
4732 /// \code
4733 /// static_cast< int >(arg);
4734 /// std::function< void(int) > fct;
4735 /// \endcode
4737 /// Keep a single space after ``<`` and before ``>`` if any spaces were
4738 /// present. Option ``Standard: Cpp03`` takes precedence.
4741 /// The SpacesInAnglesStyle to use for template argument lists.
4742 /// \version 3.4
4744
4745 /// If ``true``, spaces will be inserted around if/for/switch/while
4746 /// conditions.
4747 /// This option is **deprecated**. See ``InConditionalStatements`` of
4748 /// ``SpacesInParensOptions``.
4749 /// \version 10
4750 // bool SpacesInConditionalStatement;
4751
4752 /// If ``true``, spaces are inserted inside container literals (e.g. ObjC and
4753 /// Javascript array and dict literals). For JSON, use
4754 /// ``SpaceBeforeJsonColon`` instead.
4755 /// \code{.js}
4756 /// true: false:
4757 /// var arr = [ 1, 2, 3 ]; vs. var arr = [1, 2, 3];
4758 /// f({a : 1, b : 2, c : 3}); f({a: 1, b: 2, c: 3});
4759 /// \endcode
4760 /// \version 3.7
4762
4763 /// If ``true``, spaces may be inserted into C style casts.
4764 /// This option is **deprecated**. See ``InCStyleCasts`` of
4765 /// ``SpacesInParensOptions``.
4766 /// \version 3.7
4767 // bool SpacesInCStyleCastParentheses;
4768
4769 /// Control of spaces within a single line comment.
4771 /// The minimum number of spaces at the start of the comment.
4772 unsigned Minimum;
4773 /// The maximum number of spaces at the start of the comment.
4774 unsigned Maximum;
4775 };
4776
4777 /// How many spaces are allowed at the start of a line comment. To disable the
4778 /// maximum set it to ``-1``, apart from that the maximum takes precedence
4779 /// over the minimum.
4780 /// \code
4781 /// Minimum = 1
4782 /// Maximum = -1
4783 /// // One space is forced
4784 ///
4785 /// // but more spaces are possible
4786 ///
4787 /// Minimum = 0
4788 /// Maximum = 0
4789 /// //Forces to start every comment directly after the slashes
4790 /// \endcode
4791 ///
4792 /// Note that in line comment sections the relative indent of the subsequent
4793 /// lines is kept, that means the following:
4794 /// \code
4795 /// before: after:
4796 /// Minimum: 1
4797 /// //if (b) { // if (b) {
4798 /// // return true; // return true;
4799 /// //} // }
4800 ///
4801 /// Maximum: 0
4802 /// /// List: ///List:
4803 /// /// - Foo /// - Foo
4804 /// /// - Bar /// - Bar
4805 /// \endcode
4806 ///
4807 /// This option has only effect if ``ReflowComments`` is set to ``true``.
4808 /// \version 13
4810
4811 /// Different ways to put a space before opening and closing parentheses.
4812 enum SpacesInParensStyle : int8_t {
4813 /// Never put a space in parentheses.
4814 /// \code
4815 /// void f() {
4816 /// if(true) {
4817 /// f();
4818 /// }
4819 /// }
4820 /// \endcode
4822 /// Configure each individual space in parentheses in
4823 /// `SpacesInParensOptions`.
4825 };
4826
4827 /// If ``true``, spaces will be inserted after ``(`` and before ``)``.
4828 /// This option is **deprecated**. The previous behavior is preserved by using
4829 /// ``SpacesInParens`` with ``Custom`` and by setting all
4830 /// ``SpacesInParensOptions`` to ``true`` except for ``InCStyleCasts`` and
4831 /// ``InEmptyParentheses``.
4832 /// \version 3.7
4833 // bool SpacesInParentheses;
4834
4835 /// Defines in which cases spaces will be inserted after ``(`` and before
4836 /// ``)``.
4837 /// \version 17
4839
4840 /// Precise control over the spacing in parentheses.
4841 /// \code
4842 /// # Should be declared this way:
4843 /// SpacesInParens: Custom
4844 /// SpacesInParensOptions:
4845 /// ExceptDoubleParentheses: false
4846 /// InConditionalStatements: true
4847 /// Other: true
4848 /// \endcode
4850 /// Override any of the following options to prevent addition of space
4851 /// when both opening and closing parentheses use multiple parentheses.
4852 /// \code
4853 /// true:
4854 /// __attribute__(( noreturn ))
4855 /// __decltype__(( x ))
4856 /// if (( a = b ))
4857 /// \endcode
4858 /// false:
4859 /// Uses the applicable option.
4861 /// Put a space in parentheses only inside conditional statements
4862 /// (``for/if/while/switch...``).
4863 /// \code
4864 /// true: false:
4865 /// if ( a ) { ... } vs. if (a) { ... }
4866 /// while ( i < 5 ) { ... } while (i < 5) { ... }
4867 /// \endcode
4869 /// Put a space in C style casts.
4870 /// \code
4871 /// true: false:
4872 /// x = ( int32 )y vs. x = (int32)y
4873 /// y = (( int (*)(int) )foo)(x); y = ((int (*)(int))foo)(x);
4874 /// \endcode
4876 /// Insert a space in empty parentheses, i.e. ``()``.
4877 /// \code
4878 /// true: false:
4879 /// void f( ) { vs. void f() {
4880 /// int x[] = {foo( ), bar( )}; int x[] = {foo(), bar()};
4881 /// if (true) { if (true) {
4882 /// f( ); f();
4883 /// } }
4884 /// } }
4885 /// \endcode
4887 /// Put a space in parentheses not covered by preceding options.
4888 /// \code
4889 /// true: false:
4890 /// t f( Deleted & ) & = delete; vs. t f(Deleted &) & = delete;
4891 /// \endcode
4892 bool Other;
4893
4897
4900 bool InEmptyParentheses, bool Other)
4904 Other(Other) {}
4905
4906 bool operator==(const SpacesInParensCustom &R) const {
4911 }
4912 bool operator!=(const SpacesInParensCustom &R) const {
4913 return !(*this == R);
4914 }
4915 };
4916
4917 /// Control of individual spaces in parentheses.
4918 ///
4919 /// If ``SpacesInParens`` is set to ``Custom``, use this to specify
4920 /// how each individual space in parentheses case should be handled.
4921 /// Otherwise, this is ignored.
4922 /// \code{.yaml}
4923 /// # Example of usage:
4924 /// SpacesInParens: Custom
4925 /// SpacesInParensOptions:
4926 /// ExceptDoubleParentheses: false
4927 /// InConditionalStatements: true
4928 /// InEmptyParentheses: true
4929 /// \endcode
4930 /// \version 17
4932
4933 /// If ``true``, spaces will be inserted after ``[`` and before ``]``.
4934 /// Lambdas without arguments or unspecified size array declarations will not
4935 /// be affected.
4936 /// \code
4937 /// true: false:
4938 /// int a[ 5 ]; vs. int a[5];
4939 /// std::unique_ptr<int[]> foo() {} // Won't be affected
4940 /// \endcode
4941 /// \version 3.7
4943
4944 /// Supported language standards for parsing and formatting C++ constructs.
4945 /// \code
4946 /// Latest: vector<set<int>>
4947 /// c++03 vs. vector<set<int> >
4948 /// \endcode
4949 ///
4950 /// The correct way to spell a specific language version is e.g. ``c++11``.
4951 /// The historical aliases ``Cpp03`` and ``Cpp11`` are deprecated.
4952 enum LanguageStandard : int8_t {
4953 /// Parse and format as C++03.
4954 /// ``Cpp03`` is a deprecated alias for ``c++03``
4955 LS_Cpp03, // c++03
4956 /// Parse and format as C++11.
4957 LS_Cpp11, // c++11
4958 /// Parse and format as C++14.
4959 LS_Cpp14, // c++14
4960 /// Parse and format as C++17.
4961 LS_Cpp17, // c++17
4962 /// Parse and format as C++20.
4963 LS_Cpp20, // c++20
4964 /// Parse and format using the latest supported language version.
4965 /// ``Cpp11`` is a deprecated alias for ``Latest``
4967 /// Automatic detection based on the input.
4969 };
4970
4971 /// Parse and format C++ constructs compatible with this standard.
4972 /// \code
4973 /// c++03: latest:
4974 /// vector<set<int> > x; vs. vector<set<int>> x;
4975 /// \endcode
4976 /// \version 3.7
4978
4979 /// Macros which are ignored in front of a statement, as if they were an
4980 /// attribute. So that they are not parsed as identifier, for example for Qts
4981 /// emit.
4982 /// \code
4983 /// AlignConsecutiveDeclarations: true
4984 /// StatementAttributeLikeMacros: []
4985 /// unsigned char data = 'x';
4986 /// emit signal(data); // This is parsed as variable declaration.
4987 ///
4988 /// AlignConsecutiveDeclarations: true
4989 /// StatementAttributeLikeMacros: [emit]
4990 /// unsigned char data = 'x';
4991 /// emit signal(data); // Now it's fine again.
4992 /// \endcode
4993 /// \version 12
4994 std::vector<std::string> StatementAttributeLikeMacros;
4995
4996 /// A vector of macros that should be interpreted as complete statements.
4997 ///
4998 /// Typical macros are expressions and require a semicolon to be added.
4999 /// Sometimes this is not the case, and this allows to make clang-format aware
5000 /// of such cases.
5001 ///
5002 /// For example: Q_UNUSED
5003 /// \version 8
5004 std::vector<std::string> StatementMacros;
5005
5006 /// Works only when TableGenBreakInsideDAGArg is not DontBreak.
5007 /// The string list needs to consist of identifiers in TableGen.
5008 /// If any identifier is specified, this limits the line breaks by
5009 /// TableGenBreakInsideDAGArg option only on DAGArg values beginning with
5010 /// the specified identifiers.
5011 ///
5012 /// For example the configuration,
5013 /// \code{.yaml}
5014 /// TableGenBreakInsideDAGArg: BreakAll
5015 /// TableGenBreakingDAGArgOperators: [ins, outs]
5016 /// \endcode
5017 ///
5018 /// makes the line break only occurs inside DAGArgs beginning with the
5019 /// specified identifiers ``ins`` and ``outs``.
5020 ///
5021 /// \code
5022 /// let DAGArgIns = (ins
5023 /// i32:$src1,
5024 /// i32:$src2
5025 /// );
5026 /// let DAGArgOtherID = (other i32:$other1, i32:$other2);
5027 /// let DAGArgBang = (!cast<SomeType>("Some") i32:$src1, i32:$src2)
5028 /// \endcode
5029 /// \version 19
5030 std::vector<std::string> TableGenBreakingDAGArgOperators;
5031
5032 /// Different ways to control the format inside TableGen DAGArg.
5033 enum DAGArgStyle : int8_t {
5034 /// Never break inside DAGArg.
5035 /// \code
5036 /// let DAGArgIns = (ins i32:$src1, i32:$src2);
5037 /// \endcode
5039 /// Break inside DAGArg after each list element but for the last.
5040 /// This aligns to the first element.
5041 /// \code
5042 /// let DAGArgIns = (ins i32:$src1,
5043 /// i32:$src2);
5044 /// \endcode
5046 /// Break inside DAGArg after the operator and the all elements.
5047 /// \code
5048 /// let DAGArgIns = (ins
5049 /// i32:$src1,
5050 /// i32:$src2
5051 /// );
5052 /// \endcode
5054 };
5055
5056 /// The styles of the line break inside the DAGArg in TableGen.
5057 /// \version 19
5059
5060 /// The number of columns used for tab stops.
5061 /// \version 3.7
5062 unsigned TabWidth;
5063
5064 /// A vector of non-keyword identifiers that should be interpreted as template
5065 /// names.
5066 ///
5067 /// A ``<`` after a template name is annotated as a template opener instead of
5068 /// a binary operator.
5069 ///
5070 /// \version 20
5071 std::vector<std::string> TemplateNames;
5072
5073 /// A vector of non-keyword identifiers that should be interpreted as type
5074 /// names.
5075 ///
5076 /// A ``*``, ``&``, or ``&&`` between a type name and another non-keyword
5077 /// identifier is annotated as a pointer or reference token instead of a
5078 /// binary operator.
5079 ///
5080 /// \version 17
5081 std::vector<std::string> TypeNames;
5082
5083 /// \brief A vector of macros that should be interpreted as type declarations
5084 /// instead of as function calls.
5085 ///
5086 /// These are expected to be macros of the form:
5087 /// \code
5088 /// STACK_OF(...)
5089 /// \endcode
5090 ///
5091 /// In the .clang-format configuration file, this can be configured like:
5092 /// \code{.yaml}
5093 /// TypenameMacros: [STACK_OF, LIST]
5094 /// \endcode
5095 ///
5096 /// For example: OpenSSL STACK_OF, BSD LIST_ENTRY.
5097 /// \version 9
5098 std::vector<std::string> TypenameMacros;
5099
5100 /// This option is **deprecated**. See ``LF`` and ``CRLF`` of ``LineEnding``.
5101 /// \version 10
5102 // bool UseCRLF;
5103
5104 /// Different ways to use tab in formatting.
5105 enum UseTabStyle : int8_t {
5106 /// Never use tab.
5108 /// Use tabs only for indentation.
5110 /// Fill all leading whitespace with tabs, and use spaces for alignment that
5111 /// appears within a line (e.g. consecutive assignments and declarations).
5113 /// Use tabs for line continuation and indentation, and spaces for
5114 /// alignment.
5116 /// Use tabs whenever we need to fill whitespace that spans at least from
5117 /// one tab stop to the next one.
5118 UT_Always
5120
5121 /// The way to use tab characters in the resulting file.
5122 /// \version 3.7
5124
5125 /// A vector of non-keyword identifiers that should be interpreted as variable
5126 /// template names.
5127 ///
5128 /// A ``)`` after a variable template instantiation is **not** annotated as
5129 /// the closing parenthesis of C-style cast operator.
5130 ///
5131 /// \version 20
5132 std::vector<std::string> VariableTemplates;
5133
5134 /// For Verilog, put each port on its own line in module instantiations.
5135 /// \code
5136 /// true:
5137 /// ffnand ff1(.q(),
5138 /// .qbar(out1),
5139 /// .clear(in1),
5140 /// .preset(in2));
5141 ///
5142 /// false:
5143 /// ffnand ff1(.q(), .qbar(out1), .clear(in1), .preset(in2));
5144 /// \endcode
5145 /// \version 17
5147
5148 /// A vector of macros which are whitespace-sensitive and should not
5149 /// be touched.
5150 ///
5151 /// These are expected to be macros of the form:
5152 /// \code
5153 /// STRINGIZE(...)
5154 /// \endcode
5155 ///
5156 /// In the .clang-format configuration file, this can be configured like:
5157 /// \code{.yaml}
5158 /// WhitespaceSensitiveMacros: [STRINGIZE, PP_STRINGIZE]
5159 /// \endcode
5160 ///
5161 /// For example: BOOST_PP_STRINGIZE
5162 /// \version 11
5163 std::vector<std::string> WhitespaceSensitiveMacros;
5164
5165 /// Different styles for wrapping namespace body with empty lines.
5167 /// Remove all empty lines at the beginning and the end of namespace body.
5168 /// \code
5169 /// namespace N1 {
5170 /// namespace N2
5171 /// function();
5172 /// }
5173 /// }
5174 /// \endcode
5176 /// Always have at least one empty line at the beginning and the end of
5177 /// namespace body except that the number of empty lines between consecutive
5178 /// nested namespace definitions is not increased.
5179 /// \code
5180 /// namespace N1 {
5181 /// namespace N2 {
5182 ///
5183 /// function();
5184 ///
5185 /// }
5186 /// }
5187 /// \endcode
5189 /// Keep existing newlines at the beginning and the end of namespace body.
5190 /// ``MaxEmptyLinesToKeep`` still applies.
5193
5194 /// Wrap namespace body with empty lines.
5195 /// \version 20
5197
5198 bool operator==(const FormatStyle &R) const {
5249 BreakArrays == R.BreakArrays &&
5291 IndentWidth == R.IndentWidth &&
5372 Standard == R.Standard &&
5385 }
5386
5387 std::optional<FormatStyle> GetLanguageStyle(LanguageKind Language) const;
5388
5389 // Stores per-language styles. A FormatStyle instance inside has an empty
5390 // StyleSet. A FormatStyle instance returned by the Get method has its
5391 // StyleSet set to a copy of the originating StyleSet, effectively keeping the
5392 // internal representation of that StyleSet alive.
5393 //
5394 // The memory management and ownership reminds of a birds nest: chicks
5395 // leaving the nest take photos of the nest with them.
5397 typedef std::map<FormatStyle::LanguageKind, FormatStyle> MapType;
5398
5399 std::optional<FormatStyle> Get(FormatStyle::LanguageKind Language) const;
5400
5401 // Adds \p Style to this FormatStyleSet. Style must not have an associated
5402 // FormatStyleSet.
5403 // Style.Language should be different than LK_None. If this FormatStyleSet
5404 // already contains an entry for Style.Language, that gets replaced with the
5405 // passed Style.
5406 void Add(FormatStyle Style);
5407
5408 // Clears this FormatStyleSet.
5409 void Clear();
5410
5411 private:
5412 std::shared_ptr<MapType> Styles;
5413 };
5414
5416 const FormatStyle &MainStyle,
5417 const std::vector<FormatStyle> &ConfigurationStyles);
5418
5419private:
5420 FormatStyleSet StyleSet;
5421
5422 friend std::error_code
5423 parseConfiguration(llvm::MemoryBufferRef Config, FormatStyle *Style,
5424 bool AllowUnknownOptions,
5425 llvm::SourceMgr::DiagHandlerTy DiagHandler,
5426 void *DiagHandlerCtxt);
5427};
5428
5429/// Returns a format style complying with the LLVM coding standards:
5430/// http://llvm.org/docs/CodingStandards.html.
5433
5434/// Returns a format style complying with one of Google's style guides:
5435/// http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml.
5436/// http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml.
5437/// https://developers.google.com/protocol-buffers/docs/style.
5439
5440/// Returns a format style complying with Chromium's style guide:
5441/// http://www.chromium.org/developers/coding-style.
5443
5444/// Returns a format style complying with Mozilla's style guide:
5445/// https://firefox-source-docs.mozilla.org/code-quality/coding-style/index.html.
5447
5448/// Returns a format style complying with Webkit's style guide:
5449/// http://www.webkit.org/coding/coding-style.html
5451
5452/// Returns a format style complying with GNU Coding Standards:
5453/// http://www.gnu.org/prep/standards/standards.html
5455
5456/// Returns a format style complying with Microsoft style guide:
5457/// https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference?view=vs-2017
5459
5461
5462/// Returns style indicating formatting should be not applied at all.
5464
5465/// Gets a predefined style for the specified language by name.
5466///
5467/// Currently supported names: LLVM, Google, Chromium, Mozilla. Names are
5468/// compared case-insensitively.
5469///
5470/// Returns ``true`` if the Style has been set.
5472 FormatStyle *Style);
5473
5474/// Parse configuration from YAML-formatted text.
5475///
5476/// Style->Language is used to get the base style, if the ``BasedOnStyle``
5477/// option is present.
5478///
5479/// The FormatStyleSet of Style is reset.
5480///
5481/// When ``BasedOnStyle`` is not present, options not present in the YAML
5482/// document, are retained in \p Style.
5483///
5484/// If AllowUnknownOptions is true, no errors are emitted if unknown
5485/// format options are occurred.
5486///
5487/// If set all diagnostics are emitted through the DiagHandler.
5488std::error_code
5489parseConfiguration(llvm::MemoryBufferRef Config, FormatStyle *Style,
5490 bool AllowUnknownOptions = false,
5491 llvm::SourceMgr::DiagHandlerTy DiagHandler = nullptr,
5492 void *DiagHandlerCtx = nullptr);
5493
5494/// Like above but accepts an unnamed buffer.
5495inline std::error_code parseConfiguration(StringRef Config, FormatStyle *Style,
5496 bool AllowUnknownOptions = false) {
5497 return parseConfiguration(llvm::MemoryBufferRef(Config, "YAML"), Style,
5498 AllowUnknownOptions);
5499}
5500
5501/// Gets configuration in a YAML string.
5502std::string configurationAsText(const FormatStyle &Style);
5503
5504/// Returns the replacements necessary to sort all ``#include`` blocks
5505/// that are affected by ``Ranges``.
5506tooling::Replacements sortIncludes(const FormatStyle &Style, StringRef Code,
5508 StringRef FileName,
5509 unsigned *Cursor = nullptr);
5510
5511/// Returns the replacements corresponding to applying and formatting
5512/// \p Replaces on success; otheriwse, return an llvm::Error carrying
5513/// llvm::StringError.
5515formatReplacements(StringRef Code, const tooling::Replacements &Replaces,
5516 const FormatStyle &Style);
5517
5518/// Returns the replacements corresponding to applying \p Replaces and
5519/// cleaning up the code after that on success; otherwise, return an llvm::Error
5520/// carrying llvm::StringError.
5521/// This also supports inserting/deleting C++ #include directives:
5522/// * If a replacement has offset UINT_MAX, length 0, and a replacement text
5523/// that is an #include directive, this will insert the #include into the
5524/// correct block in the \p Code.
5525/// * If a replacement has offset UINT_MAX, length 1, and a replacement text
5526/// that is the name of the header to be removed, the header will be removed
5527/// from \p Code if it exists.
5528/// The include manipulation is done via ``tooling::HeaderInclude``, see its
5529/// documentation for more details on how include insertion points are found and
5530/// what edits are produced.
5532cleanupAroundReplacements(StringRef Code, const tooling::Replacements &Replaces,
5533 const FormatStyle &Style);
5534
5535/// Represents the status of a formatting attempt.
5537 /// A value of ``false`` means that any of the affected ranges were not
5538 /// formatted due to a non-recoverable syntax error.
5539 bool FormatComplete = true;
5540
5541 /// If ``FormatComplete`` is false, ``Line`` records a one-based
5542 /// original line number at which a syntax error might have occurred. This is
5543 /// based on a best-effort analysis and could be imprecise.
5544 unsigned Line = 0;
5545};
5546
5547/// Reformats the given \p Ranges in \p Code.
5548///
5549/// Each range is extended on either end to its next bigger logic unit, i.e.
5550/// everything that might influence its formatting or might be influenced by its
5551/// formatting.
5552///
5553/// Returns the ``Replacements`` necessary to make all \p Ranges comply with
5554/// \p Style.
5555///
5556/// If ``Status`` is non-null, its value will be populated with the status of
5557/// this formatting attempt. See \c FormattingAttemptStatus.
5558tooling::Replacements reformat(const FormatStyle &Style, StringRef Code,
5560 StringRef FileName = "<stdin>",
5561 FormattingAttemptStatus *Status = nullptr);
5562
5563/// Same as above, except if ``IncompleteFormat`` is non-null, its value
5564/// will be set to true if any of the affected ranges were not formatted due to
5565/// a non-recoverable syntax error.
5566tooling::Replacements reformat(const FormatStyle &Style, StringRef Code,
5568 StringRef FileName, bool *IncompleteFormat);
5569
5570/// Clean up any erroneous/redundant code in the given \p Ranges in \p
5571/// Code.
5572///
5573/// Returns the ``Replacements`` that clean up all \p Ranges in \p Code.
5574tooling::Replacements cleanup(const FormatStyle &Style, StringRef Code,
5576 StringRef FileName = "<stdin>");
5577
5578/// Fix namespace end comments in the given \p Ranges in \p Code.
5579///
5580/// Returns the ``Replacements`` that fix the namespace comments in all
5581/// \p Ranges in \p Code.
5583 StringRef Code,
5585 StringRef FileName = "<stdin>");
5586
5587/// Inserts or removes empty lines separating definition blocks including
5588/// classes, structs, functions, namespaces, and enums in the given \p Ranges in
5589/// \p Code.
5590///
5591/// Returns the ``Replacements`` that inserts or removes empty lines separating
5592/// definition blocks in all \p Ranges in \p Code.
5594 StringRef Code,
5596 StringRef FileName = "<stdin>");
5597
5598/// Sort consecutive using declarations in the given \p Ranges in
5599/// \p Code.
5600///
5601/// Returns the ``Replacements`` that sort the using declarations in all
5602/// \p Ranges in \p Code.
5604 StringRef Code,
5606 StringRef FileName = "<stdin>");
5607
5608/// Returns the ``LangOpts`` that the formatter expects you to set.
5609///
5610/// \param Style determines specific settings for lexing mode.
5612
5613/// Description to be used for help text for a ``llvm::cl`` option for
5614/// specifying format style. The description is closely related to the operation
5615/// of ``getStyle()``.
5616extern const char *StyleOptionHelpDescription;
5617
5618/// The suggested format style to use by default. This allows tools using
5619/// ``getStyle`` to have a consistent default style.
5620/// Different builds can modify the value to the preferred styles.
5621extern const char *DefaultFormatStyle;
5622
5623/// The suggested predefined style to use as the fallback style in ``getStyle``.
5624/// Different builds can modify the value to the preferred styles.
5625extern const char *DefaultFallbackStyle;
5626
5627/// Construct a FormatStyle based on ``StyleName``.
5628///
5629/// ``StyleName`` can take several forms:
5630/// * "{<key>: <value>, ...}" - Set specic style parameters.
5631/// * "<style name>" - One of the style names supported by getPredefinedStyle().
5632/// * "file" - Load style configuration from a file called ``.clang-format``
5633/// located in one of the parent directories of ``FileName`` or the current
5634/// directory if ``FileName`` is empty.
5635/// * "file:<format_file_path>" to explicitly specify the configuration file to
5636/// use.
5637///
5638/// \param[in] StyleName Style name to interpret according to the description
5639/// above.
5640/// \param[in] FileName Path to start search for .clang-format if ``StyleName``
5641/// == "file".
5642/// \param[in] FallbackStyle The name of a predefined style used to fallback to
5643/// in case \p StyleName is "file" and no file can be found.
5644/// \param[in] Code The actual code to be formatted. Used to determine the
5645/// language if the filename isn't sufficient.
5646/// \param[in] FS The underlying file system, in which the file resides. By
5647/// default, the file system is the real file system.
5648/// \param[in] AllowUnknownOptions If true, unknown format options only
5649/// emit a warning. If false, errors are emitted on unknown format
5650/// options.
5651///
5652/// \returns FormatStyle as specified by ``StyleName``. If ``StyleName`` is
5653/// "file" and no file is found, returns ``FallbackStyle``. If no style could be
5654/// determined, returns an Error.
5656getStyle(StringRef StyleName, StringRef FileName, StringRef FallbackStyle,
5657 StringRef Code = "", llvm::vfs::FileSystem *FS = nullptr,
5658 bool AllowUnknownOptions = false,
5659 llvm::SourceMgr::DiagHandlerTy DiagHandler = nullptr);
5660
5661// Guesses the language from the ``FileName`` and ``Code`` to be formatted.
5662// Defaults to FormatStyle::LK_Cpp.
5663FormatStyle::LanguageKind guessLanguage(StringRef FileName, StringRef Code);
5664
5665// Returns a string representation of ``Language``.
5667 switch (Language) {
5669 return "C++";
5671 return "CSharp";
5673 return "Objective-C";
5675 return "Java";
5677 return "JavaScript";
5679 return "Json";
5681 return "Proto";
5683 return "TableGen";
5685 return "TextProto";
5687 return "Verilog";
5688 default:
5689 return "Unknown";
5690 }
5691}
5692
5693bool isClangFormatOn(StringRef Comment);
5694bool isClangFormatOff(StringRef Comment);
5695
5696} // end namespace format
5697} // end namespace clang
5698
5699template <>
5700struct std::is_error_code_enum<clang::format::ParseError> : std::true_type {};
5701
5702#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:500
const char * name() const noexcept override
Definition: Format.cpp:1313
std::string message(int EV) const override
Definition: Format.cpp:1317
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:3964
const char * DefaultFallbackStyle
The suggested predefined style to use as the fallback style in getStyle.
Definition: Format.cpp:4040
FormatStyle getWebKitStyle()
Returns a format style complying with Webkit's style guide: http://www.webkit.org/coding/coding-style...
Definition: Format.cpp:1922
std::error_code make_error_code(ParseError e)
Definition: Format.cpp:1304
FormatStyle getClangFormatStyle()
Definition: Format.cpp:1990
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:1471
FormatStyle getGoogleStyle(FormatStyle::LanguageKind Language)
Returns a format style complying with one of Google's style guides: http://google-styleguide....
Definition: Format.cpp:1694
std::string configurationAsText(const FormatStyle &Style)
Gets configuration in a YAML string.
Definition: Format.cpp:2139
FormatStyle getMicrosoftStyle(FormatStyle::LanguageKind Language)
Returns a format style complying with Microsoft style guide: https://docs.microsoft....
Definition: Format.cpp:1961
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:2073
const std::error_category & getParseCategory()
Definition: Format.cpp:1300
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:3915
FormatStyle::LanguageKind guessLanguage(StringRef FileName, StringRef Code)
Definition: Format.cpp:4019
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:4057
const char * DefaultFormatStyle
The suggested format style to use by default.
Definition: Format.cpp:4038
FormatStyle getGNUStyle()
Returns a format style complying with GNU Coding Standards: http://www.gnu.org/prep/standards/standar...
Definition: Format.cpp:1946
bool isClangFormatOff(StringRef Comment)
Definition: Format.cpp:4240
LangOptions getFormattingLangOpts(const FormatStyle &Style=getLLVMStyle())
Returns the LangOpts that the formatter expects you to set.
Definition: Format.cpp:3935
FormatStyle getMozillaStyle()
Returns a format style complying with Mozilla's style guide: https://firefox-source-docs....
Definition: Format.cpp:1896
bool getPredefinedStyle(StringRef Name, FormatStyle::LanguageKind Language, FormatStyle *Style)
Gets a predefined style for the specified language by name.
Definition: Format.cpp:2012
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:3679
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:3882
bool isClangFormatOn(StringRef Comment)
Definition: Format.cpp:4236
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:3925
FormatStyle getChromiumStyle(FormatStyle::LanguageKind Language)
Returns a format style complying with Chromium's style guide: http://www.chromium....
Definition: Format.cpp:1836
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:3893
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:3569
FormatStyle getNoStyle()
Returns style indicating formatting should be not applied at all.
Definition: Format.cpp:2004
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:3528
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:5666
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:5397
std::optional< FormatStyle > Get(FormatStyle::LanguageKind Language) const
Definition: Format.cpp:2155
Separator format of integer literals of different bases.
Definition: Format.h:3046
int8_t BinaryMinDigits
Format separators in binary literals with a minimum number of digits.
Definition: Format.h:3062
bool operator==(const IntegerLiteralSeparatorStyle &R) const
Definition: Format.h:3094
int8_t Binary
Format separators in binary literals.
Definition: Format.h:3054
int8_t DecimalMinDigits
Format separators in decimal literals with a minimum number of digits.
Definition: Format.h:3077
int8_t Decimal
Format separators in decimal literals.
Definition: Format.h:3069
int8_t HexMinDigits
Format separators in hexadecimal literals with a minimum number of digits.
Definition: Format.h:3093
int8_t Hex
Format separators in hexadecimal literals.
Definition: Format.h:3084
Options regarding which empty lines are kept.
Definition: Format.h:3195
bool AtStartOfFile
Keep empty lines at start of file.
Definition: Format.h:3208
bool AtEndOfFile
Keep empty lines at end of file.
Definition: Format.h:3197
bool operator==(const KeepEmptyLinesStyle &R) const
Definition: Format.h:3209
bool AtStartOfBlock
Keep empty lines at start of a block.
Definition: Format.h:3206
See documentation of RawStringFormats.
Definition: Format.h:3794
std::string CanonicalDelimiter
The canonical delimiter for this language.
Definition: Format.h:3802
LanguageKind Language
The language of this raw string.
Definition: Format.h:3796
std::string BasedOnStyle
The style name on which this raw string format is based on.
Definition: Format.h:3806
std::vector< std::string > EnclosingFunctions
A list of enclosing function names that match this language.
Definition: Format.h:3800
bool operator==(const RawStringFormat &Other) const
Definition: Format.h:3807
std::vector< std::string > Delimiters
A list of raw string delimiters that match this language.
Definition: Format.h:3798
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:4550
bool AfterControlStatements
If true, put space between control statement keywords (for/if/while...) and opening parentheses.
Definition: Format.h:4557
bool AfterOverloadedOperator
If true, put a space between operator overloading and opening parentheses.
Definition: Format.h:4593
bool AfterRequiresInExpression
If true, put space between requires keyword in a requires expression and opening parentheses.
Definition: Format.h:4620
bool AfterFunctionDeclarationName
If true, put a space between function declaration name and opening parentheses.
Definition: Format.h:4571
bool AfterRequiresInClause
If true, put space between requires keyword in a requires clause and opening parentheses,...
Definition: Format.h:4610
bool AfterForeachMacros
If true, put space between foreach macros and opening parentheses.
Definition: Format.h:4564
bool AfterFunctionDefinitionName
If true, put a space between function definition name and opening parentheses.
Definition: Format.h:4578
bool BeforeNonEmptyParentheses
If true, put a space before opening parentheses only if the parentheses are not empty.
Definition: Format.h:4628
bool operator==(const SpaceBeforeParensCustom &Other) const
Definition: Format.h:4638
bool AfterIfMacros
If true, put space between if macros and opening parentheses.
Definition: Format.h:4585
bool AfterPlacementOperator
If true, put a space between operator new/delete and opening parenthesis.
Definition: Format.h:4601
If true, spaces may be inserted into C style casts.
Definition: Format.h:4770
unsigned Maximum
The maximum number of spaces at the start of the comment.
Definition: Format.h:4774
unsigned Minimum
The minimum number of spaces at the start of the comment.
Definition: Format.h:4772
Precise control over the spacing in parentheses.
Definition: Format.h:4849
bool operator==(const SpacesInParensCustom &R) const
Definition: Format.h:4906
bool ExceptDoubleParentheses
Override any of the following options to prevent addition of space when both opening and closing pare...
Definition: Format.h:4860
bool Other
Put a space in parentheses not covered by preceding options.
Definition: Format.h:4892
bool InEmptyParentheses
Insert a space in empty parentheses, i.e.
Definition: Format.h:4886
bool InCStyleCasts
Put a space in C style casts.
Definition: Format.h:4875
bool operator!=(const SpacesInParensCustom &R) const
Definition: Format.h:4912
bool InConditionalStatements
Put a space in parentheses only inside conditional statements (for/if/while/switch....
Definition: Format.h:4868
SpacesInParensCustom(bool ExceptDoubleParentheses, bool InConditionalStatements, bool InCStyleCasts, bool InEmptyParentheses, bool Other)
Definition: Format.h:4898
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:5105
@ UT_AlignWithSpaces
Use tabs for line continuation and indentation, and spaces for alignment.
Definition: Format.h:5115
@ UT_ForContinuationAndIndentation
Fill all leading whitespace with tabs, and use spaces for alignment that appears within a line (e....
Definition: Format.h:5112
@ UT_ForIndentation
Use tabs only for indentation.
Definition: Format.h:5109
@ 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:5118
@ UT_Never
Never use tab.
Definition: Format.h:5107
bool SpaceBeforeInheritanceColon
If false, spaces will be removed before inheritance colon.
Definition: Format.h:4468
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:4977
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:3311
LanguageKind
Supported languages.
Definition: Format.h:3275
@ LK_CSharp
Should be used for C#.
Definition: Format.h:3281
@ LK_None
Do not use.
Definition: Format.h:3277
@ LK_Java
Should be used for Java.
Definition: Format.h:3283
@ LK_Cpp
Should be used for C, C++.
Definition: Format.h:3279
@ LK_JavaScript
Should be used for JavaScript.
Definition: Format.h:3285
@ LK_ObjC
Should be used for Objective-C, Objective-C++.
Definition: Format.h:3289
@ LK_Verilog
Should be used for Verilog and SystemVerilog.
Definition: Format.h:3301
@ LK_TableGen
Should be used for TableGen code.
Definition: Format.h:3294
@ LK_Proto
Should be used for Protocol Buffers (https://developers.google.com/protocol-buffers/).
Definition: Format.h:3292
@ LK_Json
Should be used for JSON.
Definition: Format.h:3287
@ LK_TextProto
Should be used for Protocol Buffer messages in text format (https://developers.google....
Definition: Format.h:3297
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:4295
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:2945
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:4179
@ SDS_Never
Remove any empty line between definition blocks.
Definition: Format.h:4185
@ SDS_Always
Insert an empty line between definition blocks.
Definition: Format.h:4183
@ SDS_Leave
Leave definition blocks as they are.
Definition: Format.h:4181
bool IndentRequiresClause
Indent the requires clause in a template.
Definition: Format.h:2931
SpacesInAnglesStyle SpacesInAngles
The SpacesInAnglesStyle to use for template argument lists.
Definition: Format.h:4743
bool KeepFormFeed
This option is deprecated.
Definition: Format.h:3234
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:3851
std::vector< std::string > VariableTemplates
A vector of non-keyword identifiers that should be interpreted as variable template names.
Definition: Format.h:5132
SortJavaStaticImportOptions
Position for Java Static imports.
Definition: Format.h:4298
@ SJSIO_Before
Static imports are placed before non-static imports.
Definition: Format.h:4305
@ SJSIO_After
Static imports are placed after non-static imports.
Definition: Format.h:4312
PPDirectiveIndentStyle IndentPPDirectives
The preprocessor directive indenting style to use.
Definition: Format.h:2908
bool RemoveSemicolon
Remove semicolons after the closing braces of functions and constructors/destructors.
Definition: Format.h:4046
std::vector< std::string > Macros
A list of macros of the form <definition>=<expansion> .
Definition: Format.h:3404
bool SpaceBeforeJsonColon
If true, a space will be added before a JSON colon.
Definition: Format.h:4479
TrailingCommaStyle
The style of inserting trailing commas into container literals.
Definition: Format.h:2998
@ TCS_Wrapped
Insert trailing commas in container literals that were wrapped over multiple lines.
Definition: Format.h:3006
@ TCS_None
Do not insert trailing commas.
Definition: Format.h:3000
unsigned PenaltyBreakBeforeFirstCallParameter
The penalty for breaking a function call after call(.
Definition: Format.h:3640
bool SpaceBeforeCtorInitializerColon
If false, spaces will be removed before constructor initializer colon.
Definition: Format.h:4460
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:4263
@ SI_Never
Includes are never sorted.
Definition: Format.h:4272
@ SI_CaseSensitive
Includes are sorted in an ASCIIbetical or case sensitive fashion.
Definition: Format.h:4281
@ SI_CaseInsensitive
Includes are sorted in an alphabetical or case insensitive fashion.
Definition: Format.h:4290
bool IndentExportBlock
If true, clang-format will indent the body of an export { ... } block.
Definition: Format.h:2816
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:3881
@ RCS_IndentOnly
Only apply indentation rules, moving comments left or right, without changing formatting inside the c...
Definition: Format.h:3898
@ RCS_Never
Leave comments untouched.
Definition: Format.h:3889
@ RCS_Always
Apply indentation rules and reflow long comments into new lines, trying to obey the ColumnLimit.
Definition: Format.h:3909
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:4720
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:2819
@ IEBS_AfterExternBlock
Backwards compatible with AfterExternBlock's indenting.
Definition: Format.h:2837
@ IEBS_Indent
Indents extern blocks.
Definition: Format.h:2851
@ IEBS_NoIndent
Does not indent extern blocks.
Definition: Format.h:2844
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:2991
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:3318
@ LE_DeriveLF
Use \n unless the input has more lines ending in \r\n.
Definition: Format.h:3324
@ LE_DeriveCRLF
Use \r\n unless the input has more lines ending in \n.
Definition: Format.h:3326
bool SpacesInSquareBrackets
If true, spaces will be inserted after [ and before ].
Definition: Format.h:4942
bool IndentWrappedFunctionNames
Indent if a function definition or declaration is wrapped after the type.
Definition: Format.h:2959
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:5196
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:3570
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:4028
std::string MacroBlockBegin
A regular expression matching macros that start a block.
Definition: Format.h:3360
bool SpaceInEmptyBlock
If true, spaces will be inserted into {}.
Definition: Format.h:4694
LanguageKind Language
Language, this format style is targeted at.
Definition: Format.h:3315
SpacesInParensStyle
Different ways to put a space before opening and closing parentheses.
Definition: Format.h:4812
@ SIPO_Custom
Configure each individual space in parentheses in SpacesInParensOptions.
Definition: Format.h:4824
@ SIPO_Never
Never put a space in parentheses.
Definition: Format.h:4821
bool RemoveBracesLLVM
Remove optional braces of control statements (if, else, for, and while) in C++ according to the LLVM ...
Definition: Format.h:3969
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:5146
unsigned TabWidth
The number of columns used for tab stops.
Definition: Format.h:5062
PPDirectiveIndentStyle
Options for indenting preprocessor directives.
Definition: Format.h:2876
@ PPDIS_BeforeHash
Indents directives before the hash.
Definition: Format.h:2903
@ PPDIS_None
Does not indent any directives.
Definition: Format.h:2885
@ PPDIS_AfterHash
Indents directives after the hash.
Definition: Format.h:2894
LambdaBodyIndentationKind
Indentation logic for lambda bodies.
Definition: Format.h:3237
@ LBI_OuterScope
For statements within block scope, align lambda body relative to the indentation level of the outer s...
Definition: Format.h:3259
@ LBI_Signature
Align lambda body relative to the lambda signature.
Definition: Format.h:3245
std::vector< std::string > JavaImportGroups
A vector of prefixes ordered by the desired groups for Java imports.
Definition: Format.h:3138
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:3652
std::vector< std::string > StatementAttributeLikeMacros
Macros which are ignored in front of a statement, as if they were an attribute.
Definition: Format.h:4994
unsigned ObjCBlockIndentWidth
The number of characters to use for indentation of ObjC blocks.
Definition: Format.h:3513
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:3791
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:2180
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:3456
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:3560
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:3537
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:3656
unsigned PenaltyBreakBeforeMemberAccess
The penalty for breaking before a member access operator (.
Definition: Format.h:3644
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:2073
SpacesInParensStyle SpacesInParens
If true, spaces will be inserted after ( and before ).
Definition: Format.h:4838
SpacesInParensCustom SpacesInParensOptions
Control of individual spaces in parentheses.
Definition: Format.h:4931
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:3877
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:3025
unsigned PenaltyBreakTemplateDeclaration
The penalty for breaking after template declaration.
Definition: Format.h:3668
SpaceBeforeParensCustom SpaceBeforeParensOptions
Control of individual space before parentheses.
Definition: Format.h:4666
BreakConstructorInitializersStyle BreakConstructorInitializers
The break constructor initializers style to use.
Definition: Format.h:2333
bool RemoveEmptyLinesInUnwrappedLines
Remove empty lines within unwrapped lines.
Definition: Format.h:3992
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:4379
SpaceBeforeParensStyle
Different ways to put a space before opening parentheses.
Definition: Format.h:4482
@ SBPO_Never
This is deprecated and replaced by Custom below, with all SpaceBeforeParensOptions but AfterPlacement...
Definition: Format.h:4486
@ SBPO_Custom
Configure each individual space before parentheses in SpaceBeforeParensOptions.
Definition: Format.h:4535
@ SBPO_NonEmptyParentheses
Put a space before opening parentheses only if the parentheses are not empty.
Definition: Format.h:4520
@ SBPO_ControlStatementsExceptControlMacros
Same as SBPO_ControlStatements except this option doesn't apply to ForEach and If macros.
Definition: Format.h:4509
@ SBPO_ControlStatements
Put a space before opening parentheses only after control statement keywords (for/if/while....
Definition: Format.h:4496
@ SBPO_Always
Always put a space before opening parentheses, except when it's prohibited by the syntax rules (in fu...
Definition: Format.h:4532
PackConstructorInitializersStyle
Different ways to try to fit all constructor initializers on a line.
Definition: Format.h:3573
@ PCIS_NextLineOnly
Put all constructor initializers on the next line if they fit.
Definition: Format.h:3627
@ PCIS_Never
Always put each constructor initializer on its own line.
Definition: Format.h:3580
@ PCIS_CurrentLine
Put all constructor initializers on the current line if they fit.
Definition: Format.h:3598
@ PCIS_BinPack
Bin-pack constructor initializers.
Definition: Format.h:3587
@ PCIS_NextLine
Same as PCIS_CurrentLine except that if all constructor initializers do not fit on the current line,...
Definition: Format.h:3612
std::vector< std::string > TypeNames
A vector of non-keyword identifiers that should be interpreted as type names.
Definition: Format.h:5081
bool ObjCSpaceAfterProperty
Add a space after @property in Objective-C, i.e.
Definition: Format.h:3565
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:3304
unsigned PenaltyExcessCharacter
The penalty for each character outside of the column limit.
Definition: Format.h:3672
std::vector< std::string > WhitespaceSensitiveMacros
A vector of macros which are whitespace-sensitive and should not be touched.
Definition: Format.h:5163
std::vector< std::string > TemplateNames
A vector of non-keyword identifiers that should be interpreted as template names.
Definition: Format.h:5071
DAGArgStyle
Different ways to control the format inside TableGen DAGArg.
Definition: Format.h:5033
@ DAS_BreakElements
Break inside DAGArg after each list element but for the last.
Definition: Format.h:5045
@ DAS_DontBreak
Never break inside DAGArg.
Definition: Format.h:5038
@ DAS_BreakAll
Break inside DAGArg after the operator and the all elements.
Definition: Format.h:5053
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:4051
@ RCPS_OwnLineWithBrace
As with OwnLine, except, unless otherwise prohibited, place a following open brace (of a function def...
Definition: Format.h:4090
@ RCPS_OwnLine
Always put the requires clause on its own line (possibly followed by a semicolon).
Definition: Format.h:4072
@ RCPS_WithPreceding
Try to put the clause together with the preceding part of a declaration.
Definition: Format.h:4107
@ RCPS_SingleLine
Try to put everything in the same line if possible.
Definition: Format.h:4145
@ RCPS_WithFollowing
Try to put the requires clause together with the class or function declaration.
Definition: Format.h:4121
bool operator==(const FormatStyle &R) const
Definition: Format.h:5198
LanguageStandard
Supported language standards for parsing and formatting C++ constructs.
Definition: Format.h:4952
@ LS_Cpp17
Parse and format as C++17.
Definition: Format.h:4961
@ LS_Latest
Parse and format using the latest supported language version.
Definition: Format.h:4966
@ LS_Cpp11
Parse and format as C++11.
Definition: Format.h:4957
@ LS_Auto
Automatic detection based on the input.
Definition: Format.h:4968
@ LS_Cpp03
Parse and format as C++03.
Definition: Format.h:4955
@ LS_Cpp14
Parse and format as C++14.
Definition: Format.h:4959
@ LS_Cpp20
Parse and format as C++20.
Definition: Format.h:4963
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:4150
JavaScriptQuoteStyle
Quotation styles for JavaScript strings.
Definition: Format.h:3142
@ JSQS_Double
Always use double quotes.
Definition: Format.h:3160
@ JSQS_Single
Always use single quotes.
Definition: Format.h:3154
@ JSQS_Leave
Leave string quotes as they are.
Definition: Format.h:3148
bool SpaceAfterCStyleCast
If true, a space is inserted after C style casts.
Definition: Format.h:4371
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:3719
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:3104
SpaceAroundPointerQualifiersStyle SpaceAroundPointerQualifiers
Defines in which cases to put a space before or after pointer qualifiers.
Definition: Format.h:4420
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:4429
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:5166
@ 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:5188
@ WNBWELS_Leave
Keep existing newlines at the beginning and the end of namespace body.
Definition: Format.h:5191
@ WNBWELS_Never
Remove all empty lines at the beginning and the end of namespace body.
Definition: Format.h:5175
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:3660
unsigned PenaltyReturnTypeOnItsOwnLine
Penalty for putting the return type of a function onto its own line.
Definition: Format.h:3681
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:3704
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:4153
@ REI_Keyword
Align requires expression body relative to the requires keyword.
Definition: Format.h:4171
@ REI_OuterScope
Align requires expression body relative to the indentation level of the outer scope the requires expr...
Definition: Format.h:4163
PackConstructorInitializersStyle PackConstructorInitializers
The pack constructor initializers style to use.
Definition: Format.h:3632
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:3915
KeepEmptyLinesStyle KeepEmptyLines
Which empty lines are kept.
Definition: Format.h:3218
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:3308
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:3418
bool SpaceBeforeSquareBrackets
If true, spaces will be before [.
Definition: Format.h:4676
BinPackStyle ObjCBinPackProtocolList
Controls bin-packing Objective-C protocol conformance list items into as few lines as possible when t...
Definition: Format.h:3502
bool isVerilog() const
Definition: Format.h:3307
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:4809
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:3306
DAGArgStyle TableGenBreakInsideDAGArg
The styles of the line break inside the DAGArg in TableGen.
Definition: Format.h:5058
JavaScriptQuoteStyle JavaScriptQuotes
The JavaScriptQuoteStyle to use for JavaScript strings.
Definition: Format.h:3165
bool SpacesInContainerLiterals
If true, spaces will be inserted around if/for/switch/while conditions.
Definition: Format.h:4761
SortJavaStaticImportOptions SortJavaStaticImport
When sorting Java imports, by default static imports are placed before non-static imports.
Definition: Format.h:4319
SpaceAroundPointerQualifiersStyle
Different ways to put a space before opening parentheses.
Definition: Format.h:4390
@ SAPQ_After
Ensure that there is a space after pointer qualifiers.
Definition: Format.h:4409
@ SAPQ_Default
Don't ensure spaces around pointer qualifiers and use PointerAlignment instead.
Definition: Format.h:4397
@ SAPQ_Both
Ensure that there is a space both before and after pointer qualifiers.
Definition: Format.h:4415
@ SAPQ_Before
Ensure that there is a space before pointer qualifiers.
Definition: Format.h:4403
bool SpaceBeforeRangeBasedForLoopColon
If false, spaces will be removed before range-based for loop colon.
Definition: Format.h:4685
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:3469
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:3268
QualifierAlignmentStyle QualifierAlignment
Different ways to arrange specifiers and qualifiers (e.g.
Definition: Format.h:3765
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:2873
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:5004
SpacesInAnglesStyle
Styles for adding spacing after < and before > in template argument lists.
Definition: Format.h:4724
@ SIAS_Never
Remove spaces after < and before >.
Definition: Format.h:4730
@ SIAS_Always
Add spaces after < and before >.
Definition: Format.h:4736
@ SIAS_Leave
Keep a single space after < and before > if any spaces were present.
Definition: Format.h:4739
SortUsingDeclarationsOptions
Using declaration sorting options.
Definition: Format.h:4322
@ SUD_LexicographicNumeric
Using declarations are sorted in the order defined as follows: Split the strings by :: and discard an...
Definition: Format.h:4358
@ SUD_Lexicographic
Using declarations are sorted in the order defined as follows: Split the strings by :: and discard an...
Definition: Format.h:4343
@ SUD_Never
Using declarations are never sorted.
Definition: Format.h:4331
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:3995
@ RPS_Leave
Do not remove parentheses.
Definition: Format.h:4002
@ RPS_ReturnStatement
Also remove parentheses enclosing the expression in a return/co_return statement.
Definition: Format.h:4017
@ RPS_MultipleParentheses
Replace multiple parentheses with single parentheses.
Definition: Format.h:4009
std::vector< std::string > TableGenBreakingDAGArgOperators
Works only when TableGenBreakInsideDAGArg is not DontBreak.
Definition: Format.h:5030
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:4439
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:3181
bool SkipMacroDefinitionBody
Do not format macro definition body.
Definition: Format.h:4260
unsigned PenaltyBreakAssignment
The penalty for breaking around an assignment operator.
Definition: Format.h:3636
PointerAlignmentStyle
The &, && and * alignment style.
Definition: Format.h:3684
@ PAS_Left
Align pointer to the left.
Definition: Format.h:3689
@ PAS_Middle
Align pointer in the middle.
Definition: Format.h:3699
@ PAS_Right
Align pointer to the right.
Definition: Format.h:3694
unsigned PenaltyBreakString
The penalty for each line break introduced inside a string literal.
Definition: Format.h:3664
RequiresExpressionIndentationKind RequiresExpressionIndentation
The indentation used for requires expression bodies.
Definition: Format.h:4176
bool SpaceAfterTemplateKeyword
If true, a space will be inserted after the template keyword.
Definition: Format.h:4387
unsigned PenaltyIndentedWhitespace
Penalty for each character of whitespace indentation (counted relative to leading non-whitespace colu...
Definition: Format.h:3677
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:3421
@ NI_None
Don't indent in namespaces.
Definition: Format.h:3431
@ NI_All
Indent in all namespaces.
Definition: Format.h:3451
@ NI_Inner
Indent only in inner namespaces (nested in other namespaces).
Definition: Format.h:3441
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:3364
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:3648
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:3854
@ RAS_Right
Align reference to the right.
Definition: Format.h:3866
@ RAS_Left
Align reference to the left.
Definition: Format.h:3861
@ RAS_Pointer
Align reference like PointerAlignment.
Definition: Format.h:3856
@ RAS_Middle
Align reference in the middle.
Definition: Format.h:3871
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:2995
SpaceBeforeParensStyle SpaceBeforeParens
Defines in which cases to put a space before opening parentheses.
Definition: Format.h:4540
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:4451
UseTabStyle UseTab
The way to use tab characters in the resulting file.
Definition: Format.h:5123
QualifierAlignmentStyle
Different specifiers and qualifiers alignment styles.
Definition: Format.h:3722
@ QAS_Right
Change specifiers/qualifiers to be right-aligned.
Definition: Format.h:3741
@ QAS_Custom
Change specifiers/qualifiers to be aligned based on QualifierOrder.
Definition: Format.h:3753
@ QAS_Left
Change specifiers/qualifiers to be left-aligned.
Definition: Format.h:3735
@ QAS_Leave
Don't change specifiers/qualifiers to either Left or Right alignment (default).
Definition: Format.h:3729
std::vector< std::string > TypenameMacros
A vector of macros that should be interpreted as type declarations instead of as function calls.
Definition: Format.h:5098
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:3331
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:4256
SortUsingDeclarationsOptions SortUsingDeclarations
Controls if and how clang-format will sort using declarations.
Definition: Format.h:4363
IndentExternBlockStyle IndentExternBlock
IndentExternBlockStyle is the type of indenting of extern blocks.
Definition: Format.h:2856
SeparateDefinitionStyle SeparateDefinitionBlocks
Specifies the use of empty lines to separate definition blocks, including classes,...
Definition: Format.h:4234
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:5536
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:5539
unsigned Line
If FormatComplete is false, Line records a one-based original line number at which a syntax error mig...
Definition: Format.h:5544
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