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 ``KeepEmptyLines``.
3211 /// \version 3.7
3212 // bool KeepEmptyLinesAtTheStartOfBlocks;
3213
3214 /// Keep the form feed character if it's immediately preceded and followed by
3215 /// a newline. Multiple form feeds and newlines within a whitespace range are
3216 /// replaced with a single newline and form feed followed by the remaining
3217 /// newlines.
3218 /// \version 20
3220
3221 /// Indentation logic for lambda bodies.
3223 /// Align lambda body relative to the lambda signature. This is the default.
3224 /// \code
3225 /// someMethod(
3226 /// [](SomeReallyLongLambdaSignatureArgument foo) {
3227 /// return;
3228 /// });
3229 /// \endcode
3231 /// For statements within block scope, align lambda body relative to the
3232 /// indentation level of the outer scope the lambda signature resides in.
3233 /// \code
3234 /// someMethod(
3235 /// [](SomeReallyLongLambdaSignatureArgument foo) {
3236 /// return;
3237 /// });
3238 ///
3239 /// someMethod(someOtherMethod(
3240 /// [](SomeReallyLongLambdaSignatureArgument foo) {
3241 /// return;
3242 /// }));
3243 /// \endcode
3245 };
3246
3247 /// The indentation style of lambda bodies. ``Signature`` (the default)
3248 /// causes the lambda body to be indented one additional level relative to
3249 /// the indentation level of the signature. ``OuterScope`` forces the lambda
3250 /// body to be indented one additional level relative to the parent scope
3251 /// containing the lambda signature.
3252 /// \version 13
3254
3255 /// Supported languages.
3256 ///
3257 /// When stored in a configuration file, specifies the language, that the
3258 /// configuration targets. When passed to the ``reformat()`` function, enables
3259 /// syntax features specific to the language.
3260 enum LanguageKind : int8_t {
3261 /// Do not use.
3263 /// Should be used for C, C++.
3265 /// Should be used for C#.
3267 /// Should be used for Java.
3269 /// Should be used for JavaScript.
3271 /// Should be used for JSON.
3273 /// Should be used for Objective-C, Objective-C++.
3275 /// Should be used for Protocol Buffers
3276 /// (https://developers.google.com/protocol-buffers/).
3278 /// Should be used for TableGen code.
3280 /// Should be used for Protocol Buffer messages in text format
3281 /// (https://developers.google.com/protocol-buffers/).
3283 /// Should be used for Verilog and SystemVerilog.
3284 /// https://standards.ieee.org/ieee/1800/6700/
3285 /// https://sci-hub.st/10.1109/IEEESTD.2018.8299595
3288 bool isCpp() const { return Language == LK_Cpp || Language == LK_ObjC; }
3289 bool isCSharp() const { return Language == LK_CSharp; }
3290 bool isJson() const { return Language == LK_Json; }
3291 bool isJavaScript() const { return Language == LK_JavaScript; }
3292 bool isVerilog() const { return Language == LK_Verilog; }
3293 bool isProto() const {
3294 return Language == LK_Proto || Language == LK_TextProto;
3295 }
3296 bool isTableGen() const { return Language == LK_TableGen; }
3297
3298 /// Language, this format style is targeted at.
3299 /// \version 3.5
3301
3302 /// Line ending style.
3303 enum LineEndingStyle : int8_t {
3304 /// Use ``\n``.
3306 /// Use ``\r\n``.
3308 /// Use ``\n`` unless the input has more lines ending in ``\r\n``.
3310 /// Use ``\r\n`` unless the input has more lines ending in ``\n``.
3312 };
3313
3314 /// Line ending style (``\n`` or ``\r\n``) to use.
3315 /// \version 16
3317
3318 /// A regular expression matching macros that start a block.
3319 /// \code
3320 /// # With:
3321 /// MacroBlockBegin: "^NS_MAP_BEGIN|\
3322 /// NS_TABLE_HEAD$"
3323 /// MacroBlockEnd: "^\
3324 /// NS_MAP_END|\
3325 /// NS_TABLE_.*_END$"
3326 ///
3327 /// NS_MAP_BEGIN
3328 /// foo();
3329 /// NS_MAP_END
3330 ///
3331 /// NS_TABLE_HEAD
3332 /// bar();
3333 /// NS_TABLE_FOO_END
3334 ///
3335 /// # Without:
3336 /// NS_MAP_BEGIN
3337 /// foo();
3338 /// NS_MAP_END
3339 ///
3340 /// NS_TABLE_HEAD
3341 /// bar();
3342 /// NS_TABLE_FOO_END
3343 /// \endcode
3344 /// \version 3.7
3345 std::string MacroBlockBegin;
3346
3347 /// A regular expression matching macros that end a block.
3348 /// \version 3.7
3349 std::string MacroBlockEnd;
3350
3351 /// A list of macros of the form \c <definition>=<expansion> .
3352 ///
3353 /// Code will be parsed with macros expanded, in order to determine how to
3354 /// interpret and format the macro arguments.
3355 ///
3356 /// For example, the code:
3357 /// \code
3358 /// A(a*b);
3359 /// \endcode
3360 ///
3361 /// will usually be interpreted as a call to a function A, and the
3362 /// multiplication expression will be formatted as ``a * b``.
3363 ///
3364 /// If we specify the macro definition:
3365 /// \code{.yaml}
3366 /// Macros:
3367 /// - A(x)=x
3368 /// \endcode
3369 ///
3370 /// the code will now be parsed as a declaration of the variable b of type a*,
3371 /// and formatted as ``a* b`` (depending on pointer-binding rules).
3372 ///
3373 /// Features and restrictions:
3374 /// * Both function-like macros and object-like macros are supported.
3375 /// * Macro arguments must be used exactly once in the expansion.
3376 /// * No recursive expansion; macros referencing other macros will be
3377 /// ignored.
3378 /// * Overloading by arity is supported: for example, given the macro
3379 /// definitions A=x, A()=y, A(a)=a
3380 ///
3381 /// \code
3382 /// A; -> x;
3383 /// A(); -> y;
3384 /// A(z); -> z;
3385 /// A(a, b); // will not be expanded.
3386 /// \endcode
3387 ///
3388 /// \version 17
3389 std::vector<std::string> Macros;
3390
3391 /// The maximum number of consecutive empty lines to keep.
3392 /// \code
3393 /// MaxEmptyLinesToKeep: 1 vs. MaxEmptyLinesToKeep: 0
3394 /// int f() { int f() {
3395 /// int = 1; int i = 1;
3396 /// i = foo();
3397 /// i = foo(); return i;
3398 /// }
3399 /// return i;
3400 /// }
3401 /// \endcode
3402 /// \version 3.7
3404
3405 /// Different ways to indent namespace contents.
3407 /// Don't indent in namespaces.
3408 /// \code
3409 /// namespace out {
3410 /// int i;
3411 /// namespace in {
3412 /// int i;
3413 /// }
3414 /// }
3415 /// \endcode
3417 /// Indent only in inner namespaces (nested in other namespaces).
3418 /// \code
3419 /// namespace out {
3420 /// int i;
3421 /// namespace in {
3422 /// int i;
3423 /// }
3424 /// }
3425 /// \endcode
3427 /// Indent in all namespaces.
3428 /// \code
3429 /// namespace out {
3430 /// int i;
3431 /// namespace in {
3432 /// int i;
3433 /// }
3434 /// }
3435 /// \endcode
3436 NI_All
3438
3439 /// The indentation used for namespaces.
3440 /// \version 3.7
3442
3443 /// A vector of macros which are used to open namespace blocks.
3444 ///
3445 /// These are expected to be macros of the form:
3446 /// \code
3447 /// NAMESPACE(<namespace-name>, ...) {
3448 /// <namespace-content>
3449 /// }
3450 /// \endcode
3451 ///
3452 /// For example: TESTSUITE
3453 /// \version 9
3454 std::vector<std::string> NamespaceMacros;
3455
3456 /// Controls bin-packing Objective-C protocol conformance list
3457 /// items into as few lines as possible when they go over ``ColumnLimit``.
3458 ///
3459 /// If ``Auto`` (the default), delegates to the value in
3460 /// ``BinPackParameters``. If that is ``BinPack``, bin-packs Objective-C
3461 /// protocol conformance list items into as few lines as possible
3462 /// whenever they go over ``ColumnLimit``.
3463 ///
3464 /// If ``Always``, always bin-packs Objective-C protocol conformance
3465 /// list items into as few lines as possible whenever they go over
3466 /// ``ColumnLimit``.
3467 ///
3468 /// If ``Never``, lays out Objective-C protocol conformance list items
3469 /// onto individual lines whenever they go over ``ColumnLimit``.
3470 ///
3471 /// \code{.objc}
3472 /// Always (or Auto, if BinPackParameters==BinPack):
3473 /// @interface ccccccccccccc () <
3474 /// ccccccccccccc, ccccccccccccc,
3475 /// ccccccccccccc, ccccccccccccc> {
3476 /// }
3477 ///
3478 /// Never (or Auto, if BinPackParameters!=BinPack):
3479 /// @interface ddddddddddddd () <
3480 /// ddddddddddddd,
3481 /// ddddddddddddd,
3482 /// ddddddddddddd,
3483 /// ddddddddddddd> {
3484 /// }
3485 /// \endcode
3486 /// \version 7
3488
3489 /// The number of characters to use for indentation of ObjC blocks.
3490 /// \code{.objc}
3491 /// ObjCBlockIndentWidth: 4
3492 ///
3493 /// [operation setCompletionBlock:^{
3494 /// [self onOperationDone];
3495 /// }];
3496 /// \endcode
3497 /// \version 3.7
3499
3500 /// Break parameters list into lines when there is nested block
3501 /// parameters in a function call.
3502 /// \code
3503 /// false:
3504 /// - (void)_aMethod
3505 /// {
3506 /// [self.test1 t:self w:self callback:^(typeof(self) self, NSNumber
3507 /// *u, NSNumber *v) {
3508 /// u = c;
3509 /// }]
3510 /// }
3511 /// true:
3512 /// - (void)_aMethod
3513 /// {
3514 /// [self.test1 t:self
3515 /// w:self
3516 /// callback:^(typeof(self) self, NSNumber *u, NSNumber *v) {
3517 /// u = c;
3518 /// }]
3519 /// }
3520 /// \endcode
3521 /// \version 11
3523
3524 /// The order in which ObjC property attributes should appear.
3525 ///
3526 /// Attributes in code will be sorted in the order specified. Any attributes
3527 /// encountered that are not mentioned in this array will be sorted last, in
3528 /// stable order. Comments between attributes will leave the attributes
3529 /// untouched.
3530 /// \warning
3531 /// Using this option could lead to incorrect code formatting due to
3532 /// clang-format's lack of complete semantic information. As such, extra
3533 /// care should be taken to review code changes made by this option.
3534 /// \endwarning
3535 /// \code{.yaml}
3536 /// ObjCPropertyAttributeOrder: [
3537 /// class, direct,
3538 /// atomic, nonatomic,
3539 /// assign, retain, strong, copy, weak, unsafe_unretained,
3540 /// readonly, readwrite, getter, setter,
3541 /// nullable, nonnull, null_resettable, null_unspecified
3542 /// ]
3543 /// \endcode
3544 /// \version 18
3545 std::vector<std::string> ObjCPropertyAttributeOrder;
3546
3547 /// Add a space after ``@property`` in Objective-C, i.e. use
3548 /// ``@property (readonly)`` instead of ``@property(readonly)``.
3549 /// \version 3.7
3551
3552 /// Add a space in front of an Objective-C protocol list, i.e. use
3553 /// ``Foo <Protocol>`` instead of ``Foo<Protocol>``.
3554 /// \version 3.7
3556
3557 /// Different ways to try to fit all constructor initializers on a line.
3559 /// Always put each constructor initializer on its own line.
3560 /// \code
3561 /// Constructor()
3562 /// : a(),
3563 /// b()
3564 /// \endcode
3566 /// Bin-pack constructor initializers.
3567 /// \code
3568 /// Constructor()
3569 /// : aaaaaaaaaaaaaaaaaaaa(), bbbbbbbbbbbbbbbbbbbb(),
3570 /// cccccccccccccccccccc()
3571 /// \endcode
3573 /// Put all constructor initializers on the current line if they fit.
3574 /// Otherwise, put each one on its own line.
3575 /// \code
3576 /// Constructor() : a(), b()
3577 ///
3578 /// Constructor()
3579 /// : aaaaaaaaaaaaaaaaaaaa(),
3580 /// bbbbbbbbbbbbbbbbbbbb(),
3581 /// ddddddddddddd()
3582 /// \endcode
3584 /// Same as ``PCIS_CurrentLine`` except that if all constructor initializers
3585 /// do not fit on the current line, try to fit them on the next line.
3586 /// \code
3587 /// Constructor() : a(), b()
3588 ///
3589 /// Constructor()
3590 /// : aaaaaaaaaaaaaaaaaaaa(), bbbbbbbbbbbbbbbbbbbb(), ddddddddddddd()
3591 ///
3592 /// Constructor()
3593 /// : aaaaaaaaaaaaaaaaaaaa(),
3594 /// bbbbbbbbbbbbbbbbbbbb(),
3595 /// cccccccccccccccccccc()
3596 /// \endcode
3598 /// Put all constructor initializers on the next line if they fit.
3599 /// Otherwise, put each one on its own line.
3600 /// \code
3601 /// Constructor()
3602 /// : a(), b()
3603 ///
3604 /// Constructor()
3605 /// : aaaaaaaaaaaaaaaaaaaa(), bbbbbbbbbbbbbbbbbbbb(), ddddddddddddd()
3606 ///
3607 /// Constructor()
3608 /// : aaaaaaaaaaaaaaaaaaaa(),
3609 /// bbbbbbbbbbbbbbbbbbbb(),
3610 /// cccccccccccccccccccc()
3611 /// \endcode
3613 };
3614
3615 /// The pack constructor initializers style to use.
3616 /// \version 14
3618
3619 /// The penalty for breaking around an assignment operator.
3620 /// \version 5
3622
3623 /// The penalty for breaking a function call after ``call(``.
3624 /// \version 3.7
3626
3627 /// The penalty for each line break introduced inside a comment.
3628 /// \version 3.7
3630
3631 /// The penalty for breaking before the first ``<<``.
3632 /// \version 3.7
3634
3635 /// The penalty for breaking after ``(``.
3636 /// \version 14
3638
3639 /// The penalty for breaking after ``::``.
3640 /// \version 18
3642
3643 /// The penalty for each line break introduced inside a string literal.
3644 /// \version 3.7
3646
3647 /// The penalty for breaking after template declaration.
3648 /// \version 7
3650
3651 /// The penalty for each character outside of the column limit.
3652 /// \version 3.7
3654
3655 /// Penalty for each character of whitespace indentation
3656 /// (counted relative to leading non-whitespace column).
3657 /// \version 12
3659
3660 /// Penalty for putting the return type of a function onto its own line.
3661 /// \version 3.7
3663
3664 /// The ``&``, ``&&`` and ``*`` alignment style.
3666 /// Align pointer to the left.
3667 /// \code
3668 /// int* a;
3669 /// \endcode
3671 /// Align pointer to the right.
3672 /// \code
3673 /// int *a;
3674 /// \endcode
3676 /// Align pointer in the middle.
3677 /// \code
3678 /// int * a;
3679 /// \endcode
3682
3683 /// Pointer and reference alignment style.
3684 /// \version 3.7
3686
3687 /// The number of columns to use for indentation of preprocessor statements.
3688 /// When set to -1 (default) ``IndentWidth`` is used also for preprocessor
3689 /// statements.
3690 /// \code
3691 /// PPIndentWidth: 1
3692 ///
3693 /// #ifdef __linux__
3694 /// # define FOO
3695 /// #else
3696 /// # define BAR
3697 /// #endif
3698 /// \endcode
3699 /// \version 13
3701
3702 /// Different specifiers and qualifiers alignment styles.
3704 /// Don't change specifiers/qualifiers to either Left or Right alignment
3705 /// (default).
3706 /// \code
3707 /// int const a;
3708 /// const int *a;
3709 /// \endcode
3711 /// Change specifiers/qualifiers to be left-aligned.
3712 /// \code
3713 /// const int a;
3714 /// const int *a;
3715 /// \endcode
3717 /// Change specifiers/qualifiers to be right-aligned.
3718 /// \code
3719 /// int const a;
3720 /// int const *a;
3721 /// \endcode
3723 /// Change specifiers/qualifiers to be aligned based on ``QualifierOrder``.
3724 /// With:
3725 /// \code{.yaml}
3726 /// QualifierOrder: [inline, static, type, const]
3727 /// \endcode
3728 ///
3729 /// \code
3730 ///
3731 /// int const a;
3732 /// int const *a;
3733 /// \endcode
3736
3737 /// Different ways to arrange specifiers and qualifiers (e.g. const/volatile).
3738 /// \warning
3739 /// Setting ``QualifierAlignment`` to something other than ``Leave``, COULD
3740 /// lead to incorrect code formatting due to incorrect decisions made due to
3741 /// clang-formats lack of complete semantic information.
3742 /// As such extra care should be taken to review code changes made by the use
3743 /// of this option.
3744 /// \endwarning
3745 /// \version 14
3747
3748 /// The order in which the qualifiers appear.
3749 /// The order is an array that can contain any of the following:
3750 ///
3751 /// * ``const``
3752 /// * ``inline``
3753 /// * ``static``
3754 /// * ``friend``
3755 /// * ``constexpr``
3756 /// * ``volatile``
3757 /// * ``restrict``
3758 /// * ``type``
3759 ///
3760 /// \note
3761 /// It must contain ``type``.
3762 /// \endnote
3763 ///
3764 /// Items to the left of ``type`` will be placed to the left of the type and
3765 /// aligned in the order supplied. Items to the right of ``type`` will be
3766 /// placed to the right of the type and aligned in the order supplied.
3767 ///
3768 /// \code{.yaml}
3769 /// QualifierOrder: [inline, static, type, const, volatile]
3770 /// \endcode
3771 /// \version 14
3772 std::vector<std::string> QualifierOrder;
3773
3774 /// See documentation of ``RawStringFormats``.
3776 /// The language of this raw string.
3778 /// A list of raw string delimiters that match this language.
3779 std::vector<std::string> Delimiters;
3780 /// A list of enclosing function names that match this language.
3781 std::vector<std::string> EnclosingFunctions;
3782 /// The canonical delimiter for this language.
3784 /// The style name on which this raw string format is based on.
3785 /// If not specified, the raw string format is based on the style that this
3786 /// format is based on.
3787 std::string BasedOnStyle;
3788 bool operator==(const RawStringFormat &Other) const {
3789 return Language == Other.Language && Delimiters == Other.Delimiters &&
3790 EnclosingFunctions == Other.EnclosingFunctions &&
3791 CanonicalDelimiter == Other.CanonicalDelimiter &&
3792 BasedOnStyle == Other.BasedOnStyle;
3793 }
3794 };
3795
3796 /// Defines hints for detecting supported languages code blocks in raw
3797 /// strings.
3798 ///
3799 /// A raw string with a matching delimiter or a matching enclosing function
3800 /// name will be reformatted assuming the specified language based on the
3801 /// style for that language defined in the .clang-format file. If no style has
3802 /// been defined in the .clang-format file for the specific language, a
3803 /// predefined style given by ``BasedOnStyle`` is used. If ``BasedOnStyle`` is
3804 /// not found, the formatting is based on ``LLVM`` style. A matching delimiter
3805 /// takes precedence over a matching enclosing function name for determining
3806 /// the language of the raw string contents.
3807 ///
3808 /// If a canonical delimiter is specified, occurrences of other delimiters for
3809 /// the same language will be updated to the canonical if possible.
3810 ///
3811 /// There should be at most one specification per language and each delimiter
3812 /// and enclosing function should not occur in multiple specifications.
3813 ///
3814 /// To configure this in the .clang-format file, use:
3815 /// \code{.yaml}
3816 /// RawStringFormats:
3817 /// - Language: TextProto
3818 /// Delimiters:
3819 /// - pb
3820 /// - proto
3821 /// EnclosingFunctions:
3822 /// - PARSE_TEXT_PROTO
3823 /// BasedOnStyle: google
3824 /// - Language: Cpp
3825 /// Delimiters:
3826 /// - cc
3827 /// - cpp
3828 /// BasedOnStyle: LLVM
3829 /// CanonicalDelimiter: cc
3830 /// \endcode
3831 /// \version 6
3832 std::vector<RawStringFormat> RawStringFormats;
3833
3834 /// \brief The ``&`` and ``&&`` alignment style.
3836 /// Align reference like ``PointerAlignment``.
3838 /// Align reference to the left.
3839 /// \code
3840 /// int& a;
3841 /// \endcode
3843 /// Align reference to the right.
3844 /// \code
3845 /// int &a;
3846 /// \endcode
3848 /// Align reference in the middle.
3849 /// \code
3850 /// int & a;
3851 /// \endcode
3854
3855 /// \brief Reference alignment style (overrides ``PointerAlignment`` for
3856 /// references).
3857 /// \version 13
3859
3860 // clang-format off
3861 /// \brief Types of comment reflow style.
3862 enum ReflowCommentsStyle : int8_t {
3863 /// Leave comments untouched.
3864 /// \code
3865 /// // veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of information
3866 /// /* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of information */
3867 /// /* third veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of information
3868 /// * and a misaligned second line */
3869 /// \endcode
3871 /// Only apply indentation rules, moving comments left or right, without
3872 /// changing formatting inside the comments.
3873 /// \code
3874 /// // veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of information
3875 /// /* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of information */
3876 /// /* third veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of information
3877 /// * and a misaligned second line */
3878 /// \endcode
3880 /// Apply indentation rules and reflow long comments into new lines, trying
3881 /// to obey the ``ColumnLimit``.
3882 /// \code
3883 /// // veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of
3884 /// // information
3885 /// /* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of
3886 /// * information */
3887 /// /* third veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of
3888 /// * information and a misaligned second line */
3889 /// \endcode
3892 // clang-format on
3893
3894 /// \brief Comment reformatting style.
3895 /// \version 3.8
3897
3898 /// Remove optional braces of control statements (``if``, ``else``, ``for``,
3899 /// and ``while``) in C++ according to the LLVM coding style.
3900 /// \warning
3901 /// This option will be renamed and expanded to support other styles.
3902 /// \endwarning
3903 /// \warning
3904 /// Setting this option to ``true`` could lead to incorrect code formatting
3905 /// due to clang-format's lack of complete semantic information. As such,
3906 /// extra care should be taken to review code changes made by this option.
3907 /// \endwarning
3908 /// \code
3909 /// false: true:
3910 ///
3911 /// if (isa<FunctionDecl>(D)) { vs. if (isa<FunctionDecl>(D))
3912 /// handleFunctionDecl(D); handleFunctionDecl(D);
3913 /// } else if (isa<VarDecl>(D)) { else if (isa<VarDecl>(D))
3914 /// handleVarDecl(D); handleVarDecl(D);
3915 /// }
3916 ///
3917 /// if (isa<VarDecl>(D)) { vs. if (isa<VarDecl>(D)) {
3918 /// for (auto *A : D.attrs()) { for (auto *A : D.attrs())
3919 /// if (shouldProcessAttr(A)) { if (shouldProcessAttr(A))
3920 /// handleAttr(A); handleAttr(A);
3921 /// } }
3922 /// }
3923 /// }
3924 ///
3925 /// if (isa<FunctionDecl>(D)) { vs. if (isa<FunctionDecl>(D))
3926 /// for (auto *A : D.attrs()) { for (auto *A : D.attrs())
3927 /// handleAttr(A); handleAttr(A);
3928 /// }
3929 /// }
3930 ///
3931 /// if (auto *D = (T)(D)) { vs. if (auto *D = (T)(D)) {
3932 /// if (shouldProcess(D)) { if (shouldProcess(D))
3933 /// handleVarDecl(D); handleVarDecl(D);
3934 /// } else { else
3935 /// markAsIgnored(D); markAsIgnored(D);
3936 /// } }
3937 /// }
3938 ///
3939 /// if (a) { vs. if (a)
3940 /// b(); b();
3941 /// } else { else if (c)
3942 /// if (c) { d();
3943 /// d(); else
3944 /// } else { e();
3945 /// e();
3946 /// }
3947 /// }
3948 /// \endcode
3949 /// \version 14
3951
3952 /// Remove empty lines within unwrapped lines.
3953 /// \code
3954 /// false: true:
3955 ///
3956 /// int c vs. int c = a + b;
3957 ///
3958 /// = a + b;
3959 ///
3960 /// enum : unsigned vs. enum : unsigned {
3961 /// AA = 0,
3962 /// { BB
3963 /// AA = 0, } myEnum;
3964 /// BB
3965 /// } myEnum;
3966 ///
3967 /// while ( vs. while (true) {
3968 /// }
3969 /// true) {
3970 /// }
3971 /// \endcode
3972 /// \version 20
3974
3975 /// Types of redundant parentheses to remove.
3977 /// Do not remove parentheses.
3978 /// \code
3979 /// class __declspec((dllimport)) X {};
3980 /// co_return (((0)));
3981 /// return ((a + b) - ((c + d)));
3982 /// \endcode
3984 /// Replace multiple parentheses with single parentheses.
3985 /// \code
3986 /// class __declspec(dllimport) X {};
3987 /// co_return (0);
3988 /// return ((a + b) - (c + d));
3989 /// \endcode
3991 /// Also remove parentheses enclosing the expression in a
3992 /// ``return``/``co_return`` statement.
3993 /// \code
3994 /// class __declspec(dllimport) X {};
3995 /// co_return 0;
3996 /// return (a + b) - (c + d);
3997 /// \endcode
3999 };
4000
4001 /// Remove redundant parentheses.
4002 /// \warning
4003 /// Setting this option to any value other than ``Leave`` could lead to
4004 /// incorrect code formatting due to clang-format's lack of complete semantic
4005 /// information. As such, extra care should be taken to review code changes
4006 /// made by this option.
4007 /// \endwarning
4008 /// \version 17
4010
4011 /// Remove semicolons after the closing braces of functions and
4012 /// constructors/destructors.
4013 /// \warning
4014 /// Setting this option to ``true`` could lead to incorrect code formatting
4015 /// due to clang-format's lack of complete semantic information. As such,
4016 /// extra care should be taken to review code changes made by this option.
4017 /// \endwarning
4018 /// \code
4019 /// false: true:
4020 ///
4021 /// int max(int a, int b) { int max(int a, int b) {
4022 /// return a > b ? a : b; return a > b ? a : b;
4023 /// }; }
4024 ///
4025 /// \endcode
4026 /// \version 16
4028
4029 /// \brief The possible positions for the requires clause. The
4030 /// ``IndentRequires`` option is only used if the ``requires`` is put on the
4031 /// start of a line.
4033 /// Always put the ``requires`` clause on its own line (possibly followed by
4034 /// a semicolon).
4035 /// \code
4036 /// template <typename T>
4037 /// requires C<T>
4038 /// struct Foo {...
4039 ///
4040 /// template <typename T>
4041 /// void bar(T t)
4042 /// requires C<T>;
4043 ///
4044 /// template <typename T>
4045 /// requires C<T>
4046 /// void bar(T t) {...
4047 ///
4048 /// template <typename T>
4049 /// void baz(T t)
4050 /// requires C<T>
4051 /// {...
4052 /// \endcode
4054 /// As with ``OwnLine``, except, unless otherwise prohibited, place a
4055 /// following open brace (of a function definition) to follow on the same
4056 /// line.
4057 /// \code
4058 /// void bar(T t)
4059 /// requires C<T> {
4060 /// return;
4061 /// }
4062 ///
4063 /// void bar(T t)
4064 /// requires C<T> {}
4065 ///
4066 /// template <typename T>
4067 /// requires C<T>
4068 /// void baz(T t) {
4069 /// ...
4070 /// \endcode
4072 /// Try to put the clause together with the preceding part of a declaration.
4073 /// For class templates: stick to the template declaration.
4074 /// For function templates: stick to the template declaration.
4075 /// For function declaration followed by a requires clause: stick to the
4076 /// parameter list.
4077 /// \code
4078 /// template <typename T> requires C<T>
4079 /// struct Foo {...
4080 ///
4081 /// template <typename T> requires C<T>
4082 /// void bar(T t) {...
4083 ///
4084 /// template <typename T>
4085 /// void baz(T t) requires C<T>
4086 /// {...
4087 /// \endcode
4089 /// Try to put the ``requires`` clause together with the class or function
4090 /// declaration.
4091 /// \code
4092 /// template <typename T>
4093 /// requires C<T> struct Foo {...
4094 ///
4095 /// template <typename T>
4096 /// requires C<T> void bar(T t) {...
4097 ///
4098 /// template <typename T>
4099 /// void baz(T t)
4100 /// requires C<T> {...
4101 /// \endcode
4103 /// Try to put everything in the same line if possible. Otherwise normal
4104 /// line breaking rules take over.
4105 /// \code
4106 /// // Fitting:
4107 /// template <typename T> requires C<T> struct Foo {...
4108 ///
4109 /// template <typename T> requires C<T> void bar(T t) {...
4110 ///
4111 /// template <typename T> void bar(T t) requires C<T> {...
4112 ///
4113 /// // Not fitting, one possible example:
4114 /// template <typename LongName>
4115 /// requires C<LongName>
4116 /// struct Foo {...
4117 ///
4118 /// template <typename LongName>
4119 /// requires C<LongName>
4120 /// void bar(LongName ln) {
4121 ///
4122 /// template <typename LongName>
4123 /// void bar(LongName ln)
4124 /// requires C<LongName> {
4125 /// \endcode
4127 };
4128
4129 /// \brief The position of the ``requires`` clause.
4130 /// \version 15
4132
4133 /// Indentation logic for requires expression bodies.
4135 /// Align requires expression body relative to the indentation level of the
4136 /// outer scope the requires expression resides in.
4137 /// This is the default.
4138 /// \code
4139 /// template <typename T>
4140 /// concept C = requires(T t) {
4141 /// ...
4142 /// }
4143 /// \endcode
4145 /// Align requires expression body relative to the ``requires`` keyword.
4146 /// \code
4147 /// template <typename T>
4148 /// concept C = requires(T t) {
4149 /// ...
4150 /// }
4151 /// \endcode
4153 };
4154
4155 /// The indentation used for requires expression bodies.
4156 /// \version 16
4158
4159 /// \brief The style if definition blocks should be separated.
4161 /// Leave definition blocks as they are.
4163 /// Insert an empty line between definition blocks.
4165 /// Remove any empty line between definition blocks.
4166 SDS_Never
4168
4169 /// Specifies the use of empty lines to separate definition blocks, including
4170 /// classes, structs, enums, and functions.
4171 /// \code
4172 /// Never v.s. Always
4173 /// #include <cstring> #include <cstring>
4174 /// struct Foo {
4175 /// int a, b, c; struct Foo {
4176 /// }; int a, b, c;
4177 /// namespace Ns { };
4178 /// class Bar {
4179 /// public: namespace Ns {
4180 /// struct Foobar { class Bar {
4181 /// int a; public:
4182 /// int b; struct Foobar {
4183 /// }; int a;
4184 /// private: int b;
4185 /// int t; };
4186 /// int method1() {
4187 /// // ... private:
4188 /// } int t;
4189 /// enum List {
4190 /// ITEM1, int method1() {
4191 /// ITEM2 // ...
4192 /// }; }
4193 /// template<typename T>
4194 /// int method2(T x) { enum List {
4195 /// // ... ITEM1,
4196 /// } ITEM2
4197 /// int i, j, k; };
4198 /// int method3(int par) {
4199 /// // ... template<typename T>
4200 /// } int method2(T x) {
4201 /// }; // ...
4202 /// class C {}; }
4203 /// }
4204 /// int i, j, k;
4205 ///
4206 /// int method3(int par) {
4207 /// // ...
4208 /// }
4209 /// };
4210 ///
4211 /// class C {};
4212 /// }
4213 /// \endcode
4214 /// \version 14
4216
4217 /// The maximal number of unwrapped lines that a short namespace spans.
4218 /// Defaults to 1.
4219 ///
4220 /// This determines the maximum length of short namespaces by counting
4221 /// unwrapped lines (i.e. containing neither opening nor closing
4222 /// namespace brace) and makes ``FixNamespaceComments`` omit adding
4223 /// end comments for those.
4224 /// \code
4225 /// ShortNamespaceLines: 1 vs. ShortNamespaceLines: 0
4226 /// namespace a { namespace a {
4227 /// int foo; int foo;
4228 /// } } // namespace a
4229 ///
4230 /// ShortNamespaceLines: 1 vs. ShortNamespaceLines: 0
4231 /// namespace b { namespace b {
4232 /// int foo; int foo;
4233 /// int bar; int bar;
4234 /// } // namespace b } // namespace b
4235 /// \endcode
4236 /// \version 13
4238
4239 /// Do not format macro definition body.
4240 /// \version 18
4242
4243 /// Include sorting options.
4244 enum SortIncludesOptions : int8_t {
4245 /// Includes are never sorted.
4246 /// \code
4247 /// #include "B/A.h"
4248 /// #include "A/B.h"
4249 /// #include "a/b.h"
4250 /// #include "A/b.h"
4251 /// #include "B/a.h"
4252 /// \endcode
4254 /// Includes are sorted in an ASCIIbetical or case sensitive fashion.
4255 /// \code
4256 /// #include "A/B.h"
4257 /// #include "A/b.h"
4258 /// #include "B/A.h"
4259 /// #include "B/a.h"
4260 /// #include "a/b.h"
4261 /// \endcode
4263 /// Includes are sorted in an alphabetical or case insensitive fashion.
4264 /// \code
4265 /// #include "A/B.h"
4266 /// #include "A/b.h"
4267 /// #include "a/b.h"
4268 /// #include "B/A.h"
4269 /// #include "B/a.h"
4270 /// \endcode
4272 };
4273
4274 /// Controls if and how clang-format will sort ``#includes``.
4275 /// \version 3.8
4277
4278 /// Position for Java Static imports.
4280 /// Static imports are placed before non-static imports.
4281 /// \code{.java}
4282 /// import static org.example.function1;
4283 ///
4284 /// import org.example.ClassA;
4285 /// \endcode
4287 /// Static imports are placed after non-static imports.
4288 /// \code{.java}
4289 /// import org.example.ClassA;
4290 ///
4291 /// import static org.example.function1;
4292 /// \endcode
4294 };
4295
4296 /// When sorting Java imports, by default static imports are placed before
4297 /// non-static imports. If ``JavaStaticImportAfterImport`` is ``After``,
4298 /// static imports are placed after non-static imports.
4299 /// \version 12
4301
4302 /// Using declaration sorting options.
4304 /// Using declarations are never sorted.
4305 /// \code
4306 /// using std::chrono::duration_cast;
4307 /// using std::move;
4308 /// using boost::regex;
4309 /// using boost::regex_constants::icase;
4310 /// using std::string;
4311 /// \endcode
4313 /// Using declarations are sorted in the order defined as follows:
4314 /// Split the strings by ``::`` and discard any initial empty strings. Sort
4315 /// the lists of names lexicographically, and within those groups, names are
4316 /// in case-insensitive lexicographic order.
4317 /// \code
4318 /// using boost::regex;
4319 /// using boost::regex_constants::icase;
4320 /// using std::chrono::duration_cast;
4321 /// using std::move;
4322 /// using std::string;
4323 /// \endcode
4325 /// Using declarations are sorted in the order defined as follows:
4326 /// Split the strings by ``::`` and discard any initial empty strings. The
4327 /// last element of each list is a non-namespace name; all others are
4328 /// namespace names. Sort the lists of names lexicographically, where the
4329 /// sort order of individual names is that all non-namespace names come
4330 /// before all namespace names, and within those groups, names are in
4331 /// case-insensitive lexicographic order.
4332 /// \code
4333 /// using boost::regex;
4334 /// using boost::regex_constants::icase;
4335 /// using std::move;
4336 /// using std::string;
4337 /// using std::chrono::duration_cast;
4338 /// \endcode
4340 };
4341
4342 /// Controls if and how clang-format will sort using declarations.
4343 /// \version 5
4345
4346 /// If ``true``, a space is inserted after C style casts.
4347 /// \code
4348 /// true: false:
4349 /// (int) i; vs. (int)i;
4350 /// \endcode
4351 /// \version 3.5
4353
4354 /// If ``true``, a space is inserted after the logical not operator (``!``).
4355 /// \code
4356 /// true: false:
4357 /// ! someExpression(); vs. !someExpression();
4358 /// \endcode
4359 /// \version 9
4361
4362 /// If \c true, a space will be inserted after the ``template`` keyword.
4363 /// \code
4364 /// true: false:
4365 /// template <int> void foo(); vs. template<int> void foo();
4366 /// \endcode
4367 /// \version 4
4369
4370 /// Different ways to put a space before opening parentheses.
4372 /// Don't ensure spaces around pointer qualifiers and use PointerAlignment
4373 /// instead.
4374 /// \code
4375 /// PointerAlignment: Left PointerAlignment: Right
4376 /// void* const* x = NULL; vs. void *const *x = NULL;
4377 /// \endcode
4379 /// Ensure that there is a space before pointer qualifiers.
4380 /// \code
4381 /// PointerAlignment: Left PointerAlignment: Right
4382 /// void* const* x = NULL; vs. void * const *x = NULL;
4383 /// \endcode
4385 /// Ensure that there is a space after pointer qualifiers.
4386 /// \code
4387 /// PointerAlignment: Left PointerAlignment: Right
4388 /// void* const * x = NULL; vs. void *const *x = NULL;
4389 /// \endcode
4391 /// Ensure that there is a space both before and after pointer qualifiers.
4392 /// \code
4393 /// PointerAlignment: Left PointerAlignment: Right
4394 /// void* const * x = NULL; vs. void * const *x = NULL;
4395 /// \endcode
4397 };
4398
4399 /// Defines in which cases to put a space before or after pointer qualifiers
4400 /// \version 12
4402
4403 /// If ``false``, spaces will be removed before assignment operators.
4404 /// \code
4405 /// true: false:
4406 /// int a = 5; vs. int a= 5;
4407 /// a += 42; a+= 42;
4408 /// \endcode
4409 /// \version 3.7
4411
4412 /// If ``false``, spaces will be removed before case colon.
4413 /// \code
4414 /// true: false
4415 /// switch (x) { vs. switch (x) {
4416 /// case 1 : break; case 1: break;
4417 /// } }
4418 /// \endcode
4419 /// \version 12
4421
4422 /// If ``true``, a space will be inserted before a C++11 braced list
4423 /// used to initialize an object (after the preceding identifier or type).
4424 /// \code
4425 /// true: false:
4426 /// Foo foo { bar }; vs. Foo foo{ bar };
4427 /// Foo {}; Foo{};
4428 /// vector<int> { 1, 2, 3 }; vector<int>{ 1, 2, 3 };
4429 /// new int[3] { 1, 2, 3 }; new int[3]{ 1, 2, 3 };
4430 /// \endcode
4431 /// \version 7
4433
4434 /// If ``false``, spaces will be removed before constructor initializer
4435 /// colon.
4436 /// \code
4437 /// true: false:
4438 /// Foo::Foo() : a(a) {} Foo::Foo(): a(a) {}
4439 /// \endcode
4440 /// \version 7
4442
4443 /// If ``false``, spaces will be removed before inheritance colon.
4444 /// \code
4445 /// true: false:
4446 /// class Foo : Bar {} vs. class Foo: Bar {}
4447 /// \endcode
4448 /// \version 7
4450
4451 /// If ``true``, a space will be added before a JSON colon. For other
4452 /// languages, e.g. JavaScript, use ``SpacesInContainerLiterals`` instead.
4453 /// \code
4454 /// true: false:
4455 /// { {
4456 /// "key" : "value" vs. "key": "value"
4457 /// } }
4458 /// \endcode
4459 /// \version 17
4461
4462 /// Different ways to put a space before opening parentheses.
4464 /// This is **deprecated** and replaced by ``Custom`` below, with all
4465 /// ``SpaceBeforeParensOptions`` but ``AfterPlacementOperator`` set to
4466 /// ``false``.
4468 /// Put a space before opening parentheses only after control statement
4469 /// keywords (``for/if/while...``).
4470 /// \code
4471 /// void f() {
4472 /// if (true) {
4473 /// f();
4474 /// }
4475 /// }
4476 /// \endcode
4478 /// Same as ``SBPO_ControlStatements`` except this option doesn't apply to
4479 /// ForEach and If macros. This is useful in projects where ForEach/If
4480 /// macros are treated as function calls instead of control statements.
4481 /// ``SBPO_ControlStatementsExceptForEachMacros`` remains an alias for
4482 /// backward compatibility.
4483 /// \code
4484 /// void f() {
4485 /// Q_FOREACH(...) {
4486 /// f();
4487 /// }
4488 /// }
4489 /// \endcode
4491 /// Put a space before opening parentheses only if the parentheses are not
4492 /// empty.
4493 /// \code
4494 /// void() {
4495 /// if (true) {
4496 /// f();
4497 /// g (x, y, z);
4498 /// }
4499 /// }
4500 /// \endcode
4502 /// Always put a space before opening parentheses, except when it's
4503 /// prohibited by the syntax rules (in function-like macro definitions) or
4504 /// when determined by other style rules (after unary operators, opening
4505 /// parentheses, etc.)
4506 /// \code
4507 /// void f () {
4508 /// if (true) {
4509 /// f ();
4510 /// }
4511 /// }
4512 /// \endcode
4514 /// Configure each individual space before parentheses in
4515 /// ``SpaceBeforeParensOptions``.
4517 };
4518
4519 /// Defines in which cases to put a space before opening parentheses.
4520 /// \version 3.5
4522
4523 /// Precise control over the spacing before parentheses.
4524 /// \code
4525 /// # Should be declared this way:
4526 /// SpaceBeforeParens: Custom
4527 /// SpaceBeforeParensOptions:
4528 /// AfterControlStatements: true
4529 /// AfterFunctionDefinitionName: true
4530 /// \endcode
4532 /// If ``true``, put space between control statement keywords
4533 /// (for/if/while...) and opening parentheses.
4534 /// \code
4535 /// true: false:
4536 /// if (...) {} vs. if(...) {}
4537 /// \endcode
4539 /// If ``true``, put space between foreach macros and opening parentheses.
4540 /// \code
4541 /// true: false:
4542 /// FOREACH (...) vs. FOREACH(...)
4543 /// <loop-body> <loop-body>
4544 /// \endcode
4546 /// If ``true``, put a space between function declaration name and opening
4547 /// parentheses.
4548 /// \code
4549 /// true: false:
4550 /// void f (); vs. void f();
4551 /// \endcode
4553 /// If ``true``, put a space between function definition name and opening
4554 /// parentheses.
4555 /// \code
4556 /// true: false:
4557 /// void f () {} vs. void f() {}
4558 /// \endcode
4560 /// If ``true``, put space between if macros and opening parentheses.
4561 /// \code
4562 /// true: false:
4563 /// IF (...) vs. IF(...)
4564 /// <conditional-body> <conditional-body>
4565 /// \endcode
4567 /// If ``true``, put a space between operator overloading and opening
4568 /// parentheses.
4569 /// \code
4570 /// true: false:
4571 /// void operator++ (int a); vs. void operator++(int a);
4572 /// object.operator++ (10); object.operator++(10);
4573 /// \endcode
4575 /// If ``true``, put a space between operator ``new``/``delete`` and opening
4576 /// parenthesis.
4577 /// \code
4578 /// true: false:
4579 /// new (buf) T; vs. new(buf) T;
4580 /// delete (buf) T; delete(buf) T;
4581 /// \endcode
4583 /// If ``true``, put space between requires keyword in a requires clause and
4584 /// opening parentheses, if there is one.
4585 /// \code
4586 /// true: false:
4587 /// template<typename T> vs. template<typename T>
4588 /// requires (A<T> && B<T>) requires(A<T> && B<T>)
4589 /// ... ...
4590 /// \endcode
4592 /// If ``true``, put space between requires keyword in a requires expression
4593 /// and opening parentheses.
4594 /// \code
4595 /// true: false:
4596 /// template<typename T> vs. template<typename T>
4597 /// concept C = requires (T t) { concept C = requires(T t) {
4598 /// ... ...
4599 /// } }
4600 /// \endcode
4602 /// If ``true``, put a space before opening parentheses only if the
4603 /// parentheses are not empty.
4604 /// \code
4605 /// true: false:
4606 /// void f (int a); vs. void f();
4607 /// f (a); f();
4608 /// \endcode
4610
4618
4620 return AfterControlStatements == Other.AfterControlStatements &&
4621 AfterForeachMacros == Other.AfterForeachMacros &&
4623 Other.AfterFunctionDeclarationName &&
4624 AfterFunctionDefinitionName == Other.AfterFunctionDefinitionName &&
4625 AfterIfMacros == Other.AfterIfMacros &&
4626 AfterOverloadedOperator == Other.AfterOverloadedOperator &&
4627 AfterPlacementOperator == Other.AfterPlacementOperator &&
4628 AfterRequiresInClause == Other.AfterRequiresInClause &&
4629 AfterRequiresInExpression == Other.AfterRequiresInExpression &&
4630 BeforeNonEmptyParentheses == Other.BeforeNonEmptyParentheses;
4631 }
4632 };
4633
4634 /// Control of individual space before parentheses.
4635 ///
4636 /// If ``SpaceBeforeParens`` is set to ``Custom``, use this to specify
4637 /// how each individual space before parentheses case should be handled.
4638 /// Otherwise, this is ignored.
4639 /// \code{.yaml}
4640 /// # Example of usage:
4641 /// SpaceBeforeParens: Custom
4642 /// SpaceBeforeParensOptions:
4643 /// AfterControlStatements: true
4644 /// AfterFunctionDefinitionName: true
4645 /// \endcode
4646 /// \version 14
4648
4649 /// If ``true``, spaces will be before ``[``.
4650 /// Lambdas will not be affected. Only the first ``[`` will get a space added.
4651 /// \code
4652 /// true: false:
4653 /// int a [5]; vs. int a[5];
4654 /// int a [5][5]; vs. int a[5][5];
4655 /// \endcode
4656 /// \version 10
4658
4659 /// If ``false``, spaces will be removed before range-based for loop
4660 /// colon.
4661 /// \code
4662 /// true: false:
4663 /// for (auto v : values) {} vs. for(auto v: values) {}
4664 /// \endcode
4665 /// \version 7
4667
4668 /// If ``true``, spaces will be inserted into ``{}``.
4669 /// \code
4670 /// true: false:
4671 /// void f() { } vs. void f() {}
4672 /// while (true) { } while (true) {}
4673 /// \endcode
4674 /// \version 10
4676
4677 /// If ``true``, spaces may be inserted into ``()``.
4678 /// This option is **deprecated**. See ``InEmptyParentheses`` of
4679 /// ``SpacesInParensOptions``.
4680 /// \version 3.7
4681 // bool SpaceInEmptyParentheses;
4682
4683 /// The number of spaces before trailing line comments
4684 /// (``//`` - comments).
4685 ///
4686 /// This does not affect trailing block comments (``/*`` - comments) as those
4687 /// commonly have different usage patterns and a number of special cases. In
4688 /// the case of Verilog, it doesn't affect a comment right after the opening
4689 /// parenthesis in the port or parameter list in a module header, because it
4690 /// is probably for the port on the following line instead of the parenthesis
4691 /// it follows.
4692 /// \code
4693 /// SpacesBeforeTrailingComments: 3
4694 /// void f() {
4695 /// if (true) { // foo1
4696 /// f(); // bar
4697 /// } // foo
4698 /// }
4699 /// \endcode
4700 /// \version 3.7
4702
4703 /// Styles for adding spacing after ``<`` and before ``>``
4704 /// in template argument lists.
4705 enum SpacesInAnglesStyle : int8_t {
4706 /// Remove spaces after ``<`` and before ``>``.
4707 /// \code
4708 /// static_cast<int>(arg);
4709 /// std::function<void(int)> fct;
4710 /// \endcode
4712 /// Add spaces after ``<`` and before ``>``.
4713 /// \code
4714 /// static_cast< int >(arg);
4715 /// std::function< void(int) > fct;
4716 /// \endcode
4718 /// Keep a single space after ``<`` and before ``>`` if any spaces were
4719 /// present. Option ``Standard: Cpp03`` takes precedence.
4722 /// The SpacesInAnglesStyle to use for template argument lists.
4723 /// \version 3.4
4725
4726 /// If ``true``, spaces will be inserted around if/for/switch/while
4727 /// conditions.
4728 /// This option is **deprecated**. See ``InConditionalStatements`` of
4729 /// ``SpacesInParensOptions``.
4730 /// \version 10
4731 // bool SpacesInConditionalStatement;
4732
4733 /// If ``true``, spaces are inserted inside container literals (e.g. ObjC and
4734 /// Javascript array and dict literals). For JSON, use
4735 /// ``SpaceBeforeJsonColon`` instead.
4736 /// \code{.js}
4737 /// true: false:
4738 /// var arr = [ 1, 2, 3 ]; vs. var arr = [1, 2, 3];
4739 /// f({a : 1, b : 2, c : 3}); f({a: 1, b: 2, c: 3});
4740 /// \endcode
4741 /// \version 3.7
4743
4744 /// If ``true``, spaces may be inserted into C style casts.
4745 /// This option is **deprecated**. See ``InCStyleCasts`` of
4746 /// ``SpacesInParensOptions``.
4747 /// \version 3.7
4748 // bool SpacesInCStyleCastParentheses;
4749
4750 /// Control of spaces within a single line comment.
4752 /// The minimum number of spaces at the start of the comment.
4753 unsigned Minimum;
4754 /// The maximum number of spaces at the start of the comment.
4755 unsigned Maximum;
4756 };
4757
4758 /// How many spaces are allowed at the start of a line comment. To disable the
4759 /// maximum set it to ``-1``, apart from that the maximum takes precedence
4760 /// over the minimum.
4761 /// \code
4762 /// Minimum = 1
4763 /// Maximum = -1
4764 /// // One space is forced
4765 ///
4766 /// // but more spaces are possible
4767 ///
4768 /// Minimum = 0
4769 /// Maximum = 0
4770 /// //Forces to start every comment directly after the slashes
4771 /// \endcode
4772 ///
4773 /// Note that in line comment sections the relative indent of the subsequent
4774 /// lines is kept, that means the following:
4775 /// \code
4776 /// before: after:
4777 /// Minimum: 1
4778 /// //if (b) { // if (b) {
4779 /// // return true; // return true;
4780 /// //} // }
4781 ///
4782 /// Maximum: 0
4783 /// /// List: ///List:
4784 /// /// - Foo /// - Foo
4785 /// /// - Bar /// - Bar
4786 /// \endcode
4787 ///
4788 /// This option has only effect if ``ReflowComments`` is set to ``true``.
4789 /// \version 13
4791
4792 /// Different ways to put a space before opening and closing parentheses.
4793 enum SpacesInParensStyle : int8_t {
4794 /// Never put a space in parentheses.
4795 /// \code
4796 /// void f() {
4797 /// if(true) {
4798 /// f();
4799 /// }
4800 /// }
4801 /// \endcode
4803 /// Configure each individual space in parentheses in
4804 /// `SpacesInParensOptions`.
4806 };
4807
4808 /// If ``true``, spaces will be inserted after ``(`` and before ``)``.
4809 /// This option is **deprecated**. The previous behavior is preserved by using
4810 /// ``SpacesInParens`` with ``Custom`` and by setting all
4811 /// ``SpacesInParensOptions`` to ``true`` except for ``InCStyleCasts`` and
4812 /// ``InEmptyParentheses``.
4813 /// \version 3.7
4814 // bool SpacesInParentheses;
4815
4816 /// Defines in which cases spaces will be inserted after ``(`` and before
4817 /// ``)``.
4818 /// \version 17
4820
4821 /// Precise control over the spacing in parentheses.
4822 /// \code
4823 /// # Should be declared this way:
4824 /// SpacesInParens: Custom
4825 /// SpacesInParensOptions:
4826 /// ExceptDoubleParentheses: false
4827 /// InConditionalStatements: true
4828 /// Other: true
4829 /// \endcode
4831 /// Override any of the following options to prevent addition of space
4832 /// when both opening and closing parentheses use multiple parentheses.
4833 /// \code
4834 /// true:
4835 /// __attribute__(( noreturn ))
4836 /// __decltype__(( x ))
4837 /// if (( a = b ))
4838 /// \endcode
4839 /// false:
4840 /// Uses the applicable option.
4842 /// Put a space in parentheses only inside conditional statements
4843 /// (``for/if/while/switch...``).
4844 /// \code
4845 /// true: false:
4846 /// if ( a ) { ... } vs. if (a) { ... }
4847 /// while ( i < 5 ) { ... } while (i < 5) { ... }
4848 /// \endcode
4850 /// Put a space in C style casts.
4851 /// \code
4852 /// true: false:
4853 /// x = ( int32 )y vs. x = (int32)y
4854 /// y = (( int (*)(int) )foo)(x); y = ((int (*)(int))foo)(x);
4855 /// \endcode
4857 /// Insert a space in empty parentheses, i.e. ``()``.
4858 /// \code
4859 /// true: false:
4860 /// void f( ) { vs. void f() {
4861 /// int x[] = {foo( ), bar( )}; int x[] = {foo(), bar()};
4862 /// if (true) { if (true) {
4863 /// f( ); f();
4864 /// } }
4865 /// } }
4866 /// \endcode
4868 /// Put a space in parentheses not covered by preceding options.
4869 /// \code
4870 /// true: false:
4871 /// t f( Deleted & ) & = delete; vs. t f(Deleted &) & = delete;
4872 /// \endcode
4873 bool Other;
4874
4878
4881 bool InEmptyParentheses, bool Other)
4885 Other(Other) {}
4886
4887 bool operator==(const SpacesInParensCustom &R) const {
4892 }
4893 bool operator!=(const SpacesInParensCustom &R) const {
4894 return !(*this == R);
4895 }
4896 };
4897
4898 /// Control of individual spaces in parentheses.
4899 ///
4900 /// If ``SpacesInParens`` is set to ``Custom``, use this to specify
4901 /// how each individual space in parentheses case should be handled.
4902 /// Otherwise, this is ignored.
4903 /// \code{.yaml}
4904 /// # Example of usage:
4905 /// SpacesInParens: Custom
4906 /// SpacesInParensOptions:
4907 /// ExceptDoubleParentheses: false
4908 /// InConditionalStatements: true
4909 /// InEmptyParentheses: true
4910 /// \endcode
4911 /// \version 17
4913
4914 /// If ``true``, spaces will be inserted after ``[`` and before ``]``.
4915 /// Lambdas without arguments or unspecified size array declarations will not
4916 /// be affected.
4917 /// \code
4918 /// true: false:
4919 /// int a[ 5 ]; vs. int a[5];
4920 /// std::unique_ptr<int[]> foo() {} // Won't be affected
4921 /// \endcode
4922 /// \version 3.7
4924
4925 /// Supported language standards for parsing and formatting C++ constructs.
4926 /// \code
4927 /// Latest: vector<set<int>>
4928 /// c++03 vs. vector<set<int> >
4929 /// \endcode
4930 ///
4931 /// The correct way to spell a specific language version is e.g. ``c++11``.
4932 /// The historical aliases ``Cpp03`` and ``Cpp11`` are deprecated.
4933 enum LanguageStandard : int8_t {
4934 /// Parse and format as C++03.
4935 /// ``Cpp03`` is a deprecated alias for ``c++03``
4936 LS_Cpp03, // c++03
4937 /// Parse and format as C++11.
4938 LS_Cpp11, // c++11
4939 /// Parse and format as C++14.
4940 LS_Cpp14, // c++14
4941 /// Parse and format as C++17.
4942 LS_Cpp17, // c++17
4943 /// Parse and format as C++20.
4944 LS_Cpp20, // c++20
4945 /// Parse and format using the latest supported language version.
4946 /// ``Cpp11`` is a deprecated alias for ``Latest``
4948 /// Automatic detection based on the input.
4950 };
4951
4952 /// Parse and format C++ constructs compatible with this standard.
4953 /// \code
4954 /// c++03: latest:
4955 /// vector<set<int> > x; vs. vector<set<int>> x;
4956 /// \endcode
4957 /// \version 3.7
4959
4960 /// Macros which are ignored in front of a statement, as if they were an
4961 /// attribute. So that they are not parsed as identifier, for example for Qts
4962 /// emit.
4963 /// \code
4964 /// AlignConsecutiveDeclarations: true
4965 /// StatementAttributeLikeMacros: []
4966 /// unsigned char data = 'x';
4967 /// emit signal(data); // This is parsed as variable declaration.
4968 ///
4969 /// AlignConsecutiveDeclarations: true
4970 /// StatementAttributeLikeMacros: [emit]
4971 /// unsigned char data = 'x';
4972 /// emit signal(data); // Now it's fine again.
4973 /// \endcode
4974 /// \version 12
4975 std::vector<std::string> StatementAttributeLikeMacros;
4976
4977 /// A vector of macros that should be interpreted as complete statements.
4978 ///
4979 /// Typical macros are expressions and require a semicolon to be added.
4980 /// Sometimes this is not the case, and this allows to make clang-format aware
4981 /// of such cases.
4982 ///
4983 /// For example: Q_UNUSED
4984 /// \version 8
4985 std::vector<std::string> StatementMacros;
4986
4987 /// Works only when TableGenBreakInsideDAGArg is not DontBreak.
4988 /// The string list needs to consist of identifiers in TableGen.
4989 /// If any identifier is specified, this limits the line breaks by
4990 /// TableGenBreakInsideDAGArg option only on DAGArg values beginning with
4991 /// the specified identifiers.
4992 ///
4993 /// For example the configuration,
4994 /// \code{.yaml}
4995 /// TableGenBreakInsideDAGArg: BreakAll
4996 /// TableGenBreakingDAGArgOperators: [ins, outs]
4997 /// \endcode
4998 ///
4999 /// makes the line break only occurs inside DAGArgs beginning with the
5000 /// specified identifiers ``ins`` and ``outs``.
5001 ///
5002 /// \code
5003 /// let DAGArgIns = (ins
5004 /// i32:$src1,
5005 /// i32:$src2
5006 /// );
5007 /// let DAGArgOtherID = (other i32:$other1, i32:$other2);
5008 /// let DAGArgBang = (!cast<SomeType>("Some") i32:$src1, i32:$src2)
5009 /// \endcode
5010 /// \version 19
5011 std::vector<std::string> TableGenBreakingDAGArgOperators;
5012
5013 /// Different ways to control the format inside TableGen DAGArg.
5014 enum DAGArgStyle : int8_t {
5015 /// Never break inside DAGArg.
5016 /// \code
5017 /// let DAGArgIns = (ins i32:$src1, i32:$src2);
5018 /// \endcode
5020 /// Break inside DAGArg after each list element but for the last.
5021 /// This aligns to the first element.
5022 /// \code
5023 /// let DAGArgIns = (ins i32:$src1,
5024 /// i32:$src2);
5025 /// \endcode
5027 /// Break inside DAGArg after the operator and the all elements.
5028 /// \code
5029 /// let DAGArgIns = (ins
5030 /// i32:$src1,
5031 /// i32:$src2
5032 /// );
5033 /// \endcode
5035 };
5036
5037 /// The styles of the line break inside the DAGArg in TableGen.
5038 /// \version 19
5040
5041 /// The number of columns used for tab stops.
5042 /// \version 3.7
5043 unsigned TabWidth;
5044
5045 /// A vector of non-keyword identifiers that should be interpreted as
5046 /// template names.
5047 ///
5048 /// A ``<`` after a template name is annotated as a template opener instead of
5049 /// a binary operator.
5050 ///
5051 /// \version 20
5052 std::vector<std::string> TemplateNames;
5053
5054 /// A vector of non-keyword identifiers that should be interpreted as type
5055 /// names.
5056 ///
5057 /// A ``*``, ``&``, or ``&&`` between a type name and another non-keyword
5058 /// identifier is annotated as a pointer or reference token instead of a
5059 /// binary operator.
5060 ///
5061 /// \version 17
5062 std::vector<std::string> TypeNames;
5063
5064 /// \brief A vector of macros that should be interpreted as type declarations
5065 /// instead of as function calls.
5066 ///
5067 /// These are expected to be macros of the form:
5068 /// \code
5069 /// STACK_OF(...)
5070 /// \endcode
5071 ///
5072 /// In the .clang-format configuration file, this can be configured like:
5073 /// \code{.yaml}
5074 /// TypenameMacros: [STACK_OF, LIST]
5075 /// \endcode
5076 ///
5077 /// For example: OpenSSL STACK_OF, BSD LIST_ENTRY.
5078 /// \version 9
5079 std::vector<std::string> TypenameMacros;
5080
5081 /// This option is **deprecated**. See ``LF`` and ``CRLF`` of ``LineEnding``.
5082 /// \version 10
5083 // bool UseCRLF;
5084
5085 /// Different ways to use tab in formatting.
5086 enum UseTabStyle : int8_t {
5087 /// Never use tab.
5089 /// Use tabs only for indentation.
5091 /// Fill all leading whitespace with tabs, and use spaces for alignment that
5092 /// appears within a line (e.g. consecutive assignments and declarations).
5094 /// Use tabs for line continuation and indentation, and spaces for
5095 /// alignment.
5097 /// Use tabs whenever we need to fill whitespace that spans at least from
5098 /// one tab stop to the next one.
5099 UT_Always
5101
5102 /// The way to use tab characters in the resulting file.
5103 /// \version 3.7
5105
5106 /// For Verilog, put each port on its own line in module instantiations.
5107 /// \code
5108 /// true:
5109 /// ffnand ff1(.q(),
5110 /// .qbar(out1),
5111 /// .clear(in1),
5112 /// .preset(in2));
5113 ///
5114 /// false:
5115 /// ffnand ff1(.q(), .qbar(out1), .clear(in1), .preset(in2));
5116 /// \endcode
5117 /// \version 17
5119
5120 /// A vector of macros which are whitespace-sensitive and should not
5121 /// be touched.
5122 ///
5123 /// These are expected to be macros of the form:
5124 /// \code
5125 /// STRINGIZE(...)
5126 /// \endcode
5127 ///
5128 /// In the .clang-format configuration file, this can be configured like:
5129 /// \code{.yaml}
5130 /// WhitespaceSensitiveMacros: [STRINGIZE, PP_STRINGIZE]
5131 /// \endcode
5132 ///
5133 /// For example: BOOST_PP_STRINGIZE
5134 /// \version 11
5135 std::vector<std::string> WhitespaceSensitiveMacros;
5136
5137 bool operator==(const FormatStyle &R) const {
5188 BreakArrays == R.BreakArrays &&
5229 IndentWidth == R.IndentWidth &&
5309 Standard == R.Standard &&
5317 UseTab == R.UseTab &&
5321 }
5322
5323 std::optional<FormatStyle> GetLanguageStyle(LanguageKind Language) const;
5324
5325 // Stores per-language styles. A FormatStyle instance inside has an empty
5326 // StyleSet. A FormatStyle instance returned by the Get method has its
5327 // StyleSet set to a copy of the originating StyleSet, effectively keeping the
5328 // internal representation of that StyleSet alive.
5329 //
5330 // The memory management and ownership reminds of a birds nest: chicks
5331 // leaving the nest take photos of the nest with them.
5333 typedef std::map<FormatStyle::LanguageKind, FormatStyle> MapType;
5334
5335 std::optional<FormatStyle> Get(FormatStyle::LanguageKind Language) const;
5336
5337 // Adds \p Style to this FormatStyleSet. Style must not have an associated
5338 // FormatStyleSet.
5339 // Style.Language should be different than LK_None. If this FormatStyleSet
5340 // already contains an entry for Style.Language, that gets replaced with the
5341 // passed Style.
5342 void Add(FormatStyle Style);
5343
5344 // Clears this FormatStyleSet.
5345 void Clear();
5346
5347 private:
5348 std::shared_ptr<MapType> Styles;
5349 };
5350
5352 const FormatStyle &MainStyle,
5353 const std::vector<FormatStyle> &ConfigurationStyles);
5354
5355private:
5356 FormatStyleSet StyleSet;
5357
5358 friend std::error_code
5359 parseConfiguration(llvm::MemoryBufferRef Config, FormatStyle *Style,
5360 bool AllowUnknownOptions,
5361 llvm::SourceMgr::DiagHandlerTy DiagHandler,
5362 void *DiagHandlerCtxt);
5363};
5364
5365/// Returns a format style complying with the LLVM coding standards:
5366/// http://llvm.org/docs/CodingStandards.html.
5369
5370/// Returns a format style complying with one of Google's style guides:
5371/// http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml.
5372/// http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml.
5373/// https://developers.google.com/protocol-buffers/docs/style.
5375
5376/// Returns a format style complying with Chromium's style guide:
5377/// http://www.chromium.org/developers/coding-style.
5379
5380/// Returns a format style complying with Mozilla's style guide:
5381/// https://firefox-source-docs.mozilla.org/code-quality/coding-style/index.html.
5383
5384/// Returns a format style complying with Webkit's style guide:
5385/// http://www.webkit.org/coding/coding-style.html
5387
5388/// Returns a format style complying with GNU Coding Standards:
5389/// http://www.gnu.org/prep/standards/standards.html
5391
5392/// Returns a format style complying with Microsoft style guide:
5393/// https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference?view=vs-2017
5395
5397
5398/// Returns style indicating formatting should be not applied at all.
5400
5401/// Gets a predefined style for the specified language by name.
5402///
5403/// Currently supported names: LLVM, Google, Chromium, Mozilla. Names are
5404/// compared case-insensitively.
5405///
5406/// Returns ``true`` if the Style has been set.
5408 FormatStyle *Style);
5409
5410/// Parse configuration from YAML-formatted text.
5411///
5412/// Style->Language is used to get the base style, if the ``BasedOnStyle``
5413/// option is present.
5414///
5415/// The FormatStyleSet of Style is reset.
5416///
5417/// When ``BasedOnStyle`` is not present, options not present in the YAML
5418/// document, are retained in \p Style.
5419///
5420/// If AllowUnknownOptions is true, no errors are emitted if unknown
5421/// format options are occurred.
5422///
5423/// If set all diagnostics are emitted through the DiagHandler.
5424std::error_code
5425parseConfiguration(llvm::MemoryBufferRef Config, FormatStyle *Style,
5426 bool AllowUnknownOptions = false,
5427 llvm::SourceMgr::DiagHandlerTy DiagHandler = nullptr,
5428 void *DiagHandlerCtx = nullptr);
5429
5430/// Like above but accepts an unnamed buffer.
5431inline std::error_code parseConfiguration(StringRef Config, FormatStyle *Style,
5432 bool AllowUnknownOptions = false) {
5433 return parseConfiguration(llvm::MemoryBufferRef(Config, "YAML"), Style,
5434 AllowUnknownOptions);
5435}
5436
5437/// Gets configuration in a YAML string.
5438std::string configurationAsText(const FormatStyle &Style);
5439
5440/// Returns the replacements necessary to sort all ``#include`` blocks
5441/// that are affected by ``Ranges``.
5442tooling::Replacements sortIncludes(const FormatStyle &Style, StringRef Code,
5444 StringRef FileName,
5445 unsigned *Cursor = nullptr);
5446
5447/// Returns the replacements corresponding to applying and formatting
5448/// \p Replaces on success; otheriwse, return an llvm::Error carrying
5449/// llvm::StringError.
5451formatReplacements(StringRef Code, const tooling::Replacements &Replaces,
5452 const FormatStyle &Style);
5453
5454/// Returns the replacements corresponding to applying \p Replaces and
5455/// cleaning up the code after that on success; otherwise, return an llvm::Error
5456/// carrying llvm::StringError.
5457/// This also supports inserting/deleting C++ #include directives:
5458/// * If a replacement has offset UINT_MAX, length 0, and a replacement text
5459/// that is an #include directive, this will insert the #include into the
5460/// correct block in the \p Code.
5461/// * If a replacement has offset UINT_MAX, length 1, and a replacement text
5462/// that is the name of the header to be removed, the header will be removed
5463/// from \p Code if it exists.
5464/// The include manipulation is done via ``tooling::HeaderInclude``, see its
5465/// documentation for more details on how include insertion points are found and
5466/// what edits are produced.
5468cleanupAroundReplacements(StringRef Code, const tooling::Replacements &Replaces,
5469 const FormatStyle &Style);
5470
5471/// Represents the status of a formatting attempt.
5473 /// A value of ``false`` means that any of the affected ranges were not
5474 /// formatted due to a non-recoverable syntax error.
5475 bool FormatComplete = true;
5476
5477 /// If ``FormatComplete`` is false, ``Line`` records a one-based
5478 /// original line number at which a syntax error might have occurred. This is
5479 /// based on a best-effort analysis and could be imprecise.
5480 unsigned Line = 0;
5481};
5482
5483/// Reformats the given \p Ranges in \p Code.
5484///
5485/// Each range is extended on either end to its next bigger logic unit, i.e.
5486/// everything that might influence its formatting or might be influenced by its
5487/// formatting.
5488///
5489/// Returns the ``Replacements`` necessary to make all \p Ranges comply with
5490/// \p Style.
5491///
5492/// If ``Status`` is non-null, its value will be populated with the status of
5493/// this formatting attempt. See \c FormattingAttemptStatus.
5494tooling::Replacements reformat(const FormatStyle &Style, StringRef Code,
5496 StringRef FileName = "<stdin>",
5497 FormattingAttemptStatus *Status = nullptr);
5498
5499/// Same as above, except if ``IncompleteFormat`` is non-null, its value
5500/// will be set to true if any of the affected ranges were not formatted due to
5501/// a non-recoverable syntax error.
5502tooling::Replacements reformat(const FormatStyle &Style, StringRef Code,
5504 StringRef FileName, bool *IncompleteFormat);
5505
5506/// Clean up any erroneous/redundant code in the given \p Ranges in \p
5507/// Code.
5508///
5509/// Returns the ``Replacements`` that clean up all \p Ranges in \p Code.
5510tooling::Replacements cleanup(const FormatStyle &Style, StringRef Code,
5512 StringRef FileName = "<stdin>");
5513
5514/// Fix namespace end comments in the given \p Ranges in \p Code.
5515///
5516/// Returns the ``Replacements`` that fix the namespace comments in all
5517/// \p Ranges in \p Code.
5519 StringRef Code,
5521 StringRef FileName = "<stdin>");
5522
5523/// Inserts or removes empty lines separating definition blocks including
5524/// classes, structs, functions, namespaces, and enums in the given \p Ranges in
5525/// \p Code.
5526///
5527/// Returns the ``Replacements`` that inserts or removes empty lines separating
5528/// definition blocks in all \p Ranges in \p Code.
5530 StringRef Code,
5532 StringRef FileName = "<stdin>");
5533
5534/// Sort consecutive using declarations in the given \p Ranges in
5535/// \p Code.
5536///
5537/// Returns the ``Replacements`` that sort the using declarations in all
5538/// \p Ranges in \p Code.
5540 StringRef Code,
5542 StringRef FileName = "<stdin>");
5543
5544/// Returns the ``LangOpts`` that the formatter expects you to set.
5545///
5546/// \param Style determines specific settings for lexing mode.
5548
5549/// Description to be used for help text for a ``llvm::cl`` option for
5550/// specifying format style. The description is closely related to the operation
5551/// of ``getStyle()``.
5552extern const char *StyleOptionHelpDescription;
5553
5554/// The suggested format style to use by default. This allows tools using
5555/// ``getStyle`` to have a consistent default style.
5556/// Different builds can modify the value to the preferred styles.
5557extern const char *DefaultFormatStyle;
5558
5559/// The suggested predefined style to use as the fallback style in ``getStyle``.
5560/// Different builds can modify the value to the preferred styles.
5561extern const char *DefaultFallbackStyle;
5562
5563/// Construct a FormatStyle based on ``StyleName``.
5564///
5565/// ``StyleName`` can take several forms:
5566/// * "{<key>: <value>, ...}" - Set specic style parameters.
5567/// * "<style name>" - One of the style names supported by getPredefinedStyle().
5568/// * "file" - Load style configuration from a file called ``.clang-format``
5569/// located in one of the parent directories of ``FileName`` or the current
5570/// directory if ``FileName`` is empty.
5571/// * "file:<format_file_path>" to explicitly specify the configuration file to
5572/// use.
5573///
5574/// \param[in] StyleName Style name to interpret according to the description
5575/// above.
5576/// \param[in] FileName Path to start search for .clang-format if ``StyleName``
5577/// == "file".
5578/// \param[in] FallbackStyle The name of a predefined style used to fallback to
5579/// in case \p StyleName is "file" and no file can be found.
5580/// \param[in] Code The actual code to be formatted. Used to determine the
5581/// language if the filename isn't sufficient.
5582/// \param[in] FS The underlying file system, in which the file resides. By
5583/// default, the file system is the real file system.
5584/// \param[in] AllowUnknownOptions If true, unknown format options only
5585/// emit a warning. If false, errors are emitted on unknown format
5586/// options.
5587///
5588/// \returns FormatStyle as specified by ``StyleName``. If ``StyleName`` is
5589/// "file" and no file is found, returns ``FallbackStyle``. If no style could be
5590/// determined, returns an Error.
5592getStyle(StringRef StyleName, StringRef FileName, StringRef FallbackStyle,
5593 StringRef Code = "", llvm::vfs::FileSystem *FS = nullptr,
5594 bool AllowUnknownOptions = false,
5595 llvm::SourceMgr::DiagHandlerTy DiagHandler = nullptr);
5596
5597// Guesses the language from the ``FileName`` and ``Code`` to be formatted.
5598// Defaults to FormatStyle::LK_Cpp.
5599FormatStyle::LanguageKind guessLanguage(StringRef FileName, StringRef Code);
5600
5601// Returns a string representation of ``Language``.
5603 switch (Language) {
5605 return "C++";
5607 return "CSharp";
5609 return "Objective-C";
5611 return "Java";
5613 return "JavaScript";
5615 return "Json";
5617 return "Proto";
5619 return "TableGen";
5621 return "TextProto";
5623 return "Verilog";
5624 default:
5625 return "Unknown";
5626 }
5627}
5628
5629bool isClangFormatOn(StringRef Comment);
5630bool isClangFormatOff(StringRef Comment);
5631
5632} // end namespace format
5633} // end namespace clang
5634
5635template <>
5636struct std::is_error_code_enum<clang::format::ParseError> : std::true_type {};
5637
5638#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:1295
std::string message(int EV) const override
Definition: Format.cpp:1299
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:3943
const char * DefaultFallbackStyle
The suggested predefined style to use as the fallback style in getStyle.
Definition: Format.cpp:4019
FormatStyle getWebKitStyle()
Returns a format style complying with Webkit's style guide: http://www.webkit.org/coding/coding-style...
Definition: Format.cpp:1901
std::error_code make_error_code(ParseError e)
Definition: Format.cpp:1286
FormatStyle getClangFormatStyle()
Definition: Format.cpp:1969
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:1453
FormatStyle getGoogleStyle(FormatStyle::LanguageKind Language)
Returns a format style complying with one of Google's style guides: http://google-styleguide....
Definition: Format.cpp:1673
std::string configurationAsText(const FormatStyle &Style)
Gets configuration in a YAML string.
Definition: Format.cpp:2118
FormatStyle getMicrosoftStyle(FormatStyle::LanguageKind Language)
Returns a format style complying with Microsoft style guide: https://docs.microsoft....
Definition: Format.cpp:1940
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:2052
const std::error_category & getParseCategory()
Definition: Format.cpp:1282
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:3894
FormatStyle::LanguageKind guessLanguage(StringRef FileName, StringRef Code)
Definition: Format.cpp:3998
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:4036
const char * DefaultFormatStyle
The suggested format style to use by default.
Definition: Format.cpp:4017
FormatStyle getGNUStyle()
Returns a format style complying with GNU Coding Standards: http://www.gnu.org/prep/standards/standar...
Definition: Format.cpp:1925
bool isClangFormatOff(StringRef Comment)
Definition: Format.cpp:4219
LangOptions getFormattingLangOpts(const FormatStyle &Style=getLLVMStyle())
Returns the LangOpts that the formatter expects you to set.
Definition: Format.cpp:3914
FormatStyle getMozillaStyle()
Returns a format style complying with Mozilla's style guide: https://firefox-source-docs....
Definition: Format.cpp:1875
bool getPredefinedStyle(StringRef Name, FormatStyle::LanguageKind Language, FormatStyle *Style)
Gets a predefined style for the specified language by name.
Definition: Format.cpp:1991
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:3658
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:3861
bool isClangFormatOn(StringRef Comment)
Definition: Format.cpp:4215
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:3904
FormatStyle getChromiumStyle(FormatStyle::LanguageKind Language)
Returns a format style complying with Chromium's style guide: http://www.chromium....
Definition: Format.cpp:1815
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:3872
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:3548
FormatStyle getNoStyle()
Returns style indicating formatting should be not applied at all.
Definition: Format.cpp:1983
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:3507
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:5602
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:5333
std::optional< FormatStyle > Get(FormatStyle::LanguageKind Language) const
Definition: Format.cpp:2134
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:3775
std::string CanonicalDelimiter
The canonical delimiter for this language.
Definition: Format.h:3783
LanguageKind Language
The language of this raw string.
Definition: Format.h:3777
std::string BasedOnStyle
The style name on which this raw string format is based on.
Definition: Format.h:3787
std::vector< std::string > EnclosingFunctions
A list of enclosing function names that match this language.
Definition: Format.h:3781
bool operator==(const RawStringFormat &Other) const
Definition: Format.h:3788
std::vector< std::string > Delimiters
A list of raw string delimiters that match this language.
Definition: Format.h:3779
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:4531
bool AfterControlStatements
If true, put space between control statement keywords (for/if/while...) and opening parentheses.
Definition: Format.h:4538
bool AfterOverloadedOperator
If true, put a space between operator overloading and opening parentheses.
Definition: Format.h:4574
bool AfterRequiresInExpression
If true, put space between requires keyword in a requires expression and opening parentheses.
Definition: Format.h:4601
bool AfterFunctionDeclarationName
If true, put a space between function declaration name and opening parentheses.
Definition: Format.h:4552
bool AfterRequiresInClause
If true, put space between requires keyword in a requires clause and opening parentheses,...
Definition: Format.h:4591
bool AfterForeachMacros
If true, put space between foreach macros and opening parentheses.
Definition: Format.h:4545
bool AfterFunctionDefinitionName
If true, put a space between function definition name and opening parentheses.
Definition: Format.h:4559
bool BeforeNonEmptyParentheses
If true, put a space before opening parentheses only if the parentheses are not empty.
Definition: Format.h:4609
bool operator==(const SpaceBeforeParensCustom &Other) const
Definition: Format.h:4619
bool AfterIfMacros
If true, put space between if macros and opening parentheses.
Definition: Format.h:4566
bool AfterPlacementOperator
If true, put a space between operator new/delete and opening parenthesis.
Definition: Format.h:4582
If true, spaces may be inserted into C style casts.
Definition: Format.h:4751
unsigned Maximum
The maximum number of spaces at the start of the comment.
Definition: Format.h:4755
unsigned Minimum
The minimum number of spaces at the start of the comment.
Definition: Format.h:4753
Precise control over the spacing in parentheses.
Definition: Format.h:4830
bool operator==(const SpacesInParensCustom &R) const
Definition: Format.h:4887
bool ExceptDoubleParentheses
Override any of the following options to prevent addition of space when both opening and closing pare...
Definition: Format.h:4841
bool Other
Put a space in parentheses not covered by preceding options.
Definition: Format.h:4873
bool InEmptyParentheses
Insert a space in empty parentheses, i.e.
Definition: Format.h:4867
bool InCStyleCasts
Put a space in C style casts.
Definition: Format.h:4856
bool operator!=(const SpacesInParensCustom &R) const
Definition: Format.h:4893
bool InConditionalStatements
Put a space in parentheses only inside conditional statements (for/if/while/switch....
Definition: Format.h:4849
SpacesInParensCustom(bool ExceptDoubleParentheses, bool InConditionalStatements, bool InCStyleCasts, bool InEmptyParentheses, bool Other)
Definition: Format.h:4879
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:5086
@ UT_AlignWithSpaces
Use tabs for line continuation and indentation, and spaces for alignment.
Definition: Format.h:5096
@ UT_ForContinuationAndIndentation
Fill all leading whitespace with tabs, and use spaces for alignment that appears within a line (e....
Definition: Format.h:5093
@ UT_ForIndentation
Use tabs only for indentation.
Definition: Format.h:5090
@ 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:5099
@ UT_Never
Never use tab.
Definition: Format.h:5088
bool SpaceBeforeInheritanceColon
If false, spaces will be removed before inheritance colon.
Definition: Format.h:4449
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:4958
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:3296
LanguageKind
Supported languages.
Definition: Format.h:3260
@ LK_CSharp
Should be used for C#.
Definition: Format.h:3266
@ LK_None
Do not use.
Definition: Format.h:3262
@ LK_Java
Should be used for Java.
Definition: Format.h:3268
@ LK_Cpp
Should be used for C, C++.
Definition: Format.h:3264
@ LK_JavaScript
Should be used for JavaScript.
Definition: Format.h:3270
@ LK_ObjC
Should be used for Objective-C, Objective-C++.
Definition: Format.h:3274
@ LK_Verilog
Should be used for Verilog and SystemVerilog.
Definition: Format.h:3286
@ LK_TableGen
Should be used for TableGen code.
Definition: Format.h:3279
@ LK_Proto
Should be used for Protocol Buffers (https://developers.google.com/protocol-buffers/).
Definition: Format.h:3277
@ LK_Json
Should be used for JSON.
Definition: Format.h:3272
@ LK_TextProto
Should be used for Protocol Buffer messages in text format (https://developers.google....
Definition: Format.h:3282
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:4276
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:4160
@ SDS_Never
Remove any empty line between definition blocks.
Definition: Format.h:4166
@ SDS_Always
Insert an empty line between definition blocks.
Definition: Format.h:4164
@ SDS_Leave
Leave definition blocks as they are.
Definition: Format.h:4162
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:4724
bool KeepFormFeed
This option is deprecated.
Definition: Format.h:3219
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:3832
SortJavaStaticImportOptions
Position for Java Static imports.
Definition: Format.h:4279
@ SJSIO_Before
Static imports are placed before non-static imports.
Definition: Format.h:4286
@ SJSIO_After
Static imports are placed after non-static imports.
Definition: Format.h:4293
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:4027
std::vector< std::string > Macros
A list of macros of the form <definition>=<expansion> .
Definition: Format.h:3389
bool SpaceBeforeJsonColon
If true, a space will be added before a JSON colon.
Definition: Format.h:4460
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:3625
bool SpaceBeforeCtorInitializerColon
If false, spaces will be removed before constructor initializer colon.
Definition: Format.h:4441
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:4244
@ SI_Never
Includes are never sorted.
Definition: Format.h:4253
@ SI_CaseSensitive
Includes are sorted in an ASCIIbetical or case sensitive fashion.
Definition: Format.h:4262
@ SI_CaseInsensitive
Includes are sorted in an alphabetical or case insensitive fashion.
Definition: Format.h:4271
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:3862
@ RCS_IndentOnly
Only apply indentation rules, moving comments left or right, without changing formatting inside the c...
Definition: Format.h:3879
@ RCS_Never
Leave comments untouched.
Definition: Format.h:3870
@ RCS_Always
Apply indentation rules and reflow long comments into new lines, trying to obey the ColumnLimit.
Definition: Format.h:3890
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:4701
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:3303
@ LE_DeriveLF
Use \n unless the input has more lines ending in \r\n.
Definition: Format.h:3309
@ LE_DeriveCRLF
Use \r\n unless the input has more lines ending in \n.
Definition: Format.h:3311
bool SpacesInSquareBrackets
If true, spaces will be inserted after [ and before ].
Definition: Format.h:4923
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
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:3555
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:4009
std::string MacroBlockBegin
A regular expression matching macros that start a block.
Definition: Format.h:3345
bool SpaceInEmptyBlock
If true, spaces will be inserted into {}.
Definition: Format.h:4675
LanguageKind Language
Language, this format style is targeted at.
Definition: Format.h:3300
SpacesInParensStyle
Different ways to put a space before opening and closing parentheses.
Definition: Format.h:4793
@ SIPO_Custom
Configure each individual space in parentheses in SpacesInParensOptions.
Definition: Format.h:4805
@ SIPO_Never
Never put a space in parentheses.
Definition: Format.h:4802
bool RemoveBracesLLVM
Remove optional braces of control statements (if, else, for, and while) in C++ according to the LLVM ...
Definition: Format.h:3950
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:5118
unsigned TabWidth
The number of columns used for tab stops.
Definition: Format.h:5043
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:3222
@ LBI_OuterScope
For statements within block scope, align lambda body relative to the indentation level of the outer s...
Definition: Format.h:3244
@ LBI_Signature
Align lambda body relative to the lambda signature.
Definition: Format.h:3230
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:3633
std::vector< std::string > StatementAttributeLikeMacros
Macros which are ignored in front of a statement, as if they were an attribute.
Definition: Format.h:4975
unsigned ObjCBlockIndentWidth
The number of characters to use for indentation of ObjC blocks.
Definition: Format.h:3498
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:3772
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:2159
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:3441
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:3545
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:3522
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:3637
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:2052
SpacesInParensStyle SpacesInParens
If true, spaces will be inserted after ( and before ).
Definition: Format.h:4819
SpacesInParensCustom SpacesInParensOptions
Control of individual spaces in parentheses.
Definition: Format.h:4912
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:3858
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:3649
SpaceBeforeParensCustom SpaceBeforeParensOptions
Control of individual space before parentheses.
Definition: Format.h:4647
BreakConstructorInitializersStyle BreakConstructorInitializers
The break constructor initializers style to use.
Definition: Format.h:2333
bool RemoveEmptyLinesInUnwrappedLines
Remove empty lines within unwrapped lines.
Definition: Format.h:3973
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:4360
SpaceBeforeParensStyle
Different ways to put a space before opening parentheses.
Definition: Format.h:4463
@ SBPO_Never
This is deprecated and replaced by Custom below, with all SpaceBeforeParensOptions but AfterPlacement...
Definition: Format.h:4467
@ SBPO_Custom
Configure each individual space before parentheses in SpaceBeforeParensOptions.
Definition: Format.h:4516
@ SBPO_NonEmptyParentheses
Put a space before opening parentheses only if the parentheses are not empty.
Definition: Format.h:4501
@ SBPO_ControlStatementsExceptControlMacros
Same as SBPO_ControlStatements except this option doesn't apply to ForEach and If macros.
Definition: Format.h:4490
@ SBPO_ControlStatements
Put a space before opening parentheses only after control statement keywords (for/if/while....
Definition: Format.h:4477
@ SBPO_Always
Always put a space before opening parentheses, except when it's prohibited by the syntax rules (in fu...
Definition: Format.h:4513
PackConstructorInitializersStyle
Different ways to try to fit all constructor initializers on a line.
Definition: Format.h:3558
@ PCIS_NextLineOnly
Put all constructor initializers on the next line if they fit.
Definition: Format.h:3612
@ PCIS_Never
Always put each constructor initializer on its own line.
Definition: Format.h:3565
@ PCIS_CurrentLine
Put all constructor initializers on the current line if they fit.
Definition: Format.h:3583
@ PCIS_BinPack
Bin-pack constructor initializers.
Definition: Format.h:3572
@ PCIS_NextLine
Same as PCIS_CurrentLine except that if all constructor initializers do not fit on the current line,...
Definition: Format.h:3597
std::vector< std::string > TypeNames
A vector of non-keyword identifiers that should be interpreted as type names.
Definition: Format.h:5062
bool ObjCSpaceAfterProperty
Add a space after @property in Objective-C, i.e.
Definition: Format.h:3550
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:3289
unsigned PenaltyExcessCharacter
The penalty for each character outside of the column limit.
Definition: Format.h:3653
std::vector< std::string > WhitespaceSensitiveMacros
A vector of macros which are whitespace-sensitive and should not be touched.
Definition: Format.h:5135
std::vector< std::string > TemplateNames
A vector of non-keyword identifiers that should be interpreted as template names.
Definition: Format.h:5052
DAGArgStyle
Different ways to control the format inside TableGen DAGArg.
Definition: Format.h:5014
@ DAS_BreakElements
Break inside DAGArg after each list element but for the last.
Definition: Format.h:5026
@ DAS_DontBreak
Never break inside DAGArg.
Definition: Format.h:5019
@ DAS_BreakAll
Break inside DAGArg after the operator and the all elements.
Definition: Format.h:5034
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:4032
@ RCPS_OwnLineWithBrace
As with OwnLine, except, unless otherwise prohibited, place a following open brace (of a function def...
Definition: Format.h:4071
@ RCPS_OwnLine
Always put the requires clause on its own line (possibly followed by a semicolon).
Definition: Format.h:4053
@ RCPS_WithPreceding
Try to put the clause together with the preceding part of a declaration.
Definition: Format.h:4088
@ RCPS_SingleLine
Try to put everything in the same line if possible.
Definition: Format.h:4126
@ RCPS_WithFollowing
Try to put the requires clause together with the class or function declaration.
Definition: Format.h:4102
bool operator==(const FormatStyle &R) const
Definition: Format.h:5137
LanguageStandard
Supported language standards for parsing and formatting C++ constructs.
Definition: Format.h:4933
@ LS_Cpp17
Parse and format as C++17.
Definition: Format.h:4942
@ LS_Latest
Parse and format using the latest supported language version.
Definition: Format.h:4947
@ LS_Cpp11
Parse and format as C++11.
Definition: Format.h:4938
@ LS_Auto
Automatic detection based on the input.
Definition: Format.h:4949
@ LS_Cpp03
Parse and format as C++03.
Definition: Format.h:4936
@ LS_Cpp14
Parse and format as C++14.
Definition: Format.h:4940
@ LS_Cpp20
Parse and format as C++20.
Definition: Format.h:4944
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:4131
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:4352
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:3700
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:4401
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:4410
BreakBeforeInlineASMColonStyle BreakBeforeInlineASMColon
The inline ASM colon style to use.
Definition: Format.h:2253
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:3641
unsigned PenaltyReturnTypeOnItsOwnLine
Penalty for putting the return type of a function onto its own line.
Definition: Format.h:3662
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:3685
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:4134
@ REI_Keyword
Align requires expression body relative to the requires keyword.
Definition: Format.h:4152
@ REI_OuterScope
Align requires expression body relative to the indentation level of the outer scope the requires expr...
Definition: Format.h:4144
PackConstructorInitializersStyle PackConstructorInitializers
The pack constructor initializers style to use.
Definition: Format.h:3617
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:3896
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:3293
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:3403
bool SpaceBeforeSquareBrackets
If true, spaces will be before [.
Definition: Format.h:4657
BinPackStyle ObjCBinPackProtocolList
Controls bin-packing Objective-C protocol conformance list items into as few lines as possible when t...
Definition: Format.h:3487
bool isVerilog() const
Definition: Format.h:3292
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:4790
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:3291
DAGArgStyle TableGenBreakInsideDAGArg
The styles of the line break inside the DAGArg in TableGen.
Definition: Format.h:5039
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:4742
SortJavaStaticImportOptions SortJavaStaticImport
When sorting Java imports, by default static imports are placed before non-static imports.
Definition: Format.h:4300
SpaceAroundPointerQualifiersStyle
Different ways to put a space before opening parentheses.
Definition: Format.h:4371
@ SAPQ_After
Ensure that there is a space after pointer qualifiers.
Definition: Format.h:4390
@ SAPQ_Default
Don't ensure spaces around pointer qualifiers and use PointerAlignment instead.
Definition: Format.h:4378
@ SAPQ_Both
Ensure that there is a space both before and after pointer qualifiers.
Definition: Format.h:4396
@ SAPQ_Before
Ensure that there is a space before pointer qualifiers.
Definition: Format.h:4384
bool SpaceBeforeRangeBasedForLoopColon
If false, spaces will be removed before range-based for loop colon.
Definition: Format.h:4666
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:3454
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:3253
QualifierAlignmentStyle QualifierAlignment
Different ways to arrange specifiers and qualifiers (e.g.
Definition: Format.h:3746
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:4985
SpacesInAnglesStyle
Styles for adding spacing after < and before > in template argument lists.
Definition: Format.h:4705
@ SIAS_Never
Remove spaces after < and before >.
Definition: Format.h:4711
@ SIAS_Always
Add spaces after < and before >.
Definition: Format.h:4717
@ SIAS_Leave
Keep a single space after < and before > if any spaces were present.
Definition: Format.h:4720
SortUsingDeclarationsOptions
Using declaration sorting options.
Definition: Format.h:4303
@ SUD_LexicographicNumeric
Using declarations are sorted in the order defined as follows: Split the strings by :: and discard an...
Definition: Format.h:4339
@ SUD_Lexicographic
Using declarations are sorted in the order defined as follows: Split the strings by :: and discard an...
Definition: Format.h:4324
@ SUD_Never
Using declarations are never sorted.
Definition: Format.h:4312
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:3976
@ RPS_Leave
Do not remove parentheses.
Definition: Format.h:3983
@ RPS_ReturnStatement
Also remove parentheses enclosing the expression in a return/co_return statement.
Definition: Format.h:3998
@ RPS_MultipleParentheses
Replace multiple parentheses with single parentheses.
Definition: Format.h:3990
std::vector< std::string > TableGenBreakingDAGArgOperators
Works only when TableGenBreakInsideDAGArg is not DontBreak.
Definition: Format.h:5011
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:4420
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:4241
unsigned PenaltyBreakAssignment
The penalty for breaking around an assignment operator.
Definition: Format.h:3621
PointerAlignmentStyle
The &, && and * alignment style.
Definition: Format.h:3665
@ PAS_Left
Align pointer to the left.
Definition: Format.h:3670
@ PAS_Middle
Align pointer in the middle.
Definition: Format.h:3680
@ PAS_Right
Align pointer to the right.
Definition: Format.h:3675
unsigned PenaltyBreakString
The penalty for each line break introduced inside a string literal.
Definition: Format.h:3645
RequiresExpressionIndentationKind RequiresExpressionIndentation
The indentation used for requires expression bodies.
Definition: Format.h:4157
bool SpaceAfterTemplateKeyword
If true, a space will be inserted after the template keyword.
Definition: Format.h:4368
unsigned PenaltyIndentedWhitespace
Penalty for each character of whitespace indentation (counted relative to leading non-whitespace colu...
Definition: Format.h:3658
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:3406
@ NI_None
Don't indent in namespaces.
Definition: Format.h:3416
@ NI_All
Indent in all namespaces.
Definition: Format.h:3436
@ NI_Inner
Indent only in inner namespaces (nested in other namespaces).
Definition: Format.h:3426
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:3349
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:3629
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:3835
@ RAS_Right
Align reference to the right.
Definition: Format.h:3847
@ RAS_Left
Align reference to the left.
Definition: Format.h:3842
@ RAS_Pointer
Align reference like PointerAlignment.
Definition: Format.h:3837
@ RAS_Middle
Align reference in the middle.
Definition: Format.h:3852
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:4521
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:4432
UseTabStyle UseTab
The way to use tab characters in the resulting file.
Definition: Format.h:5104
QualifierAlignmentStyle
Different specifiers and qualifiers alignment styles.
Definition: Format.h:3703
@ QAS_Right
Change specifiers/qualifiers to be right-aligned.
Definition: Format.h:3722
@ QAS_Custom
Change specifiers/qualifiers to be aligned based on QualifierOrder.
Definition: Format.h:3734
@ QAS_Left
Change specifiers/qualifiers to be left-aligned.
Definition: Format.h:3716
@ QAS_Leave
Don't change specifiers/qualifiers to either Left or Right alignment (default).
Definition: Format.h:3710
std::vector< std::string > TypenameMacros
A vector of macros that should be interpreted as type declarations instead of as function calls.
Definition: Format.h:5079
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:3316
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:4237
SortUsingDeclarationsOptions SortUsingDeclarations
Controls if and how clang-format will sort using declarations.
Definition: Format.h:4344
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:4215
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:5472
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:5475
unsigned Line
If FormatComplete is false, Line records a one-based original line number at which a syntax error mig...
Definition: Format.h:5480
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