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