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