clang  6.0.0svn
Format.h
Go to the documentation of this file.
1 //===--- Format.h - Format C++ code -----------------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 ///
10 /// \file
11 /// Various functions to configurably format source code.
12 ///
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_CLANG_FORMAT_FORMAT_H
16 #define LLVM_CLANG_FORMAT_FORMAT_H
17 
20 #include "llvm/ADT/ArrayRef.h"
21 #include <system_error>
22 
23 namespace clang {
24 
25 class Lexer;
26 class SourceManager;
27 class DiagnosticConsumer;
28 
29 namespace vfs {
30 class FileSystem;
31 }
32 
33 namespace format {
34 
35 enum class ParseError { Success = 0, Error, Unsuitable };
36 class ParseErrorCategory final : public std::error_category {
37 public:
38  const char *name() const noexcept override;
39  std::string message(int EV) const override;
40 };
41 const std::error_category &getParseCategory();
42 std::error_code make_error_code(ParseError e);
43 
44 /// \brief The ``FormatStyle`` is used to configure the formatting to follow
45 /// specific guidelines.
46 struct FormatStyle {
47  /// \brief The extra indent or outdent of access modifiers, e.g. ``public:``.
49 
50  /// \brief Different styles for aligning after open brackets.
52  /// \brief Align parameters on the open bracket, e.g.:
53  /// \code
54  /// someLongFunction(argument1,
55  /// argument2);
56  /// \endcode
58  /// \brief Don't align, instead use ``ContinuationIndentWidth``, e.g.:
59  /// \code
60  /// someLongFunction(argument1,
61  /// argument2);
62  /// \endcode
64  /// \brief Always break after an open bracket, if the parameters don't fit
65  /// on a single line, e.g.:
66  /// \code
67  /// someLongFunction(
68  /// argument1, argument2);
69  /// \endcode
71  };
72 
73  /// \brief If ``true``, horizontally aligns arguments after an open bracket.
74  ///
75  /// This applies to round brackets (parentheses), angle brackets and square
76  /// brackets.
78 
79  /// \brief If ``true``, aligns consecutive assignments.
80  ///
81  /// This will align the assignment operators of consecutive lines. This
82  /// will result in formattings like
83  /// \code
84  /// int aaaa = 12;
85  /// int b = 23;
86  /// int ccc = 23;
87  /// \endcode
89 
90  /// \brief If ``true``, aligns consecutive declarations.
91  ///
92  /// This will align the declaration names of consecutive lines. This
93  /// will result in formattings like
94  /// \code
95  /// int aaaa = 12;
96  /// float b = 23;
97  /// std::string ccc = 23;
98  /// \endcode
100 
101  /// \brief Different styles for aligning escaped newlines.
103  /// \brief Don't align escaped newlines.
104  /// \code
105  /// #define A \
106  /// int aaaa; \
107  /// int b; \
108  /// int dddddddddd;
109  /// \endcode
111  /// \brief Align escaped newlines as far left as possible.
112  /// \code
113  /// true:
114  /// #define A \
115  /// int aaaa; \
116  /// int b; \
117  /// int dddddddddd;
118  ///
119  /// false:
120  /// \endcode
122  /// \brief Align escaped newlines in the right-most column.
123  /// \code
124  /// #define A \
125  /// int aaaa; \
126  /// int b; \
127  /// int dddddddddd;
128  /// \endcode
130  };
131 
132  /// \brief Options for aligning backslashes in escaped newlines.
134 
135  /// \brief If ``true``, horizontally align operands of binary and ternary
136  /// expressions.
137  ///
138  /// Specifically, this aligns operands of a single expression that needs to be
139  /// split over multiple lines, e.g.:
140  /// \code
141  /// int aaa = bbbbbbbbbbbbbbb +
142  /// ccccccccccccccc;
143  /// \endcode
145 
146  /// \brief If ``true``, aligns trailing comments.
147  /// \code
148  /// true: false:
149  /// int a; // My comment a vs. int a; // My comment a
150  /// int b = 2; // comment b int b = 2; // comment about b
151  /// \endcode
153 
154  /// \brief If the function declaration doesn't fit on a line,
155  /// allow putting all parameters of a function declaration onto
156  /// the next line even if ``BinPackParameters`` is ``false``.
157  /// \code
158  /// true:
159  /// void myFunction(
160  /// int a, int b, int c, int d, int e);
161  ///
162  /// false:
163  /// void myFunction(int a,
164  /// int b,
165  /// int c,
166  /// int d,
167  /// int e);
168  /// \endcode
170 
171  /// \brief Allows contracting simple braced statements to a single line.
172  ///
173  /// E.g., this allows ``if (a) { return; }`` to be put on a single line.
175 
176  /// \brief If ``true``, short case labels will be contracted to a single line.
177  /// \code
178  /// true: false:
179  /// switch (a) { vs. switch (a) {
180  /// case 1: x = 1; break; case 1:
181  /// case 2: return; x = 1;
182  /// } break;
183  /// case 2:
184  /// return;
185  /// }
186  /// \endcode
188 
189  /// \brief Different styles for merging short functions containing at most one
190  /// statement.
192  /// \brief Never merge functions into a single line.
194  /// \brief Only merge functions defined inside a class. Same as "inline",
195  /// except it does not implies "empty": i.e. top level empty functions
196  /// are not merged either.
197  /// \code
198  /// class Foo {
199  /// void f() { foo(); }
200  /// };
201  /// void f() {
202  /// foo();
203  /// }
204  /// void f() {
205  /// }
206  /// \endcode
208  /// \brief Only merge empty functions.
209  /// \code
210  /// void f() {}
211  /// void f2() {
212  /// bar2();
213  /// }
214  /// \endcode
216  /// \brief Only merge functions defined inside a class. Implies "empty".
217  /// \code
218  /// class Foo {
219  /// void f() { foo(); }
220  /// };
221  /// void f() {
222  /// foo();
223  /// }
224  /// void f() {}
225  /// \endcode
227  /// \brief Merge all functions fitting on a single line.
228  /// \code
229  /// class Foo {
230  /// void f() { foo(); }
231  /// };
232  /// void f() { bar(); }
233  /// \endcode
235  };
236 
237  /// \brief Dependent on the value, ``int f() { return 0; }`` can be put on a
238  /// single line.
240 
241  /// \brief If ``true``, ``if (a) return;`` can be put on a single line.
243 
244  /// \brief If ``true``, ``while (true) continue;`` can be put on a single
245  /// line.
247 
248  /// \brief Different ways to break after the function definition return type.
249  /// This option is **deprecated** and is retained for backwards compatibility.
251  /// Break after return type automatically.
252  /// ``PenaltyReturnTypeOnItsOwnLine`` is taken into account.
254  /// Always break after the return type.
256  /// Always break after the return types of top-level functions.
258  };
259 
260  /// \brief Different ways to break after the function definition or
261  /// declaration return type.
263  /// Break after return type automatically.
264  /// ``PenaltyReturnTypeOnItsOwnLine`` is taken into account.
265  /// \code
266  /// class A {
267  /// int f() { return 0; };
268  /// };
269  /// int f();
270  /// int f() { return 1; }
271  /// \endcode
273  /// Always break after the return type.
274  /// \code
275  /// class A {
276  /// int
277  /// f() {
278  /// return 0;
279  /// };
280  /// };
281  /// int
282  /// f();
283  /// int
284  /// f() {
285  /// return 1;
286  /// }
287  /// \endcode
289  /// Always break after the return types of top-level functions.
290  /// \code
291  /// class A {
292  /// int f() { return 0; };
293  /// };
294  /// int
295  /// f();
296  /// int
297  /// f() {
298  /// return 1;
299  /// }
300  /// \endcode
302  /// Always break after the return type of function definitions.
303  /// \code
304  /// class A {
305  /// int
306  /// f() {
307  /// return 0;
308  /// };
309  /// };
310  /// int f();
311  /// int
312  /// f() {
313  /// return 1;
314  /// }
315  /// \endcode
317  /// Always break after the return type of top-level definitions.
318  /// \code
319  /// class A {
320  /// int f() { return 0; };
321  /// };
322  /// int f();
323  /// int
324  /// f() {
325  /// return 1;
326  /// }
327  /// \endcode
329  };
330 
331  /// \brief The function definition return type breaking style to use. This
332  /// option is **deprecated** and is retained for backwards compatibility.
334 
335  /// \brief The function declaration return type breaking style to use.
337 
338  /// \brief If ``true``, always break before multiline string literals.
339  ///
340  /// This flag is mean to make cases where there are multiple multiline strings
341  /// in a file look more consistent. Thus, it will only take effect if wrapping
342  /// the string at that point leads to it being indented
343  /// ``ContinuationIndentWidth`` spaces from the start of the line.
344  /// \code
345  /// true: false:
346  /// aaaa = vs. aaaa = "bbbb"
347  /// "bbbb" "cccc";
348  /// "cccc";
349  /// \endcode
351 
352  /// \brief If ``true``, always break after the ``template<...>`` of a template
353  /// declaration.
354  /// \code
355  /// true: false:
356  /// template <typename T> vs. template <typename T> class C {};
357  /// class C {};
358  /// \endcode
360 
361  /// \brief If ``false``, a function call's arguments will either be all on the
362  /// same line or will have one line each.
363  /// \code
364  /// true:
365  /// void f() {
366  /// f(aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa,
367  /// aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
368  /// }
369  ///
370  /// false:
371  /// void f() {
372  /// f(aaaaaaaaaaaaaaaaaaaa,
373  /// aaaaaaaaaaaaaaaaaaaa,
374  /// aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
375  /// }
376  /// \endcode
378 
379  /// \brief If ``false``, a function declaration's or function definition's
380  /// parameters will either all be on the same line or will have one line each.
381  /// \code
382  /// true:
383  /// void f(int aaaaaaaaaaaaaaaaaaaa, int aaaaaaaaaaaaaaaaaaaa,
384  /// int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}
385  ///
386  /// false:
387  /// void f(int aaaaaaaaaaaaaaaaaaaa,
388  /// int aaaaaaaaaaaaaaaaaaaa,
389  /// int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}
390  /// \endcode
392 
393  /// \brief The style of breaking before or after binary operators.
395  /// Break after operators.
396  /// \code
397  /// LooooooooooongType loooooooooooooooooooooongVariable =
398  /// someLooooooooooooooooongFunction();
399  ///
400  /// bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
401  /// aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ==
402  /// aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &&
403  /// aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa >
404  /// ccccccccccccccccccccccccccccccccccccccccc;
405  /// \endcode
407  /// Break before operators that aren't assignments.
408  /// \code
409  /// LooooooooooongType loooooooooooooooooooooongVariable =
410  /// someLooooooooooooooooongFunction();
411  ///
412  /// bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
413  /// + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
414  /// == aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
415  /// && aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
416  /// > ccccccccccccccccccccccccccccccccccccccccc;
417  /// \endcode
419  /// Break before operators.
420  /// \code
421  /// LooooooooooongType loooooooooooooooooooooongVariable
422  /// = someLooooooooooooooooongFunction();
423  ///
424  /// bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
425  /// + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
426  /// == aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
427  /// && aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
428  /// > ccccccccccccccccccccccccccccccccccccccccc;
429  /// \endcode
431  };
432 
433  /// \brief The way to wrap binary operators.
435 
436  /// \brief Different ways to attach braces to their surrounding context.
438  /// Always attach braces to surrounding context.
439  /// \code
440  /// try {
441  /// foo();
442  /// } catch () {
443  /// }
444  /// void foo() { bar(); }
445  /// class foo {};
446  /// if (foo()) {
447  /// } else {
448  /// }
449  /// enum X : int { A, B };
450  /// \endcode
452  /// Like ``Attach``, but break before braces on function, namespace and
453  /// class definitions.
454  /// \code
455  /// try {
456  /// foo();
457  /// } catch () {
458  /// }
459  /// void foo() { bar(); }
460  /// class foo
461  /// {
462  /// };
463  /// if (foo()) {
464  /// } else {
465  /// }
466  /// enum X : int { A, B };
467  /// \endcode
469  /// Like ``Attach``, but break before braces on enum, function, and record
470  /// definitions.
471  /// \code
472  /// try {
473  /// foo();
474  /// } catch () {
475  /// }
476  /// void foo() { bar(); }
477  /// class foo
478  /// {
479  /// };
480  /// if (foo()) {
481  /// } else {
482  /// }
483  /// enum X : int { A, B };
484  /// \endcode
486  /// Like ``Attach``, but break before function definitions, ``catch``, and
487  /// ``else``.
488  /// \code
489  /// try {
490  /// foo();
491  /// } catch () {
492  /// }
493  /// void foo() { bar(); }
494  /// class foo
495  /// {
496  /// };
497  /// if (foo()) {
498  /// } else {
499  /// }
500  /// enum X : int
501  /// {
502  /// A,
503  /// B
504  /// };
505  /// \endcode
507  /// Always break before braces.
508  /// \code
509  /// try {
510  /// foo();
511  /// }
512  /// catch () {
513  /// }
514  /// void foo() { bar(); }
515  /// class foo {
516  /// };
517  /// if (foo()) {
518  /// }
519  /// else {
520  /// }
521  /// enum X : int { A, B };
522  /// \endcode
524  /// Always break before braces and add an extra level of indentation to
525  /// braces of control statements, not to those of class, function
526  /// or other definitions.
527  /// \code
528  /// try
529  /// {
530  /// foo();
531  /// }
532  /// catch ()
533  /// {
534  /// }
535  /// void foo() { bar(); }
536  /// class foo
537  /// {
538  /// };
539  /// if (foo())
540  /// {
541  /// }
542  /// else
543  /// {
544  /// }
545  /// enum X : int
546  /// {
547  /// A,
548  /// B
549  /// };
550  /// \endcode
552  /// Like ``Attach``, but break before functions.
553  /// \code
554  /// try {
555  /// foo();
556  /// } catch () {
557  /// }
558  /// void foo() { bar(); }
559  /// class foo {
560  /// };
561  /// if (foo()) {
562  /// } else {
563  /// }
564  /// enum X : int { A, B };
565  /// \endcode
567  /// Configure each individual brace in `BraceWrapping`.
568  BS_Custom
569  };
570 
571  /// \brief The brace breaking style to use.
573 
574  /// \brief Precise control over the wrapping of braces.
575  /// \code
576  /// # Should be declared this way:
577  /// BreakBeforeBraces: Custom
578  /// BraceWrapping:
579  /// AfterClass: true
580  /// \endcode
582  /// \brief Wrap class definitions.
583  /// \code
584  /// true:
585  /// class foo {};
586  ///
587  /// false:
588  /// class foo
589  /// {};
590  /// \endcode
592  /// \brief Wrap control statements (``if``/``for``/``while``/``switch``/..).
593  /// \code
594  /// true:
595  /// if (foo())
596  /// {
597  /// } else
598  /// {}
599  /// for (int i = 0; i < 10; ++i)
600  /// {}
601  ///
602  /// false:
603  /// if (foo()) {
604  /// } else {
605  /// }
606  /// for (int i = 0; i < 10; ++i) {
607  /// }
608  /// \endcode
610  /// \brief Wrap enum definitions.
611  /// \code
612  /// true:
613  /// enum X : int
614  /// {
615  /// B
616  /// };
617  ///
618  /// false:
619  /// enum X : int { B };
620  /// \endcode
621  bool AfterEnum;
622  /// \brief Wrap function definitions.
623  /// \code
624  /// true:
625  /// void foo()
626  /// {
627  /// bar();
628  /// bar2();
629  /// }
630  ///
631  /// false:
632  /// void foo() {
633  /// bar();
634  /// bar2();
635  /// }
636  /// \endcode
638  /// \brief Wrap namespace definitions.
639  /// \code
640  /// true:
641  /// namespace
642  /// {
643  /// int foo();
644  /// int bar();
645  /// }
646  ///
647  /// false:
648  /// namespace {
649  /// int foo();
650  /// int bar();
651  /// }
652  /// \endcode
654  /// \brief Wrap ObjC definitions (``@autoreleasepool``, interfaces, ..).
656  /// \brief Wrap struct definitions.
657  /// \code
658  /// true:
659  /// struct foo
660  /// {
661  /// int x;
662  /// };
663  ///
664  /// false:
665  /// struct foo {
666  /// int x;
667  /// };
668  /// \endcode
670  /// \brief Wrap union definitions.
671  /// \code
672  /// true:
673  /// union foo
674  /// {
675  /// int x;
676  /// }
677  ///
678  /// false:
679  /// union foo {
680  /// int x;
681  /// }
682  /// \endcode
684  /// \brief Wrap extern blocks.
685  /// \code
686  /// true:
687  /// extern "C"
688  /// {
689  /// int foo();
690  /// }
691  ///
692  /// false:
693  /// extern "C" {
694  /// int foo();
695  /// }
696  /// \endcode
698  /// \brief Wrap before ``catch``.
699  /// \code
700  /// true:
701  /// try {
702  /// foo();
703  /// }
704  /// catch () {
705  /// }
706  ///
707  /// false:
708  /// try {
709  /// foo();
710  /// } catch () {
711  /// }
712  /// \endcode
714  /// \brief Wrap before ``else``.
715  /// \code
716  /// true:
717  /// if (foo()) {
718  /// }
719  /// else {
720  /// }
721  ///
722  /// false:
723  /// if (foo()) {
724  /// } else {
725  /// }
726  /// \endcode
728  /// \brief Indent the wrapped braces themselves.
730  /// \brief If ``false``, empty function body can be put on a single line.
731  /// This option is used only if the opening brace of the function has
732  /// already been wrapped, i.e. the `AfterFunction` brace wrapping mode is
733  /// set, and the function could/should not be put on a single line (as per
734  /// `AllowShortFunctionsOnASingleLine` and constructor formatting options).
735  /// \code
736  /// int f() vs. inf f()
737  /// {} {
738  /// }
739  /// \endcode
740  ///
742  /// \brief If ``false``, empty record (e.g. class, struct or union) body
743  /// can be put on a single line. This option is used only if the opening
744  /// brace of the record has already been wrapped, i.e. the `AfterClass`
745  /// (for classes) brace wrapping mode is set.
746  /// \code
747  /// class Foo vs. class Foo
748  /// {} {
749  /// }
750  /// \endcode
751  ///
753  /// \brief If ``false``, empty namespace body can be put on a single line.
754  /// This option is used only if the opening brace of the namespace has
755  /// already been wrapped, i.e. the `AfterNamespace` brace wrapping mode is
756  /// set.
757  /// \code
758  /// namespace Foo vs. namespace Foo
759  /// {} {
760  /// }
761  /// \endcode
762  ///
764  };
765 
766  /// \brief Control of individual brace wrapping cases.
767  ///
768  /// If ``BreakBeforeBraces`` is set to ``BS_Custom``, use this to specify how
769  /// each individual brace case should be handled. Otherwise, this is ignored.
770  /// \code{.yaml}
771  /// # Example of usage:
772  /// BreakBeforeBraces: Custom
773  /// BraceWrapping:
774  /// AfterEnum: true
775  /// AfterStruct: false
776  /// SplitEmptyFunction: false
777  /// \endcode
779 
780  /// \brief If ``true``, ternary operators will be placed after line breaks.
781  /// \code
782  /// true:
783  /// veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongDescription
784  /// ? firstValue
785  /// : SecondValueVeryVeryVeryVeryLong;
786  ///
787  /// false:
788  /// veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongDescription ?
789  /// firstValue :
790  /// SecondValueVeryVeryVeryVeryLong;
791  /// \endcode
793 
794  /// \brief Different ways to break initializers.
796  /// Break constructor initializers before the colon and after the commas.
797  /// \code
798  /// Constructor()
799  /// : initializer1(),
800  /// initializer2()
801  /// \endcode
803  /// Break constructor initializers before the colon and commas, and align
804  /// the commas with the colon.
805  /// \code
806  /// Constructor()
807  /// : initializer1()
808  /// , initializer2()
809  /// \endcode
811  /// Break constructor initializers after the colon and commas.
812  /// \code
813  /// Constructor() :
814  /// initializer1(),
815  /// initializer2()
816  /// \endcode
817  BCIS_AfterColon
818  };
819 
820  /// \brief The constructor initializers style to use.
822 
823  /// \brief Break after each annotation on a field in Java files.
824  /// \code{.java}
825  /// true: false:
826  /// @Partial vs. @Partial @Mock DataLoad loader;
827  /// @Mock
828  /// DataLoad loader;
829  /// \endcode
831 
832  /// \brief Allow breaking string literals when formatting.
834 
835  /// \brief The column limit.
836  ///
837  /// A column limit of ``0`` means that there is no column limit. In this case,
838  /// clang-format will respect the input's line breaking decisions within
839  /// statements unless they contradict other rules.
840  unsigned ColumnLimit;
841 
842  /// \brief A regular expression that describes comments with special meaning,
843  /// which should not be split into lines or otherwise changed.
844  /// \code
845  /// // CommentPragmas: '^ FOOBAR pragma:'
846  /// // Will leave the following line unaffected
847  /// #include <vector> // FOOBAR pragma: keep
848  /// \endcode
849  std::string CommentPragmas;
850 
851  /// \brief If ``true``, in the class inheritance expression clang-format will
852  /// break before ``:`` and ``,`` if there is multiple inheritance.
853  /// \code
854  /// true: false:
855  /// class MyClass vs. class MyClass : public X, public Y {
856  /// : public X };
857  /// , public Y {
858  /// };
859  /// \endcode
861 
862  /// \brief If ``true``, consecutive namespace declarations will be on the same
863  /// line. If ``false``, each namespace is declared on a new line.
864  /// \code
865  /// true:
866  /// namespace Foo { namespace Bar {
867  /// }}
868  ///
869  /// false:
870  /// namespace Foo {
871  /// namespace Bar {
872  /// }
873  /// }
874  /// \endcode
875  ///
876  /// If it does not fit on a single line, the overflowing namespaces get
877  /// wrapped:
878  /// \code
879  /// namespace Foo { namespace Bar {
880  /// namespace Extra {
881  /// }}}
882  /// \endcode
884 
885  /// \brief If the constructor initializers don't fit on a line, put each
886  /// initializer on its own line.
887  /// \code
888  /// true:
889  /// SomeClass::Constructor()
890  /// : aaaaaaaa(aaaaaaaa), aaaaaaaa(aaaaaaaa), aaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaa) {
891  /// return 0;
892  /// }
893  ///
894  /// false:
895  /// SomeClass::Constructor()
896  /// : aaaaaaaa(aaaaaaaa), aaaaaaaa(aaaaaaaa),
897  /// aaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaa) {
898  /// return 0;
899  /// }
900  /// \endcode
902 
903  /// \brief The number of characters to use for indentation of constructor
904  /// initializer lists.
906 
907  /// \brief Indent width for line continuations.
908  /// \code
909  /// ContinuationIndentWidth: 2
910  ///
911  /// int i = // VeryVeryVeryVeryVeryLongComment
912  /// longFunction( // Again a long comment
913  /// arg);
914  /// \endcode
916 
917  /// \brief If ``true``, format braced lists as best suited for C++11 braced
918  /// lists.
919  ///
920  /// Important differences:
921  /// - No spaces inside the braced list.
922  /// - No line break before the closing brace.
923  /// - Indentation with the continuation indent, not with the block indent.
924  ///
925  /// Fundamentally, C++11 braced lists are formatted exactly like function
926  /// calls would be formatted in their place. If the braced list follows a name
927  /// (e.g. a type or variable name), clang-format formats as if the ``{}`` were
928  /// the parentheses of a function call with that name. If there is no name,
929  /// a zero-length name is assumed.
930  /// \code
931  /// true: false:
932  /// vector<int> x{1, 2, 3, 4}; vs. vector<int> x{ 1, 2, 3, 4 };
933  /// vector<T> x{{}, {}, {}, {}}; vector<T> x{ {}, {}, {}, {} };
934  /// f(MyMap[{composite, key}]); f(MyMap[{ composite, key }]);
935  /// new int[3]{1, 2, 3}; new int[3]{ 1, 2, 3 };
936  /// \endcode
938 
939  /// \brief If ``true``, analyze the formatted file for the most common
940  /// alignment of ``&`` and ``*``.
941  /// Pointer and reference alignment styles are going to be updated according
942  /// to the preferences found in the file.
943  /// ``PointerAlignment`` is then used only as fallback.
945 
946  /// \brief Disables formatting completely.
948 
949  /// \brief If ``true``, clang-format detects whether function calls and
950  /// definitions are formatted with one parameter per line.
951  ///
952  /// Each call can be bin-packed, one-per-line or inconclusive. If it is
953  /// inconclusive, e.g. completely on one line, but a decision needs to be
954  /// made, clang-format analyzes whether there are other bin-packed cases in
955  /// the input file and act accordingly.
956  ///
957  /// NOTE: This is an experimental flag, that might go away or be renamed. Do
958  /// not use this in config files, etc. Use at your own risk.
960 
961  /// \brief If ``true``, clang-format adds missing namespace end comments and
962  /// fixes invalid existing ones.
963  /// \code
964  /// true: false:
965  /// namespace a { vs. namespace a {
966  /// foo(); foo();
967  /// } // namespace a; }
968  /// \endcode
970 
971  /// \brief A vector of macros that should be interpreted as foreach loops
972  /// instead of as function calls.
973  ///
974  /// These are expected to be macros of the form:
975  /// \code
976  /// FOREACH(<variable-declaration>, ...)
977  /// <loop-body>
978  /// \endcode
979  ///
980  /// In the .clang-format configuration file, this can be configured like:
981  /// \code{.yaml}
982  /// ForEachMacros: ['RANGES_FOR', 'FOREACH']
983  /// \endcode
984  ///
985  /// For example: BOOST_FOREACH.
986  std::vector<std::string> ForEachMacros;
987 
988  /// \brief Styles for sorting multiple ``#include`` blocks.
990  /// \brief Sort each ``#include`` block separately.
991  /// \code
992  /// #include "b.h" into #include "b.h"
993  ///
994  /// #include <lib/main.h> #include "a.h"
995  /// #include "a.h" #include <lib/main.h>
996  /// \endcode
998  /// \brief Merge multiple ``#include`` blocks together and sort as one.
999  /// \code
1000  /// #include "b.h" into #include "a.h"
1001  /// #include "b.h"
1002  /// #include <lib/main.h> #include <lib/main.h>
1003  /// #include "a.h"
1004  /// \endcode
1006  /// \brief Merge multiple ``#include`` blocks together and sort as one.
1007  /// Then split into groups based on category priority. See
1008  /// ``IncludeCategories``.
1009  /// \code
1010  /// #include "b.h" into #include "a.h"
1011  /// #include "b.h"
1012  /// #include <lib/main.h>
1013  /// #include "a.h" #include <lib/main.h>
1014  /// \endcode
1016  };
1017 
1018  /// \brief Dependent on the value, multiple ``#include`` blocks can be sorted
1019  /// as one and divided based on category.
1021 
1022  /// \brief See documentation of ``IncludeCategories``.
1024  /// \brief The regular expression that this category matches.
1025  std::string Regex;
1026  /// \brief The priority to assign to this category.
1028  bool operator==(const IncludeCategory &Other) const {
1029  return Regex == Other.Regex && Priority == Other.Priority;
1030  }
1031  };
1032 
1033  /// \brief Regular expressions denoting the different ``#include`` categories
1034  /// used for ordering ``#includes``.
1035  ///
1036  /// These regular expressions are matched against the filename of an include
1037  /// (including the <> or "") in order. The value belonging to the first
1038  /// matching regular expression is assigned and ``#includes`` are sorted first
1039  /// according to increasing category number and then alphabetically within
1040  /// each category.
1041  ///
1042  /// If none of the regular expressions match, INT_MAX is assigned as
1043  /// category. The main header for a source file automatically gets category 0.
1044  /// so that it is generally kept at the beginning of the ``#includes``
1045  /// (http://llvm.org/docs/CodingStandards.html#include-style). However, you
1046  /// can also assign negative priorities if you have certain headers that
1047  /// always need to be first.
1048  ///
1049  /// To configure this in the .clang-format file, use:
1050  /// \code{.yaml}
1051  /// IncludeCategories:
1052  /// - Regex: '^"(llvm|llvm-c|clang|clang-c)/'
1053  /// Priority: 2
1054  /// - Regex: '^(<|"(gtest|gmock|isl|json)/)'
1055  /// Priority: 3
1056  /// - Regex: '.*'
1057  /// Priority: 1
1058  /// \endcode
1059  std::vector<IncludeCategory> IncludeCategories;
1060 
1061  /// \brief Specify a regular expression of suffixes that are allowed in the
1062  /// file-to-main-include mapping.
1063  ///
1064  /// When guessing whether a #include is the "main" include (to assign
1065  /// category 0, see above), use this regex of allowed suffixes to the header
1066  /// stem. A partial match is done, so that:
1067  /// - "" means "arbitrary suffix"
1068  /// - "$" means "no suffix"
1069  ///
1070  /// For example, if configured to "(_test)?$", then a header a.h would be seen
1071  /// as the "main" include in both a.cc and a_test.cc.
1072  std::string IncludeIsMainRegex;
1073 
1074  /// \brief Indent case labels one level from the switch statement.
1075  ///
1076  /// When ``false``, use the same indentation level as for the switch statement.
1077  /// Switch statement body is always indented one level more than case labels.
1078  /// \code
1079  /// false: true:
1080  /// switch (fool) { vs. switch (fool) {
1081  /// case 1: case 1:
1082  /// bar(); bar();
1083  /// break; break;
1084  /// default: default:
1085  /// plop(); plop();
1086  /// } }
1087  /// \endcode
1089 
1090  /// \brief Options for indenting preprocessor directives.
1092  /// Does not indent any directives.
1093  /// \code
1094  /// #if FOO
1095  /// #if BAR
1096  /// #include <foo>
1097  /// #endif
1098  /// #endif
1099  /// \endcode
1101  /// Indents directives after the hash.
1102  /// \code
1103  /// #if FOO
1104  /// # if BAR
1105  /// # include <foo>
1106  /// # endif
1107  /// #endif
1108  /// \endcode
1109  PPDIS_AfterHash
1110  };
1111 
1112  /// \brief The preprocessor directive indenting style to use.
1114 
1115  /// \brief The number of columns to use for indentation.
1116  /// \code
1117  /// IndentWidth: 3
1118  ///
1119  /// void f() {
1120  /// someFunction();
1121  /// if (true, false) {
1122  /// f();
1123  /// }
1124  /// }
1125  /// \endcode
1126  unsigned IndentWidth;
1127 
1128  /// \brief Indent if a function definition or declaration is wrapped after the
1129  /// type.
1130  /// \code
1131  /// true:
1132  /// LoooooooooooooooooooooooooooooooooooooooongReturnType
1133  /// LoooooooooooooooooooooooooooooooongFunctionDeclaration();
1134  ///
1135  /// false:
1136  /// LoooooooooooooooooooooooooooooooooooooooongReturnType
1137  /// LoooooooooooooooooooooooooooooooongFunctionDeclaration();
1138  /// \endcode
1140 
1141  /// \brief Quotation styles for JavaScript strings. Does not affect template
1142  /// strings.
1144  /// Leave string quotes as they are.
1145  /// \code{.js}
1146  /// string1 = "foo";
1147  /// string2 = 'bar';
1148  /// \endcode
1150  /// Always use single quotes.
1151  /// \code{.js}
1152  /// string1 = 'foo';
1153  /// string2 = 'bar';
1154  /// \endcode
1156  /// Always use double quotes.
1157  /// \code{.js}
1158  /// string1 = "foo";
1159  /// string2 = "bar";
1160  /// \endcode
1161  JSQS_Double
1162  };
1163 
1164  /// \brief The JavaScriptQuoteStyle to use for JavaScript strings.
1166 
1167  /// \brief Whether to wrap JavaScript import/export statements.
1168  /// \code{.js}
1169  /// true:
1170  /// import {
1171  /// VeryLongImportsAreAnnoying,
1172  /// VeryLongImportsAreAnnoying,
1173  /// VeryLongImportsAreAnnoying,
1174  /// } from 'some/module.js'
1175  ///
1176  /// false:
1177  /// import {VeryLongImportsAreAnnoying, VeryLongImportsAreAnnoying, VeryLongImportsAreAnnoying,} from "some/module.js"
1178  /// \endcode
1180 
1181  /// \brief If true, the empty line at the start of blocks is kept.
1182  /// \code
1183  /// true: false:
1184  /// if (foo) { vs. if (foo) {
1185  /// bar();
1186  /// bar(); }
1187  /// }
1188  /// \endcode
1190 
1191  /// \brief Supported languages.
1192  ///
1193  /// When stored in a configuration file, specifies the language, that the
1194  /// configuration targets. When passed to the ``reformat()`` function, enables
1195  /// syntax features specific to the language.
1197  /// Do not use.
1199  /// Should be used for C, C++.
1201  /// Should be used for Java.
1203  /// Should be used for JavaScript.
1205  /// Should be used for Objective-C, Objective-C++.
1207  /// Should be used for Protocol Buffers
1208  /// (https://developers.google.com/protocol-buffers/).
1210  /// Should be used for TableGen code.
1212  /// Should be used for Protocol Buffer messages in text format
1213  /// (https://developers.google.com/protocol-buffers/).
1214  LK_TextProto
1215  };
1216  bool isCpp() const { return Language == LK_Cpp || Language == LK_ObjC; }
1217 
1218  /// \brief Language, this format style is targeted at.
1220 
1221  /// \brief A regular expression matching macros that start a block.
1222  /// \code
1223  /// # With:
1224  /// MacroBlockBegin: "^NS_MAP_BEGIN|\
1225  /// NS_TABLE_HEAD$"
1226  /// MacroBlockEnd: "^\
1227  /// NS_MAP_END|\
1228  /// NS_TABLE_.*_END$"
1229  ///
1230  /// NS_MAP_BEGIN
1231  /// foo();
1232  /// NS_MAP_END
1233  ///
1234  /// NS_TABLE_HEAD
1235  /// bar();
1236  /// NS_TABLE_FOO_END
1237  ///
1238  /// # Without:
1239  /// NS_MAP_BEGIN
1240  /// foo();
1241  /// NS_MAP_END
1242  ///
1243  /// NS_TABLE_HEAD
1244  /// bar();
1245  /// NS_TABLE_FOO_END
1246  /// \endcode
1247  std::string MacroBlockBegin;
1248 
1249  /// \brief A regular expression matching macros that end a block.
1250  std::string MacroBlockEnd;
1251 
1252  /// \brief The maximum number of consecutive empty lines to keep.
1253  /// \code
1254  /// MaxEmptyLinesToKeep: 1 vs. MaxEmptyLinesToKeep: 0
1255  /// int f() { int f() {
1256  /// int = 1; int i = 1;
1257  /// i = foo();
1258  /// i = foo(); return i;
1259  /// }
1260  /// return i;
1261  /// }
1262  /// \endcode
1264 
1265  /// \brief Different ways to indent namespace contents.
1267  /// Don't indent in namespaces.
1268  /// \code
1269  /// namespace out {
1270  /// int i;
1271  /// namespace in {
1272  /// int i;
1273  /// }
1274  /// }
1275  /// \endcode
1277  /// Indent only in inner namespaces (nested in other namespaces).
1278  /// \code
1279  /// namespace out {
1280  /// int i;
1281  /// namespace in {
1282  /// int i;
1283  /// }
1284  /// }
1285  /// \endcode
1287  /// Indent in all namespaces.
1288  /// \code
1289  /// namespace out {
1290  /// int i;
1291  /// namespace in {
1292  /// int i;
1293  /// }
1294  /// }
1295  /// \endcode
1296  NI_All
1297  };
1298 
1299  /// \brief The indentation used for namespaces.
1301 
1302  /// \brief The number of characters to use for indentation of ObjC blocks.
1303  /// \code{.objc}
1304  /// ObjCBlockIndentWidth: 4
1305  ///
1306  /// [operation setCompletionBlock:^{
1307  /// [self onOperationDone];
1308  /// }];
1309  /// \endcode
1311 
1312  /// \brief Add a space after ``@property`` in Objective-C, i.e. use
1313  /// ``@property (readonly)`` instead of ``@property(readonly)``.
1315 
1316  /// \brief Add a space in front of an Objective-C protocol list, i.e. use
1317  /// ``Foo <Protocol>`` instead of ``Foo<Protocol>``.
1319 
1320  /// \brief The penalty for breaking around an assignment operator.
1322 
1323  /// \brief The penalty for breaking a function call after ``call(``.
1325 
1326  /// \brief The penalty for each line break introduced inside a comment.
1328 
1329  /// \brief The penalty for breaking before the first ``<<``.
1331 
1332  /// \brief The penalty for each line break introduced inside a string literal.
1334 
1335  /// \brief The penalty for each character outside of the column limit.
1337 
1338  /// \brief Penalty for putting the return type of a function onto its own
1339  /// line.
1341 
1342  /// \brief The ``&`` and ``*`` alignment style.
1344  /// Align pointer to the left.
1345  /// \code
1346  /// int* a;
1347  /// \endcode
1349  /// Align pointer to the right.
1350  /// \code
1351  /// int *a;
1352  /// \endcode
1354  /// Align pointer in the middle.
1355  /// \code
1356  /// int * a;
1357  /// \endcode
1358  PAS_Middle
1359  };
1360 
1361  /// \brief Pointer and reference alignment style.
1363 
1364  /// See documentation of ``RawStringFormats``.
1366  /// \brief The delimiter that this raw string format matches.
1367  std::string Delimiter;
1368  /// \brief The language of this raw string.
1370  /// \brief The style name on which this raw string format is based on.
1371  /// If not specified, the raw string format is based on the style that this
1372  /// format is based on.
1373  std::string BasedOnStyle;
1374  bool operator==(const RawStringFormat &Other) const {
1375  return Delimiter == Other.Delimiter && Language == Other.Language &&
1376  BasedOnStyle == Other.BasedOnStyle;
1377  }
1378  };
1379 
1380  /// \brief Raw string delimiters denoting that the raw string contents are
1381  /// code in a particular language and can be reformatted.
1382  ///
1383  /// A raw string with a matching delimiter will be reformatted assuming the
1384  /// specified language based on a predefined style given by 'BasedOnStyle'.
1385  /// If 'BasedOnStyle' is not found, the formatting is based on llvm style.
1386  ///
1387  /// To configure this in the .clang-format file, use:
1388  /// \code{.yaml}
1389  /// RawStringFormats:
1390  /// - Delimiter: 'pb'
1391  /// Language: TextProto
1392  /// BasedOnStyle: llvm
1393  /// - Delimiter: 'proto'
1394  /// Language: TextProto
1395  /// BasedOnStyle: google
1396  /// \endcode
1397  std::vector<RawStringFormat> RawStringFormats;
1398 
1399  /// \brief If ``true``, clang-format will attempt to re-flow comments.
1400  /// \code
1401  /// false:
1402  /// // veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of information
1403  /// /* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of information */
1404  ///
1405  /// true:
1406  /// // veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of
1407  /// // information
1408  /// /* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of
1409  /// * information */
1410  /// \endcode
1412 
1413  /// \brief If ``true``, clang-format will sort ``#includes``.
1414  /// \code
1415  /// false: true:
1416  /// #include "b.h" vs. #include "a.h"
1417  /// #include "a.h" #include "b.h"
1418  /// \endcode
1420 
1421  /// \brief If ``true``, clang-format will sort using declarations.
1422  ///
1423  /// The order of using declarations is defined as follows:
1424  /// Split the strings by "::" and discard any initial empty strings. The last
1425  /// element of each list is a non-namespace name; all others are namespace
1426  /// names. Sort the lists of names lexicographically, where the sort order of
1427  /// individual names is that all non-namespace names come before all namespace
1428  /// names, and within those groups, names are in case-insensitive
1429  /// lexicographic order.
1430  /// \code
1431  /// false: true:
1432  /// using std::cout; vs. using std::cin;
1433  /// using std::cin; using std::cout;
1434  /// \endcode
1436 
1437  /// \brief If ``true``, a space is inserted after C style casts.
1438  /// \code
1439  /// true: false:
1440  /// (int)i; vs. (int) i;
1441  /// \endcode
1443 
1444  /// \brief If \c true, a space will be inserted after the 'template' keyword.
1445  /// \code
1446  /// true: false:
1447  /// template <int> void foo(); vs. template<int> void foo();
1448  /// \endcode
1450 
1451  /// \brief If ``false``, spaces will be removed before assignment operators.
1452  /// \code
1453  /// true: false:
1454  /// int a = 5; vs. int a=5;
1455  /// a += 42 a+=42;
1456  /// \endcode
1458 
1459  /// \brief Different ways to put a space before opening parentheses.
1461  /// Never put a space before opening parentheses.
1462  /// \code
1463  /// void f() {
1464  /// if(true) {
1465  /// f();
1466  /// }
1467  /// }
1468  /// \endcode
1470  /// Put a space before opening parentheses only after control statement
1471  /// keywords (``for/if/while...``).
1472  /// \code
1473  /// void f() {
1474  /// if (true) {
1475  /// f();
1476  /// }
1477  /// }
1478  /// \endcode
1480  /// Always put a space before opening parentheses, except when it's
1481  /// prohibited by the syntax rules (in function-like macro definitions) or
1482  /// when determined by other style rules (after unary operators, opening
1483  /// parentheses, etc.)
1484  /// \code
1485  /// void f () {
1486  /// if (true) {
1487  /// f ();
1488  /// }
1489  /// }
1490  /// \endcode
1491  SBPO_Always
1492  };
1493 
1494  /// \brief Defines in which cases to put a space before opening parentheses.
1496 
1497  /// \brief If ``true``, spaces may be inserted into ``()``.
1498  /// \code
1499  /// true: false:
1500  /// void f( ) { vs. void f() {
1501  /// int x[] = {foo( ), bar( )}; int x[] = {foo(), bar()};
1502  /// if (true) { if (true) {
1503  /// f( ); f();
1504  /// } }
1505  /// } }
1506  /// \endcode
1508 
1509  /// \brief The number of spaces before trailing line comments
1510  /// (``//`` - comments).
1511  ///
1512  /// This does not affect trailing block comments (``/*`` - comments) as
1513  /// those commonly have different usage patterns and a number of special
1514  /// cases.
1515  /// \code
1516  /// SpacesBeforeTrailingComments: 3
1517  /// void f() {
1518  /// if (true) { // foo1
1519  /// f(); // bar
1520  /// } // foo
1521  /// }
1522  /// \endcode
1524 
1525  /// \brief If ``true``, spaces will be inserted after ``<`` and before ``>``
1526  /// in template argument lists.
1527  /// \code
1528  /// true: false:
1529  /// static_cast< int >(arg); vs. static_cast<int>(arg);
1530  /// std::function< void(int) > fct; std::function<void(int)> fct;
1531  /// \endcode
1533 
1534  /// \brief If ``true``, spaces are inserted inside container literals (e.g.
1535  /// ObjC and Javascript array and dict literals).
1536  /// \code{.js}
1537  /// true: false:
1538  /// var arr = [ 1, 2, 3 ]; vs. var arr = [1, 2, 3];
1539  /// f({a : 1, b : 2, c : 3}); f({a: 1, b: 2, c: 3});
1540  /// \endcode
1542 
1543  /// \brief If ``true``, spaces may be inserted into C style casts.
1544  /// \code
1545  /// true: false:
1546  /// x = ( int32 )y vs. x = (int32)y
1547  /// \endcode
1549 
1550  /// \brief If ``true``, spaces will be inserted after ``(`` and before ``)``.
1551  /// \code
1552  /// true: false:
1553  /// t f( Deleted & ) & = delete; vs. t f(Deleted &) & = delete;
1554  /// \endcode
1556 
1557  /// \brief If ``true``, spaces will be inserted after ``[`` and before ``]``.
1558  /// Lambdas or unspecified size array declarations will not be affected.
1559  /// \code
1560  /// true: false:
1561  /// int a[ 5 ]; vs. int a[5];
1562  /// std::unique_ptr<int[]> foo() {} // Won't be affected
1563  /// \endcode
1565 
1566  /// \brief Supported language standards.
1568  /// Use C++03-compatible syntax.
1570  /// Use features of C++11, C++14 and C++1z (e.g. ``A<A<int>>`` instead of
1571  /// ``A<A<int> >``).
1573  /// Automatic detection based on the input.
1574  LS_Auto
1575  };
1576 
1577  /// \brief Format compatible with this standard, e.g. use ``A<A<int> >``
1578  /// instead of ``A<A<int>>`` for ``LS_Cpp03``.
1580 
1581  /// \brief The number of columns used for tab stops.
1582  unsigned TabWidth;
1583 
1584  /// \brief Different ways to use tab in formatting.
1586  /// Never use tab.
1588  /// Use tabs only for indentation.
1590  /// Use tabs only for line continuation and indentation.
1592  /// Use tabs whenever we need to fill whitespace that spans at least from
1593  /// one tab stop to the next one.
1594  UT_Always
1595  };
1596 
1597  /// \brief The way to use tab characters in the resulting file.
1599 
1600  bool operator==(const FormatStyle &R) const {
1601  return AccessModifierOffset == R.AccessModifierOffset &&
1602  AlignAfterOpenBracket == R.AlignAfterOpenBracket &&
1603  AlignConsecutiveAssignments == R.AlignConsecutiveAssignments &&
1604  AlignConsecutiveDeclarations == R.AlignConsecutiveDeclarations &&
1605  AlignEscapedNewlines == R.AlignEscapedNewlines &&
1606  AlignOperands == R.AlignOperands &&
1607  AlignTrailingComments == R.AlignTrailingComments &&
1608  AllowAllParametersOfDeclarationOnNextLine ==
1610  AllowShortBlocksOnASingleLine == R.AllowShortBlocksOnASingleLine &&
1611  AllowShortCaseLabelsOnASingleLine ==
1613  AllowShortFunctionsOnASingleLine ==
1615  AllowShortIfStatementsOnASingleLine ==
1617  AllowShortLoopsOnASingleLine == R.AllowShortLoopsOnASingleLine &&
1618  AlwaysBreakAfterReturnType == R.AlwaysBreakAfterReturnType &&
1619  AlwaysBreakBeforeMultilineStrings ==
1621  AlwaysBreakTemplateDeclarations ==
1623  BinPackArguments == R.BinPackArguments &&
1624  BinPackParameters == R.BinPackParameters &&
1625  BreakBeforeBinaryOperators == R.BreakBeforeBinaryOperators &&
1626  BreakBeforeBraces == R.BreakBeforeBraces &&
1627  BreakBeforeTernaryOperators == R.BreakBeforeTernaryOperators &&
1628  BreakConstructorInitializers == R.BreakConstructorInitializers &&
1629  CompactNamespaces == R.CompactNamespaces &&
1630  BreakAfterJavaFieldAnnotations == R.BreakAfterJavaFieldAnnotations &&
1631  BreakStringLiterals == R.BreakStringLiterals &&
1632  ColumnLimit == R.ColumnLimit && CommentPragmas == R.CommentPragmas &&
1633  BreakBeforeInheritanceComma == R.BreakBeforeInheritanceComma &&
1634  ConstructorInitializerAllOnOneLineOrOnePerLine ==
1636  ConstructorInitializerIndentWidth ==
1638  ContinuationIndentWidth == R.ContinuationIndentWidth &&
1639  Cpp11BracedListStyle == R.Cpp11BracedListStyle &&
1640  DerivePointerAlignment == R.DerivePointerAlignment &&
1641  DisableFormat == R.DisableFormat &&
1642  ExperimentalAutoDetectBinPacking ==
1644  FixNamespaceComments == R.FixNamespaceComments &&
1645  ForEachMacros == R.ForEachMacros &&
1646  IncludeBlocks == R.IncludeBlocks &&
1647  IncludeCategories == R.IncludeCategories &&
1648  IndentCaseLabels == R.IndentCaseLabels &&
1649  IndentPPDirectives == R.IndentPPDirectives &&
1650  IndentWidth == R.IndentWidth && Language == R.Language &&
1651  IndentWrappedFunctionNames == R.IndentWrappedFunctionNames &&
1652  JavaScriptQuotes == R.JavaScriptQuotes &&
1653  JavaScriptWrapImports == R.JavaScriptWrapImports &&
1654  KeepEmptyLinesAtTheStartOfBlocks ==
1656  MacroBlockBegin == R.MacroBlockBegin &&
1657  MacroBlockEnd == R.MacroBlockEnd &&
1658  MaxEmptyLinesToKeep == R.MaxEmptyLinesToKeep &&
1659  NamespaceIndentation == R.NamespaceIndentation &&
1660  ObjCBlockIndentWidth == R.ObjCBlockIndentWidth &&
1661  ObjCSpaceAfterProperty == R.ObjCSpaceAfterProperty &&
1662  ObjCSpaceBeforeProtocolList == R.ObjCSpaceBeforeProtocolList &&
1663  PenaltyBreakAssignment ==
1665  PenaltyBreakBeforeFirstCallParameter ==
1667  PenaltyBreakComment == R.PenaltyBreakComment &&
1668  PenaltyBreakFirstLessLess == R.PenaltyBreakFirstLessLess &&
1669  PenaltyBreakString == R.PenaltyBreakString &&
1670  PenaltyExcessCharacter == R.PenaltyExcessCharacter &&
1671  PenaltyReturnTypeOnItsOwnLine == R.PenaltyReturnTypeOnItsOwnLine &&
1672  PointerAlignment == R.PointerAlignment &&
1673  RawStringFormats == R.RawStringFormats &&
1674  SpaceAfterCStyleCast == R.SpaceAfterCStyleCast &&
1675  SpaceAfterTemplateKeyword == R.SpaceAfterTemplateKeyword &&
1676  SpaceBeforeAssignmentOperators == R.SpaceBeforeAssignmentOperators &&
1677  SpaceBeforeParens == R.SpaceBeforeParens &&
1678  SpaceInEmptyParentheses == R.SpaceInEmptyParentheses &&
1679  SpacesBeforeTrailingComments == R.SpacesBeforeTrailingComments &&
1680  SpacesInAngles == R.SpacesInAngles &&
1681  SpacesInContainerLiterals == R.SpacesInContainerLiterals &&
1682  SpacesInCStyleCastParentheses == R.SpacesInCStyleCastParentheses &&
1683  SpacesInParentheses == R.SpacesInParentheses &&
1684  SpacesInSquareBrackets == R.SpacesInSquareBrackets &&
1685  Standard == R.Standard && TabWidth == R.TabWidth &&
1686  UseTab == R.UseTab;
1687  }
1688 };
1689 
1690 /// \brief Returns a format style complying with the LLVM coding standards:
1691 /// http://llvm.org/docs/CodingStandards.html.
1693 
1694 /// \brief Returns a format style complying with one of Google's style guides:
1695 /// http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml.
1696 /// http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml.
1697 /// https://developers.google.com/protocol-buffers/docs/style.
1699 
1700 /// \brief Returns a format style complying with Chromium's style guide:
1701 /// http://www.chromium.org/developers/coding-style.
1703 
1704 /// \brief Returns a format style complying with Mozilla's style guide:
1705 /// https://developer.mozilla.org/en-US/docs/Developer_Guide/Coding_Style.
1707 
1708 /// \brief Returns a format style complying with Webkit's style guide:
1709 /// http://www.webkit.org/coding/coding-style.html
1711 
1712 /// \brief Returns a format style complying with GNU Coding Standards:
1713 /// http://www.gnu.org/prep/standards/standards.html
1715 
1716 /// \brief Returns style indicating formatting should be not applied at all.
1718 
1719 /// \brief Gets a predefined style for the specified language by name.
1720 ///
1721 /// Currently supported names: LLVM, Google, Chromium, Mozilla. Names are
1722 /// compared case-insensitively.
1723 ///
1724 /// Returns ``true`` if the Style has been set.
1725 bool getPredefinedStyle(StringRef Name, FormatStyle::LanguageKind Language,
1726  FormatStyle *Style);
1727 
1728 /// \brief Parse configuration from YAML-formatted text.
1729 ///
1730 /// Style->Language is used to get the base style, if the ``BasedOnStyle``
1731 /// option is present.
1732 ///
1733 /// When ``BasedOnStyle`` is not present, options not present in the YAML
1734 /// document, are retained in \p Style.
1735 std::error_code parseConfiguration(StringRef Text, FormatStyle *Style);
1736 
1737 /// \brief Gets configuration in a YAML string.
1738 std::string configurationAsText(const FormatStyle &Style);
1739 
1740 /// \brief Returns the replacements necessary to sort all ``#include`` blocks
1741 /// that are affected by ``Ranges``.
1742 tooling::Replacements sortIncludes(const FormatStyle &Style, StringRef Code,
1743  ArrayRef<tooling::Range> Ranges,
1744  StringRef FileName,
1745  unsigned *Cursor = nullptr);
1746 
1747 /// \brief Returns the replacements corresponding to applying and formatting
1748 /// \p Replaces on success; otheriwse, return an llvm::Error carrying
1749 /// llvm::StringError.
1751 formatReplacements(StringRef Code, const tooling::Replacements &Replaces,
1752  const FormatStyle &Style);
1753 
1754 /// \brief Returns the replacements corresponding to applying \p Replaces and
1755 /// cleaning up the code after that on success; otherwise, return an llvm::Error
1756 /// carrying llvm::StringError.
1757 /// This also supports inserting/deleting C++ #include directives:
1758 /// - If a replacement has offset UINT_MAX, length 0, and a replacement text
1759 /// that is an #include directive, this will insert the #include into the
1760 /// correct block in the \p Code. When searching for points to insert new
1761 /// header, this ignores #include's after the #include block(s) in the
1762 /// beginning of a file to avoid inserting headers into code sections where
1763 /// new #include's should not be added by default. These code sections
1764 /// include:
1765 /// - raw string literals (containing #include).
1766 /// - #if blocks.
1767 /// - Special #include's among declarations (e.g. functions).
1768 /// - If a replacement has offset UINT_MAX, length 1, and a replacement text
1769 /// that is the name of the header to be removed, the header will be removed
1770 /// from \p Code if it exists.
1772 cleanupAroundReplacements(StringRef Code, const tooling::Replacements &Replaces,
1773  const FormatStyle &Style);
1774 
1775 /// \brief Represents the status of a formatting attempt.
1777  /// \brief A value of ``false`` means that any of the affected ranges were not
1778  /// formatted due to a non-recoverable syntax error.
1779  bool FormatComplete = true;
1780 
1781  /// \brief If ``FormatComplete`` is false, ``Line`` records a one-based
1782  /// original line number at which a syntax error might have occurred. This is
1783  /// based on a best-effort analysis and could be imprecise.
1784  unsigned Line = 0;
1785 };
1786 
1787 /// \brief Reformats the given \p Ranges in \p Code.
1788 ///
1789 /// Each range is extended on either end to its next bigger logic unit, i.e.
1790 /// everything that might influence its formatting or might be influenced by its
1791 /// formatting.
1792 ///
1793 /// Returns the ``Replacements`` necessary to make all \p Ranges comply with
1794 /// \p Style.
1795 ///
1796 /// If ``Status`` is non-null, its value will be populated with the status of
1797 /// this formatting attempt. See \c FormattingAttemptStatus.
1798 tooling::Replacements reformat(const FormatStyle &Style, StringRef Code,
1799  ArrayRef<tooling::Range> Ranges,
1800  StringRef FileName = "<stdin>",
1801  FormattingAttemptStatus *Status = nullptr);
1802 
1803 /// \brief Same as above, except if ``IncompleteFormat`` is non-null, its value
1804 /// will be set to true if any of the affected ranges were not formatted due to
1805 /// a non-recoverable syntax error.
1806 tooling::Replacements reformat(const FormatStyle &Style, StringRef Code,
1807  ArrayRef<tooling::Range> Ranges,
1808  StringRef FileName,
1809  bool *IncompleteFormat);
1810 
1811 /// \brief Clean up any erroneous/redundant code in the given \p Ranges in \p
1812 /// Code.
1813 ///
1814 /// Returns the ``Replacements`` that clean up all \p Ranges in \p Code.
1815 tooling::Replacements cleanup(const FormatStyle &Style, StringRef Code,
1816  ArrayRef<tooling::Range> Ranges,
1817  StringRef FileName = "<stdin>");
1818 
1819 /// \brief Fix namespace end comments in the given \p Ranges in \p Code.
1820 ///
1821 /// Returns the ``Replacements`` that fix the namespace comments in all
1822 /// \p Ranges in \p Code.
1824  StringRef Code,
1825  ArrayRef<tooling::Range> Ranges,
1826  StringRef FileName = "<stdin>");
1827 
1828 /// \brief Sort consecutive using declarations in the given \p Ranges in
1829 /// \p Code.
1830 ///
1831 /// Returns the ``Replacements`` that sort the using declarations in all
1832 /// \p Ranges in \p Code.
1834  StringRef Code,
1835  ArrayRef<tooling::Range> Ranges,
1836  StringRef FileName = "<stdin>");
1837 
1838 /// \brief Returns the ``LangOpts`` that the formatter expects you to set.
1839 ///
1840 /// \param Style determines specific settings for lexing mode.
1842 
1843 /// \brief Description to be used for help text for a ``llvm::cl`` option for
1844 /// specifying format style. The description is closely related to the operation
1845 /// of ``getStyle()``.
1846 extern const char *StyleOptionHelpDescription;
1847 
1848 /// \brief Construct a FormatStyle based on ``StyleName``.
1849 ///
1850 /// ``StyleName`` can take several forms:
1851 /// * "{<key>: <value>, ...}" - Set specic style parameters.
1852 /// * "<style name>" - One of the style names supported by
1853 /// getPredefinedStyle().
1854 /// * "file" - Load style configuration from a file called ``.clang-format``
1855 /// located in one of the parent directories of ``FileName`` or the current
1856 /// directory if ``FileName`` is empty.
1857 ///
1858 /// \param[in] StyleName Style name to interpret according to the description
1859 /// above.
1860 /// \param[in] FileName Path to start search for .clang-format if ``StyleName``
1861 /// == "file".
1862 /// \param[in] FallbackStyle The name of a predefined style used to fallback to
1863 /// in case \p StyleName is "file" and no file can be found.
1864 /// \param[in] Code The actual code to be formatted. Used to determine the
1865 /// language if the filename isn't sufficient.
1866 /// \param[in] FS The underlying file system, in which the file resides. By
1867 /// default, the file system is the real file system.
1868 ///
1869 /// \returns FormatStyle as specified by ``StyleName``. If ``StyleName`` is
1870 /// "file" and no file is found, returns ``FallbackStyle``. If no style could be
1871 /// determined, returns an Error.
1872 llvm::Expected<FormatStyle> getStyle(StringRef StyleName, StringRef FileName,
1873  StringRef FallbackStyle,
1874  StringRef Code = "",
1875  vfs::FileSystem *FS = nullptr);
1876 
1877 // \brief Returns a string representation of ``Language``.
1878 inline StringRef getLanguageName(FormatStyle::LanguageKind Language) {
1879  switch (Language) {
1880  case FormatStyle::LK_Cpp:
1881  return "C++";
1882  case FormatStyle::LK_ObjC:
1883  return "Objective-C";
1884  case FormatStyle::LK_Java:
1885  return "Java";
1886  case FormatStyle::LK_JavaScript:
1887  return "JavaScript";
1888  case FormatStyle::LK_Proto:
1889  return "Proto";
1890  case FormatStyle::LK_TextProto:
1891  return "TextProto";
1892  default:
1893  return "Unknown";
1894  }
1895 }
1896 
1897 } // end namespace format
1898 } // end namespace clang
1899 
1900 namespace std {
1901 template <>
1902 struct is_error_code_enum<clang::format::ParseError> : std::true_type {};
1903 }
1904 
1905 #endif // LLVM_CLANG_FORMAT_FORMAT_H
Always break after the return type of top-level definitions.
Definition: Format.h:328
Use tabs only for indentation.
Definition: Format.h:1589
See documentation of IncludeCategories.
Definition: Format.h:1023
PointerAlignmentStyle
The & and * alignment style.
Definition: Format.h:1343
bool AfterUnion
Wrap union definitions.
Definition: Format.h:683
std::string IncludeIsMainRegex
Specify a regular expression of suffixes that are allowed in the file-to-main-include mapping...
Definition: Format.h:1072
bool AlwaysBreakBeforeMultilineStrings
If true, always break before multiline string literals.
Definition: Format.h:350
tooling::Replacements reformat(const FormatStyle &Style, StringRef Code, ArrayRef< tooling::Range > Ranges, StringRef FileName, bool *IncompleteFormat)
Same as above, except if IncompleteFormat is non-null, its value will be set to true if any of the af...
Definition: Format.cpp:2041
unsigned PenaltyBreakBeforeFirstCallParameter
The penalty for breaking a function call after call(.
Definition: Format.h:1324
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:1600
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:2029
Should be used for Protocol Buffers (https://developers.google.com/protocol-buffers/).
Definition: Format.h:1209
bool IndentCaseLabels
Indent case labels one level from the switch statement.
Definition: Format.h:1088
unsigned IndentWidth
The number of columns to use for indentation.
Definition: Format.h:1126
Break constructor initializers before the colon and commas, and align the commas with the colon...
Definition: Format.h:810
bool DisableFormat
Disables formatting completely.
Definition: Format.h:947
bool AlignConsecutiveDeclarations
If true, aligns consecutive declarations.
Definition: Format.h:99
FormatStyle getMozillaStyle()
Returns a format style complying with Mozilla&#39;s style guide: https://developer.mozilla.org/en-US/docs/Developer_Guide/Coding_Style.
Definition: Format.cpp:763
DefinitionReturnTypeBreakingStyle AlwaysBreakAfterDefinitionReturnType
The function definition return type breaking style to use.
Definition: Format.h:333
bool SpaceAfterTemplateKeyword
If true, a space will be inserted after the &#39;template&#39; keyword.
Definition: Format.h:1449
PointerAlignmentStyle PointerAlignment
Pointer and reference alignment style.
Definition: Format.h:1362
bool AfterExternBlock
Wrap extern blocks.
Definition: Format.h:697
Align pointer to the left.
Definition: Format.h:1348
Maintains a set of replacements that are conflict-free.
Definition: Replacement.h:205
bool SplitEmptyFunction
If false, empty function body can be put on a single line.
Definition: Format.h:741
Should be used for C, C++.
Definition: Format.h:1200
unsigned PenaltyBreakFirstLessLess
The penalty for breaking before the first <<.
Definition: Format.h:1330
LanguageKind
Supported languages.
Definition: Format.h:1196
Does not indent any directives.
Definition: Format.h:1100
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:2051
bool SplitEmptyNamespace
If false, empty namespace body can be put on a single line.
Definition: Format.h:763
BreakConstructorInitializersStyle
Different ways to break initializers.
Definition: Format.h:795
bool AfterEnum
Wrap enum definitions.
Definition: Format.h:621
PPDirectiveIndentStyle IndentPPDirectives
The preprocessor directive indenting style to use.
Definition: Format.h:1113
Break after operators.
Definition: Format.h:406
Break constructor initializers before the colon and after the commas.
Definition: Format.h:802
FormatStyle getWebKitStyle()
Returns a format style complying with Webkit&#39;s style guide: http://www.webkit.org/coding/coding-style...
Definition: Format.cpp:789
std::string Delimiter
The delimiter that this raw string format matches.
Definition: Format.h:1367
bool JavaScriptWrapImports
Whether to wrap JavaScript import/export statements.
Definition: Format.h:1179
Like Attach, but break before braces on enum, function, and record definitions.
Definition: Format.h:485
Always break after the return type.
Definition: Format.h:288
The virtual file system interface.
bool AfterObjCDeclaration
Wrap ObjC definitions (@autoreleasepool, interfaces, ..).
Definition: Format.h:655
bool DerivePointerAlignment
If true, analyze the formatted file for the most common alignment of & and *.
Definition: Format.h:944
bool ExperimentalAutoDetectBinPacking
If true, clang-format detects whether function calls and definitions are formatted with one parameter...
Definition: Format.h:959
bool SpaceInEmptyParentheses
If true, spaces may be inserted into ().
Definition: Format.h:1507
EscapedNewlineAlignmentStyle AlignEscapedNewlines
Options for aligning backslashes in escaped newlines.
Definition: Format.h:133
bool IndentBraces
Indent the wrapped braces themselves.
Definition: Format.h:729
llvm::Expected< FormatStyle > getStyle(StringRef StyleName, StringRef FileName, StringRef FallbackStyle, StringRef Code="", vfs::FileSystem *FS=nullptr)
Construct a FormatStyle based on StyleName.
Definition: Format.cpp:2120
Definition: Format.h:1900
Should be used for Java.
Definition: Format.h:1202
Always break after the return type of function definitions.
Definition: Format.h:316
Only merge functions defined inside a class.
Definition: Format.h:207
std::vector< IncludeCategory > IncludeCategories
Regular expressions denoting the different #include categories used for ordering #includes.
Definition: Format.h:1059
NamespaceIndentationKind
Different ways to indent namespace contents.
Definition: Format.h:1266
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:48
Always break after the return types of top-level functions.
Definition: Format.h:257
bool BreakAfterJavaFieldAnnotations
Break after each annotation on a field in Java files.
Definition: Format.h:830
Use tabs only for line continuation and indentation.
Definition: Format.h:1591
bool ConstructorInitializerAllOnOneLineOrOnePerLine
If the constructor initializers don&#39;t fit on a line, put each initializer on its own line...
Definition: Format.h:901
unsigned PenaltyBreakComment
The penalty for each line break introduced inside a comment.
Definition: Format.h:1327
bool IndentWrappedFunctionNames
Indent if a function definition or declaration is wrapped after the type.
Definition: Format.h:1139
std::string Regex
The regular expression that this category matches.
Definition: Format.h:1025
IncludeBlocksStyle IncludeBlocks
Dependent on the value, multiple #include blocks can be sorted as one and divided based on category...
Definition: Format.h:1020
std::error_code make_error_code(BuildPreambleError Error)
bool SpacesInParentheses
If true, spaces will be inserted after ( and before ).
Definition: Format.h:1555
Always break after an open bracket, if the parameters don&#39;t fit on a single line, e...
Definition: Format.h:70
NamespaceIndentationKind NamespaceIndentation
The indentation used for namespaces.
Definition: Format.h:1300
ReturnTypeBreakingStyle AlwaysBreakAfterReturnType
The function declaration return type breaking style to use.
Definition: Format.h:336
LanguageKind Language
The language of this raw string.
Definition: Format.h:1369
bool BinPackArguments
If false, a function call&#39;s arguments will either be all on the same line or will have one line each...
Definition: Format.h:377
unsigned ObjCBlockIndentWidth
The number of characters to use for indentation of ObjC blocks.
Definition: Format.h:1310
bool SpaceBeforeAssignmentOperators
If false, spaces will be removed before assignment operators.
Definition: Format.h:1457
Merge multiple #include blocks together and sort as one.
Definition: Format.h:1015
FormatStyle getChromiumStyle(FormatStyle::LanguageKind Language)
Returns a format style complying with Chromium&#39;s style guide: http://www.chromium.org/developers/coding-style.
Definition: Format.cpp:740
SpaceBeforeParensOptions SpaceBeforeParens
Defines in which cases to put a space before opening parentheses.
Definition: Format.h:1495
FormatStyle getGNUStyle()
Returns a format style complying with GNU Coding Standards: http://www.gnu.org/prep/standards/standar...
Definition: Format.cpp:809
unsigned PenaltyBreakAssignment
The penalty for breaking around an assignment operator.
Definition: Format.h:1321
JavaScriptQuoteStyle
Quotation styles for JavaScript strings.
Definition: Format.h:1143
bool AlignConsecutiveAssignments
If true, aligns consecutive assignments.
Definition: Format.h:88
unsigned ColumnLimit
The column limit.
Definition: Format.h:840
Never merge functions into a single line.
Definition: Format.h:193
llvm::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:1638
bool SplitEmptyRecord
If false, empty record (e.g.
Definition: Format.h:752
bool AllowShortCaseLabelsOnASingleLine
If true, short case labels will be contracted to a single line.
Definition: Format.h:187
int Priority
The priority to assign to this category.
Definition: Format.h:1027
BracketAlignmentStyle AlignAfterOpenBracket
If true, horizontally aligns arguments after an open bracket.
Definition: Format.h:77
bool KeepEmptyLinesAtTheStartOfBlocks
If true, the empty line at the start of blocks is kept.
Definition: Format.h:1189
std::vector< std::string > ForEachMacros
A vector of macros that should be interpreted as foreach loops instead of as function calls...
Definition: Format.h:986
SpaceBeforeParensOptions
Different ways to put a space before opening parentheses.
Definition: Format.h:1460
Break before operators that aren&#39;t assignments.
Definition: Format.h:418
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:2061
UseTabStyle UseTab
The way to use tab characters in the resulting file.
Definition: Format.h:1598
std::string MacroBlockEnd
A regular expression matching macros that end a block.
Definition: Format.h:1250
FormatStyle getLLVMStyle()
Returns a format style complying with the LLVM coding standards: http://llvm.org/docs/CodingStandards...
Definition: Format.cpp:577
Break after return type automatically.
Definition: Format.h:272
std::string CommentPragmas
A regular expression that describes comments with special meaning, which should not be split into lin...
Definition: Format.h:849
See documentation of RawStringFormats.
Definition: Format.h:1365
Only merge empty functions.
Definition: Format.h:215
Defines the clang::LangOptions interface.
std::string MacroBlockBegin
A regular expression matching macros that start a block.
Definition: Format.h:1247
Should be used for JavaScript.
Definition: Format.h:1204
const AnnotatedLine * Line
Precise control over the wrapping of braces.
Definition: Format.h:581
LangOptions getFormattingLangOpts(const FormatStyle &Style=getLLVMStyle())
Returns the LangOpts that the formatter expects you to set.
Definition: Format.cpp:2071
IncludeBlocksStyle
Styles for sorting multiple #include blocks.
Definition: Format.h:989
Align escaped newlines as far left as possible.
Definition: Format.h:121
bool SpacesInContainerLiterals
If true, spaces are inserted inside container literals (e.g.
Definition: Format.h:1541
Align escaped newlines in the right-most column.
Definition: Format.h:129
BraceWrappingFlags BraceWrapping
Control of individual brace wrapping cases.
Definition: Format.h:778
bool SpacesInAngles
If true, spaces will be inserted after < and before > in template argument lists. ...
Definition: Format.h:1532
bool AlignOperands
If true, horizontally align operands of binary and ternary expressions.
Definition: Format.h:144
Don&#39;t align escaped newlines.
Definition: Format.h:110
bool AfterFunction
Wrap function definitions.
Definition: Format.h:637
Break after return type automatically.
Definition: Format.h:253
Always use single quotes.
Definition: Format.h:1155
int AccessModifierOffset
The extra indent or outdent of access modifiers, e.g. public:.
Definition: Format.h:48
FormatStyle getGoogleStyle(FormatStyle::LanguageKind Language)
Returns a format style complying with one of Google&#39;s style guides: http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml.
Definition: Format.cpp:672
EscapedNewlineAlignmentStyle
Different styles for aligning escaped newlines.
Definition: Format.h:102
Don&#39;t indent in namespaces.
Definition: Format.h:1276
BinaryOperatorStyle
The style of breaking before or after binary operators.
Definition: Format.h:394
llvm::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:1935
PPDirectiveIndentStyle
Options for indenting preprocessor directives.
Definition: Format.h:1091
StringRef getLanguageName(FormatStyle::LanguageKind Language)
Definition: Format.h:1878
bool CompactNamespaces
If true, consecutive namespace declarations will be on the same line.
Definition: Format.h:883
BraceBreakingStyle BreakBeforeBraces
The brace breaking style to use.
Definition: Format.h:572
Don&#39;t align, instead use ContinuationIndentWidth, e.g.
Definition: Format.h:63
unsigned PenaltyBreakString
The penalty for each line break introduced inside a string literal.
Definition: Format.h:1333
LanguageStandard
Supported language standards.
Definition: Format.h:1567
Always attach braces to surrounding context.
Definition: Format.h:451
bool operator==(const FormatStyle &R) const
Definition: Format.h:1600
unsigned PenaltyExcessCharacter
The penalty for each character outside of the column limit.
Definition: Format.h:1336
bool SortUsingDeclarations
If true, clang-format will sort using declarations.
Definition: Format.h:1435
bool ReflowComments
If true, clang-format will attempt to re-flow comments.
Definition: Format.h:1411
Put a space before opening parentheses only after control statement keywords (for/if/while...).
Definition: Format.h:1479
bool BreakBeforeTernaryOperators
If true, ternary operators will be placed after line breaks.
Definition: Format.h:792
Merge multiple #include blocks together and sort as one.
Definition: Format.h:1005
unsigned ContinuationIndentWidth
Indent width for line continuations.
Definition: Format.h:915
bool AlwaysBreakTemplateDeclarations
If true, always break after the template<...> of a template declaration.
Definition: Format.h:359
std::string BasedOnStyle
The style name on which this raw string format is based on.
Definition: Format.h:1373
bool AllowShortLoopsOnASingleLine
If true, while (true) continue; can be put on a single line.
Definition: Format.h:246
bool SpacesInCStyleCastParentheses
If true, spaces may be inserted into C style casts.
Definition: Format.h:1548
bool SpacesInSquareBrackets
If true, spaces will be inserted after [ and before ].
Definition: Format.h:1564
ReturnTypeBreakingStyle
Different ways to break after the function definition or declaration return type. ...
Definition: Format.h:262
The FormatStyle is used to configure the formatting to follow specific guidelines.
Definition: Format.h:46
Never put a space before opening parentheses.
Definition: Format.h:1469
unsigned PenaltyReturnTypeOnItsOwnLine
Penalty for putting the return type of a function onto its own line.
Definition: Format.h:1340
Indent only in inner namespaces (nested in other namespaces).
Definition: Format.h:1286
std::string configurationAsText(const FormatStyle &Style)
Gets configuration in a YAML string.
Definition: Format.cpp:902
LanguageKind Language
Language, this format style is targeted at.
Definition: Format.h:1219
Always break before braces.
Definition: Format.h:523
const char * StyleOptionHelpDescription
Description to be used for help text for a llvm::cl option for specifying format style.
Definition: Format.cpp:2089
Represents the status of a formatting attempt.
Definition: Format.h:1776
Dataflow Directional Tag Classes.
ShortFunctionStyle AllowShortFunctionsOnASingleLine
Dependent on the value, int f() { return 0; } can be put on a single line.
Definition: Format.h:239
bool SortIncludes
If true, clang-format will sort #includes.
Definition: Format.h:1419
Leave string quotes as they are.
Definition: Format.h:1149
bool FixNamespaceComments
If true, clang-format adds missing namespace end comments and fixes invalid existing ones...
Definition: Format.h:969
Use C++03-compatible syntax.
Definition: Format.h:1569
Always break after the return types of top-level functions.
Definition: Format.h:301
Should be used for TableGen code.
Definition: Format.h:1211
Use features of C++11, C++14 and C++1z (e.g.
Definition: Format.h:1572
bool Cpp11BracedListStyle
If true, format braced lists as best suited for C++11 braced lists.
Definition: Format.h:937
BraceBreakingStyle
Different ways to attach braces to their surrounding context.
Definition: Format.h:437
bool operator==(const IncludeCategory &Other) const
Definition: Format.h:1028
bool BreakStringLiterals
Allow breaking string literals when formatting.
Definition: Format.h:833
BracketAlignmentStyle
Different styles for aligning after open brackets.
Definition: Format.h:51
Merge all functions fitting on a single line.
Definition: Format.h:234
Like Attach, but break before functions.
Definition: Format.h:566
bool AfterStruct
Wrap struct definitions.
Definition: Format.h:669
bool AllowAllParametersOfDeclarationOnNextLine
If the function declaration doesn&#39;t fit on a line, allow putting all parameters of a function declara...
Definition: Format.h:169
bool getPredefinedStyle(StringRef Name, FormatStyle::LanguageKind Language, FormatStyle *Style)
Gets a predefined style for the specified language by name.
Definition: Format.cpp:832
unsigned TabWidth
The number of columns used for tab stops.
Definition: Format.h:1582
UseTabStyle
Different ways to use tab in formatting.
Definition: Format.h:1585
bool SpaceAfterCStyleCast
If true, a space is inserted after C style casts.
Definition: Format.h:1442
JavaScriptQuoteStyle JavaScriptQuotes
The JavaScriptQuoteStyle to use for JavaScript strings.
Definition: Format.h:1165
bool AllowShortIfStatementsOnASingleLine
If true, if (a) return; can be put on a single line.
Definition: Format.h:242
bool BreakBeforeInheritanceComma
If true, in the class inheritance expression clang-format will break before : and ...
Definition: Format.h:860
Should be used for Objective-C, Objective-C++.
Definition: Format.h:1206
Like Attach, but break before function definitions, catch, and else.
Definition: Format.h:506
FormatStyle getNoStyle()
Returns style indicating formatting should be not applied at all.
Definition: Format.cpp:824
Align parameters on the open bracket, e.g.
Definition: Format.h:57
Only merge functions defined inside a class.
Definition: Format.h:226
LanguageStandard Standard
Format compatible with this standard, e.g.
Definition: Format.h:1579
BreakConstructorInitializersStyle BreakConstructorInitializers
The constructor initializers style to use.
Definition: Format.h:821
std::vector< RawStringFormat > RawStringFormats
Raw string delimiters denoting that the raw string contents are code in a particular language and can...
Definition: Format.h:1397
unsigned ConstructorInitializerIndentWidth
The number of characters to use for indentation of constructor initializer lists. ...
Definition: Format.h:905
const std::error_category & getParseCategory()
Definition: Format.cpp:495
BinaryOperatorStyle BreakBeforeBinaryOperators
The way to wrap binary operators.
Definition: Format.h:434
Break before operators.
Definition: Format.h:430
bool ObjCSpaceBeforeProtocolList
Add a space in front of an Objective-C protocol list, i.e.
Definition: Format.h:1318
bool AfterControlStatement
Wrap control statements (if/for/while/switch/..).
Definition: Format.h:609
unsigned SpacesBeforeTrailingComments
The number of spaces before trailing line comments (// - comments).
Definition: Format.h:1523
bool AllowShortBlocksOnASingleLine
Allows contracting simple braced statements to a single line.
Definition: Format.h:174
bool operator==(const RawStringFormat &Other) const
Definition: Format.h:1374
bool AlignTrailingComments
If true, aligns trailing comments.
Definition: Format.h:152
ShortFunctionStyle
Different styles for merging short functions containing at most one statement.
Definition: Format.h:191
bool AfterClass
Wrap class definitions.
Definition: Format.h:591
StringRef Text
Definition: Format.cpp:1346
Always break before braces and add an extra level of indentation to braces of control statements...
Definition: Format.h:551
std::error_code parseConfiguration(StringRef Text, FormatStyle *Style)
Parse configuration from YAML-formatted text.
Definition: Format.cpp:856
Align pointer to the right.
Definition: Format.h:1353
DefinitionReturnTypeBreakingStyle
Different ways to break after the function definition return type.
Definition: Format.h:250
Always break after the return type.
Definition: Format.h:255
Sort each #include block separately.
Definition: Format.h:997
unsigned MaxEmptyLinesToKeep
The maximum number of consecutive empty lines to keep.
Definition: Format.h:1263
bool AfterNamespace
Wrap namespace definitions.
Definition: Format.h:653
const FormatStyle & Style
Like Attach, but break before braces on function, namespace and class definitions.
Definition: Format.h:468
bool BinPackParameters
If false, a function declaration&#39;s or function definition&#39;s parameters will either all be on the same...
Definition: Format.h:391