-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.clang-format
826 lines (815 loc) · 30.5 KB
/
.clang-format
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
###################################################################
# Formatting Options (using clang 14 pre-release) #
###################################################################
---
BasedOnStyle: LLVM
########## The extra indent or outdent of access modifiers ##########
AccessModifierOffset: -2
########## If true, horizontally aligns arguments after an open bracket ##########
AlignAfterOpenBracket: Align
# if not None, when using initialization for an array of structs aligns the fields into columns.
# AlignArrayOfStructures: Left #clang-format v14
########## If set, aligns consecutive assignments ##########
# Same as ACS_Consecutive, but also spans over lines only containing comments and empty lines, e.g.
# int a = 1;
# int somelongname = 2;
# double c = 3;
#
# int d = 3;
# /* A comment. */
# double e = 4;
AlignConsecutiveAssignments: AcrossEmptyLinesAndComments
#Style of aligning consecutive bit field.
#Consecutive will align the bitfield separators of consecutive lines. This will result in formattings like:
#int aaaa : 1;
#int b : 12;
#int ccc : 8;
AlignConsecutiveBitFields: AcrossEmptyLinesAndComments
########## If true, aligns consecutive declarations. ##########
# Same as ACS_Consecutive, but also spans over lines only containing comments and empty lines, e.g.
# int aaaa = 12;
# float b = 23;
# std::string ccc;
#
# int a = 42;
# /* A comment. */
# bool c = false;
AlignConsecutiveDeclarations: None
#Style of aligning consecutive macro definitions.
# Same as ACS_Consecutive, but also spans over lines only containing comments and empty lines, e.g.
# #define SHORT_NAME 42
# #define LONGER_NAME 0x007f
# #define EVEN_LONGER_NAME (2)
#
# #define foo(x) (x * x)
# /* some comment */
# #define bar(y, z) (y + z)
AlignConsecutiveMacros: AcrossEmptyLinesAndComments
########## Align escaped newlines in the right-most column ##########
# #define A \
# int aaaa; \
# int b; \
# int dddddddddd;
AlignEscapedNewlines: Right
########## Horizontally align operands of binary and ternary expressions ##########
# This is similar to AO_Align, except when BreakBeforeBinaryOperators is set, the
# operator is un-indented so that the wrapped operand is aligned with the operand on
# the first line.
# int aaa = bbbbbbbbbbbbbbb
# + ccccccccccccccc;
AlignOperands: AlignAfterOperator
########## If true, aligns trailing comments ##########
# true: false:
# int a; // My comment a vs. int a; // My comment a
# int b = 2; // comment b int b = 2; // comment about b
AlignTrailingComments: true
# If a function call or braced initializer list doesn’t fit on a line, allow putting all arguments onto the next line, even if BinPackArguments is false.
# true:
# callFunction(
# a, b, c, d);
# false:
# callFunction(a,
# b,
# c,
# d);
AllowAllArgumentsOnNextLine: true
########## allow putting all parameters of a function declaration onto the next line ##########
# false:
# void myFunction(int a,
# int b,
# int c);
AllowAllParametersOfDeclarationOnNextLine: true
########## Allows contracting simple braced statements to a single line ##########
# Always merge short blocks into a single line.
# while (true) {}
# while (true) { continue; }
AllowShortBlocksOnASingleLine: Always
########## If true, short case labels will be contracted to a single line ##########
# true: false:
# switch (a) { vs. switch (a) {
# case 1: x = 1; break; case 1:
# case 2: return; x = 1;
# } break;
# case 2:
# return;
# }
AllowShortCaseLabelsOnASingleLine: true
# Allow short enums on a single line.
# true:
# enum { A, B } myEnum;
# false:
# enum {
# A,
# B
# } myEnum;
AllowShortEnumsOnASingleLine: false
########## Only merge empty functions ##########
# void f() {}
# void f2() {
# bar2();
# }
AllowShortFunctionsOnASingleLine: Empty
# Put short ifs on the same line only if there is no else statement.
# if (a) return;
#
# if (b)
# return;
# else
# return;
#
# if (c)
# return;
# else {
# return;
# }
AllowShortIfStatementsOnASingleLine: WithoutElse
# Dependent on the value, auto lambda []() { return 0; } can be put on a single line.
# Merge lambda into a single line if argument of a function.
# auto lambda = [](int a) {
# return a;
# };
# sort(a.begin(), a.end(), ()[] { return x < y; })
AllowShortLambdasOnASingleLine: Inline
########## If true, while (true) continue; can be put on a single line ##########
AllowShortLoopsOnASingleLine: true
########## Always break after the return type of function definitions ##########
# class A {
# int f() { return 0; };
# };
# int f();
# int f() { return 1; }
AlwaysBreakAfterReturnType: None
########## If true, always break before multiline string literals ##########
# true: false:
# aaaa = vs. aaaa = "bbbb"
# "bbbb" "cccc";
# "cccc";
AlwaysBreakBeforeMultilineStrings: false
########## Force break after template declaration only when ##########
########## the following declaration spans multiple lines. ##########
# template <typename T> T foo() {
# }
# template <typename T>
# T foo(int aaaaaaaaaaaaaaaaaaaaa,
# int bbbbbbbbbbbbbbbbbbbbb) {
# }
AlwaysBreakTemplateDeclarations: MultiLine
# A vector of strings that should be interpreted as attributes/qualifiers instead of identifiers.
# This can be useful for language extensions or static analyzer annotations.
# For example:
# x = (char *__capability)&y;
# int function(void) __ununsed;
# void only_writes_to_buffer(char *__output buffer);
# In the .clang-format configuration file, this can be configured like:
# AttributeMacros: ['__capability', '__output', '__ununsed']
AttributeMacros: ['']
########## If false, a function call’s arguments will either ###########
########## be all on the same line or will have one line each. ###########
# false:
# void f() {
# f(aaaaaaaaaaaaaaaaaaaa,
# aaaaaaaaaaaaaaaaaaaa,
# aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
# }
BinPackArguments: true
########## If false, a function declaration’s or function definition’s parameters ##########
########## will either all be on the same line or will have one line each ##########
# false:
# void f(int aaaaaaaaaaaaaaaaaaaa,
# int aaaaaaaaaaaaaaaaaaaa,
# int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}
BinPackParameters: true
# The BitFieldColonSpacingStyle to use for bitfields.
# Add space after the : only (space may be added before if needed for AlignConsecutiveBitFields).
# unsigned bf: 2;
BitFieldColonSpacing: After
########## Control of individual brace wrapping cases If custom defined ##########
BreakBeforeBraces: Custom
BraceWrapping:
# false: true:
# switch (foo) { vs. switch (foo) {
# case 1: { case 1:
# bar(); {
# break; bar();
# } break;
# default: { }
# plop(); default:
# } {
# }
AfterCaseLabel: false
# true:
# class foo {};
# false:
# class foo
# {};
AfterClass: true
# Only wrap braces after a multi-line control statement.
# if (foo && bar &&
# baz)
# {
# quux();
# }
# while (foo || bar) {
# }
AfterControlStatement: MultiLine
# true:
# enum X : int
# {
# B
# };
# false:
# enum X : int { B };
AfterEnum: true
# true:
# void foo()
# {
# bar();
# bar2();
# }
# false:
# void foo() {
# bar();
# bar2();
# }
AfterFunction: false
# true:
# namespace
# {
# int foo();
# int bar();
# }
# false:
# namespace {
# int foo();
# int bar();
# }
AfterNamespace: false
# Not used but setting to false
AfterObjCDeclaration: false
# true:
# struct foo
# {
# int x;
# };
# false:
# struct foo {
# int x;
# };
AfterStruct: true
#true:
#union foo
#{
# int x;
#}
#false:
#union foo {
# int x;
#}
AfterUnion: true
# true:
# extern "C"
# {
# int foo();
# }
# false:
# extern "C" {
# int foo();
# }
AfterExternBlock: false
# true:
# try {
# foo();
# }
# catch () {
# }
# false:
# try {
# foo();
# } catch () {
# }
BeforeCatch: true
# true:
# if (foo()) {
# }
# else {
# }
# false:
# if (foo()) {
# } else {
# }
BeforeElse: false
# true:
# connect(
# []()
# {
# foo();
# bar();
# });
# false:
# connect([]() {
# foo();
# bar();
# });
BeforeLambdaBody: false
# Indent the wrapped braces themselves.
IndentBraces: true
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
########## Break after operators ##########
# bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
# aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ==
# aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &&
# aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa >
# ccccccccccccccccccccccccccccccccccccccccc;
BreakBeforeBinaryOperators: None
# The concept declaration style to use.
BreakBeforeConceptDeclarations: true
########## If true, ternary operators will be placed after line breaks ##########
# true:
# veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongDescription
# ? firstValue
# : SecondValueVeryVeryVeryVeryLong;
BreakBeforeTernaryOperators: true
########## Break constructor initializers before the colon and after the commas ##########
# Constructor()
# : initializer1(),
# initializer2()
BreakConstructorInitializers: BeforeColon
########## Break inheritance list after the colon and commas ##########
# class Foo : Base1,
# Base2
# {};
BreakInheritanceList: BeforeColon
########## Allow breaking string literals when formatting ##########
# true:
# const char* x = "veryVeryVeryVeryVeryVe"
# "ryVeryVeryVeryVeryVery"
# "VeryLongString";
BreakStringLiterals: true
ColumnLimit: 165
########## A regular expression that describes comments with special meaning ##########
CommentPragmas: '^///'
########## If false, each namespace is declared on a new line ##########
# NOTE: Will Be Coupled With Custom Breaking And Indenting Rules Earlier
# false: With Earlier Choices:
# namespace Foo { namespace Foo {
# namespace Bar { namespace Bar {}
# } }
# }
CompactNamespaces: false
########## The number of characters to use for indentation of ##########
########## constructor initializer lists as well as inheritance lists ##########
ConstructorInitializerIndentWidth: 4
########## Indent width for line continuations ##########
ContinuationIndentWidth: 0
########## If true, format braced lists as best suited for C++11 braced lists ##########
# true: false:
# vector<int> x{1, 2, 3, 4}; vs. vector<int> x{ 1, 2, 3, 4 };
# vector<T> x{{}, {}, {}, {}}; vector<T> x{ {}, {}, {}, {} };
# f(MyMap[{composite, key}]); f(MyMap[{ composite, key }]);
# new int[3]{1, 2, 3}; new int[3]{ 1, 2, 3 };
Cpp11BracedListStyle: false
# Analyze the formatted file for the most used line ending (\r\n or \n).
# UseCRLF is only used as a fallback if none can be derived.
DeriveLineEnding: true
########## Analyze the formatted file for the most common alignment of & and *. Pointer ##########
########## and reference alignment styles are going to be updated according to the ##########
########## preferences found in the file. PointerAlignment is then used only as fallback. ##########
DerivePointerAlignment: false
########## Disables formatting completely ##########
DisableFormat: false
# Defines when to put an empty line after access modifiers. EmptyLineBeforeAccessModifier
# configuration handles the number of empty lines between two access modifiers.
# Always add empty line after access modifiers if there are none. MaxEmptyLinesToKeep is applied also.
# struct foo {
# private:
#
# int i;
# protected:
#
# int j;
# /* comment */
# public:
#
# foo() {}
# private:
#
# protected:
#
# };
# EmptyLineAfterAccessModifier: Never #clang-format v14
# Defines in which cases to put empty line before access modifiers.
# Remove all empty lines after access modifiers.
# struct foo {
# private:
# int i;
# protected:
# int j;
# /* comment */
# public:
# foo() {}
# private:
# protected:
# };
EmptyLineBeforeAccessModifier: LogicalBlock
########## If true, clang-format adds missing namespace ##########
########## end comments and fixes invalid existing ones ##########
# true: false:
# namespace a { vs. namespace a {
# foo(); foo();
# } // namespace a }
FixNamespaceComments: true
# A vector of macros that should be interpreted as foreach loops instead of as function calls.
# These are expected to be macros of the form:
# FOREACH(<variable-declaration>, ...)
# <loop-body>
ForEachMacros: ['']
# A vector of macros that should be interpreted as conditionals instead of as function calls.
# These are expected to be macros of the form:
# IF(...)
# <conditional-body>
# else IF(...)
# <conditional-body>
# IfMacros: [''] #clang-format v14
########## Sort each #include block separately. ##########
IncludeBlocks: Preserve
########## Regular expressions denoting the different ##########
########## #include categories used for ordering ##########
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
SortPriority: 2
CaseSensitive: true
- Regex: '^((<|")(gtest|gmock|isl|json)/)'
Priority: 3
- Regex: '<[[:alnum:].]+>'
Priority: 4
- Regex: '.*'
Priority: 1
SortPriority: 0
######## Specify a regular expression of suffixes that ##########
######## are allowed in the file-to-main-include mapping ##########
IncludeIsMainRegex: (Test)?$
# Specify whether access modifiers should have their own indentation level.
# When false, access modifiers are indented (or outdented) relative to the record members,
# respecting the AccessModifierOffset. Record members are indented one level below the record.
# When true, access modifiers get their own indentation level. As a consequence, record members
# are always indented 2 levels below the record, regardless of the access modifier presence.
# Value of the AccessModifierOffset is ignored.
# false: true:
# class C { vs. class C {
# class D { class D {
# void bar(); void bar();
# protected: protected:
# D(); D();
# }; };
# public: public:
# C(); C();
# }; };
# void foo() { void foo() {
# return 1; return 1;
# } }
# IndentAccessModifiers: true #clang-format v14
# Indent case label blocks one level from the case label.
# When false, the block following the case label uses the same indentation level as for the case label,
# treating the case label the same as an if-statement. When true, the block gets indented as a scope block.
# false: true:
# switch (fool) { vs. switch (fool) {
# case 1: { case 1:
# bar(); {
# } break; bar();
# default: { }
# plop(); break;
# } default:
# } {
# plop();
# }
# }
IndentCaseBlocks: true
########## Indent case labels one level from the switch statement ##########
# false: true:
# switch (fool) { vs. switch (fool) {
# case 1: case 1:
# bar(); bar();
# break; break;
# default: default:
# plop(); plop();
# } }
IndentCaseLabels: true
# IndentExternBlockStyle is the type of indenting of extern blocks.
IndentExternBlock: Indent
# Indent goto labels.
# When false, goto labels are flushed left.
# true: false:
# int f() { vs. int f() {
# if (foo()) { if (foo()) {
# label1: label1:
# bar(); bar();
# } }
# label2: label2:
# return 1; return 1;
# } }
IndentGotoLabels: false
########## Indents directives before the hash ##########
# #if FOO
# #if BAR
# #include <foo>
# #endif
# #endif
IndentPPDirectives: BeforeHash
# Indent the requires clause in a template. This only applies when RequiresClausePosition is OwnLine, or WithFollowing.
# true:
# template <typename It>
# requires Iterator<It>
# void sort(It begin, It end) {
# //....
# }
#
# false:
# template <typename It>
# requires Iterator<It>
# void sort(It begin, It end) {
# //....
# }
# IndentRequiresClause: true
########## The number of columns to use for indentation ##########
IndentWidth: 4
########## Indent if a function definition or declaration is wrapped after the type ##########
# true:
# LoooooooooooooooooooooooooooooooooooooooongReturnType
# LoooooooooooooooooooooooooooooooongFunctionDeclaration();
# false:
# LoooooooooooooooooooooooooooooooooooooooongReturnType
# LoooooooooooooooooooooooooooooooongFunctionDeclaration();
IndentWrappedFunctionNames: false
# If true, the empty line at the start of blocks is kept.
# true: false:
# if (foo) { vs. if (foo) {
# bar();
# bar(); }
# }
KeepEmptyLinesAtTheStartOfBlocks: false
# The indentation style of lambda bodies. Signature (the default) causes the lambda body to be
# indented one additional level relative to the indentation level of the signature. OuterScope
# forces the lambda body to be indented one additional level relative to the parent scope
# containing the lambda signature. For callback-heavy code, it may improve readability to have
# the signature indented two levels and to use OuterScope.
# LambdaBodyIndentation: OuterScope #clang-format v14
# Language, this format style is targeted at.
Language: Cpp
########## A regular expression matching macros that start and end a block #########
MacroBlockBegin: ''
MacroBlockEnd: ''
# The maximum number of consecutive empty lines to keep.
MaxEmptyLinesToKeep: 1
# Indent in all namespaces.
# namespace out {
# int i;
# namespace in {
# int i;
# }
# }
NamespaceIndentation: All
# A vector of macros which are used to open namespace blocks.
# These are expected to be macros of the form:
# NAMESPACE(<namespace-name>, ...) {
# <namespace-content>
# }
# For example: TESTSUITE
# NamespaceMacros:
# The number of columns to use for indentation of preprocessor statements.
# When set to -1 (default) IndentWidth is used also for preprocessor statements.
# PPIndentWidth: 1
# #ifdef __linux__
# # define FOO
# #else
# # define BAR
# #endif
# PPIndentWidth: -1 #clang-format v14
# The pack constructor initializers style to use.
# Same as PCIS_CurrentLine except that if all constructor initializers do not fit on the
# current line, try to fit them on the next line.
# Constructor() : a(), b()
# Constructor()
# : aaaaaaaaaaaaaaaaaaaa(), bbbbbbbbbbbbbbbbbbbb(), ddddddddddddd()
# Constructor()
# : aaaaaaaaaaaaaaaaaaaa(),
# bbbbbbbbbbbbbbbbbbbb(),
# cccccccccccccccccccc()
# PackConstructorInitializers: NextLine # clang-format v14
PenaltyBreakAssignment: 15
PenaltyBreakBeforeFirstCallParameter: 25
PenaltyBreakComment: 10
PenaltyBreakFirstLessLess: 15
PenaltyBreakString: 5
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 5
PenaltyReturnTypeOnItsOwnLine: 50
# Align pointer to the left.
# int* a;
PointerAlignment: Left
# Different ways to arrange specifiers and qualifiers (e.g. const/volatile). #
# Don’t change specifiers/qualifiers to either Left or Right alignment (default).
# int const a;
# const int *a;
# QualifierAlignment: Leave # clang-format v14
# The order in which the qualifiers appear. Order is an array that can contain any of the following:
# - const
# - inline
# - static
# - constexpr
# - volatile
# - restrict
# - type
# Note: it MUST contain ‘type’. Items to the left of ‘type’ will be placed to the left of the type
# and aligned in the order supplied. Items to the right of ‘type’ will be placed to the right of
# the type and aligned in the order supplied.
# QualifierOrder: ['inline', 'static', 'type', 'const', 'volatile' ]
########## Defines hints for detecting supported ##########
########## languages code blocks in raw strings ##########
RawStringFormats:
- Language: Cpp
Delimiters:
- "cc"
- "cpp"
BasedOnStyle: llvm
CanonicalDelimiter: "cc"
# Reference alignment style (overrides PointerAlignment for references).
# ReferenceAlignment: Pointer #clang-format v14
# If true, clang-format will attempt to re-flow comments.
ReflowComments: true
# Specifies the use of empty lines to separate definition blocks, including classes, structs, enums, and functions.
# Never v.s. Always
# #include <cstring> #include <cstring>
# struct Foo {
# int a, b, c; struct Foo {
# }; int a, b, c;
# namespace Ns { };
# class Bar {
# public: namespace Ns {
# struct Foobar { class Bar {
# int a; public:
# int b; struct Foobar {
# }; int a;
# private: int b;
# int t; };
# int method1() {
# // ... private:
# } int t;
# enum List {
# ITEM1, int method1() {
# ITEM2 // ...
# }; }
# template<typename T>
# int method2(T x) { enum List {
# // ... ITEM1,
# } ITEM2
# int i, j, k; };
# int method3(int par) {
# // ... template<typename T>
# } int method2(T x) {
# }; // ...
# class C {}; }
# }
# int i, j, k;
#
# int method3(int par) {
# // ...
# }
# };
#
# class C {};
# }
# SeparateDefinitionBlocks: Always # clang-format v14
# The maximal number of unwrapped lines that a short namespace spans. Defaults to 1.
# This determines the maximum length of short namespaces by counting unwrapped lines
# (i.e. containing neither opening nor closing namespace brace) and makes “FixNamespaceComments”
# omit adding end comments for those.
# ShortNamespaceLines: 1 vs. ShortNamespaceLines: 0
# namespace a { namespace a {
# int foo; int foo;
# } } // namespace a
# ShortNamespaceLines: 1 vs. ShortNamespaceLines: 0
# namespace b { namespace b {
# int foo; int foo;
# int bar; int bar;
# } // namespace b } // namespace b
# ShortNamespaceLines: 1 #clang-format v14
# Includes are sorted in an ASCIIbetical or case sensitive fashion.
# #include "A/B.h"
# #include "A/b.h"
# #include "B/A.h"
# #include "B/a.h"
# #include "a/b.h"
# SortIncludes: CaseSensitive clang-format v14
# If true, clang-format will sort using declarations.
# false: true:
# using std::cout; vs. using std::cin;
# using std::cin; using std::cout;
SortUsingDeclarations: true
# If true, a space is inserted after C style casts.
# true: false:
# (int) i; vs. (int)i;
SpaceAfterCStyleCast: false
# If true, a space is inserted after the logical not operator (!).
SpaceAfterLogicalNot: false
# If true, a space will be inserted after the ‘template’ keyword.
# true: false:
# template <int> void foo(); vs. template<int> void foo();
SpaceAfterTemplateKeyword: false
# Defines in which cases to put a space before or after pointer qualifiers
SpaceAroundPointerQualifiers: Default
# If false, spaces will be removed before assignment operators.
# true: false:
# int a = 5; vs. int a=5;
# a += 42 a+=42;
SpaceBeforeAssignmentOperators: true
# If false, spaces will be removed before case colon.
SpaceBeforeCaseColon: false
# If true, a space will be inserted before a C++11 braced list used to initialize an object (after the preceding identifier or type).
# true: false:
# Foo foo { bar }; vs. Foo foo{ bar };
# Foo {}; Foo{};
# vector<int> { 1, 2, 3 }; vector<int>{ 1, 2, 3 };
# new int[3] { 1, 2, 3 }; new int[3]{ 1, 2, 3 };
SpaceBeforeCpp11BracedList: true
# If false, spaces will be removed before constructor initializer colon.
# true: false:
# Foo::Foo() : a(a) {} Foo::Foo(): a(a) {}
SpaceBeforeCtorInitializerColon: false
# If false, spaces will be removed before inheritance colon.
# true: false:
# class Foo : Bar {} vs. class Foo: Bar {}
SpaceBeforeInheritanceColon: false
# Defines in which cases to put a space before opening parentheses.
SpaceBeforeParens: Never
# If false, spaces will be removed before range-based for loop colon.
# true: false:
# for (auto v : values) {} vs. for(auto v: values) {}
SpaceBeforeRangeBasedForLoopColon: false
# If true, spaces will be before [. Lambdas will not be affected. Only the first [ will get a space added.
# true: false:
# int a [5]; vs. int a[5];
# int a [5][5]; vs. int a[5][5];
SpaceBeforeSquareBrackets: false
# If true, spaces will be inserted into {}.
# true: false:
# void f() { } vs. void f() {}
# while (true) { } while (true) {}
SpaceInEmptyBlock: true
# If true, spaces may be inserted into ().
# true: false:
# void f( ) { vs. void f() {
# int x[] = {foo( ), bar( )}; int x[] = {foo(), bar()};
# if (true) { if (true) {
# f( ); f();
# } }
# } }
SpaceInEmptyParentheses: false
# The number of spaces before trailing line comments (// - comments).
# This does not affect trailing block comments (/* - comments) as those commonly have different usage patterns and a number of special cases.
SpacesBeforeTrailingComments: 4
# If true, spaces will be inserted after < and before > in template argument lists.
# true: false:
# static_cast< int >(arg); vs. static_cast<int>(arg);
# std::function< void(int) > fct; std::function<void(int)> fct;
# SpacesInAngles: Never #clang-format v14
# If true, spaces may be inserted into C style casts.
# true: false:
# x = ( int32 )y vs. x = (int32)y
SpacesInCStyleCastParentheses: false
# If true, spaces will be inserted around if/for/switch/while conditions.
# true: false:
# if ( a ) { ... } vs. if (a) { ... }
# while ( i < 5 ) { ... } while (i < 5) { ... }
SpacesInConditionalStatement: true
# If true, spaces are inserted inside container literals (e.g. ObjC and Javascript array and dict literals).
# true: false:
# var arr = [ 1, 2, 3 ]; vs. var arr = [1, 2, 3];
# f({a : 1, b : 2, c : 3}); f({a: 1, b: 2, c: 3});
SpacesInContainerLiterals: true
# How many spaces are allowed at the start of a line comment. To disable the maximum
# set it to -1, apart from that the maximum takes precedence over the minimum.
# SpacesInLineCommentPrefix: #clang-format v14
# Minimum: 1 #clang-format v14
# Maximum: -1 #clang-format v14
# If true, spaces will be inserted after ( and before ).
# true: false:
# t f( Deleted & ) & = delete; vs. t f(Deleted &) & = delete;
SpacesInParentheses: false
# If true, spaces will be inserted after [ and before ]. Lambdas or unspecified size array declarations will not be affected.
# true: false:
# int a[ 5 ]; vs. int a[5];
# std::unique_ptr<int[]> foo() {} // Won't be affected
SpacesInSquareBrackets: true
# Format compatible with this standard
Standard: Latest
# A vector of macros that should be interpreted as complete statements.
# Typical macros are expressions, and require a semi-colon to be added; sometimes this is not the case, and this allows to make clang-format aware of such cases.
# For example: Q_UNUSED
# StatementMacros: ["DEPRACATED", "TODO", "NOTE"]
# The number of columns used for tab stops.
TabWidth: 4
# The way to use tab characters in the resulting file.
UseTab: AlignWithSpaces