-
Notifications
You must be signed in to change notification settings - Fork 0
/
.clang-format
426 lines (330 loc) · 11 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
---
## C++, latest standard.
Language: Cpp
Standard: Latest
## How far `public:`, `private:`, and `protected:` are indented.
AccessModifierOffset: -4
## If a function decl or call's opening paren is at the end of a line,
## format its arguments like so:
##
## int foo(
## int a,
## int b
## );
##
AlignAfterOpenBracket: BlockIndent
## Don’t align arrays or initialiser lists.
AlignArrayOfStructures: None
## Don’t align assignments because that leads to too much extra whitespace.
AlignConsecutiveAssignments: None
## So is aligning bitfields.
AlignConsecutiveBitFields: Consecutive
## Same as declarations: nope.
AlignConsecutiveDeclarations: None
## Aligning macros is usually fine tho.
AlignConsecutiveMacros: Consecutive
## Escaped newlines in macros should be aligned like so:
##
## #define foo(x) \
## do { \
## bar(x); \
## baz(x); \
## } while (0)
AlignEscapedNewlines: Left
## Align operands of binary expressions like so:
##
## int a = 1 + 2 + 3 + 4
## + 5 + 6 + 7 + 8
## + 9 + 10;
##
## Note: BreakBeforeBinaryOperators also needs to be set appropriately.
AlignOperands: AlignAfterOperator
## This option also allows you to define across how many empty
## lines comments should be aligned, but I don’t want that so
## I just use a bool here.
##
## This aligns comments like so:
##
## int bar = 42; /// Comment.
## std::string foobarbaz = ""; /// Another comment.
AlignTrailingComments: true
## Don’t allow this:
##
## foobarbaz(
## a, b, c, d);
##
## Instead, BinPackArguments will format it like so:
##
## foobarbaz(
## a,
## b,
## c,
## d
## );
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
## Allow these:
##
## for (;;) { foo(); }
##
## case 1: foo(); break;
##
## enum { A, B };
##
## int foo() { bar(); }
##
## if (foo()) bar();
## else baz();
##
## auto lambda []() { return 0; }
##
## for (;;) foo();
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: true
AllowShortEnumsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: AllIfsAndElse
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: true
## Don’t do this horribleness, ever:
##
## int
## foo() { ...
AlwaysBreakAfterReturnType: None
## Break before multiline strings like so:
##
## auto s =
## "This is a "
## "multiline string.";
AlwaysBreakBeforeMultilineStrings: true
## Don’t force break template declarations (i.e. the template
## param list and the rest of the signature/definition may be
## on the same line).
AlwaysBreakTemplateDeclarations: No
## Identifiers that should be interpreted as attributes.
AttributeMacros: ['__forceinline']
## Function parameters are either all on the same line,
## or all on separate lines.
BinPackArguments: false
BinPackParameters: false
## Space before and after the ':' in bitfields.
BitFieldColonSpacing: Both
## Leave line breaks around attributes alone.
BreakAfterAttributes: Leave
## Break *after*, and not before operators.
BreakBeforeBinaryOperators: None
## NEVER put opening braces on a new line.
BreakBeforeBraces: Attach
## This is AlwaysBreakTemplateDeclarations, but for concept decls.
BreakBeforeConceptDeclarations: Allowed
## Put the colons of multiline inline ASM on new lines.
BreakBeforeInlineASMColon: OnlyMultiline
## Format ternaries like so:
##
## auto foo = bar
## ? baz
## : qux;
BreakBeforeTernaryOperators: true
## Format ctors like so:
##
## Constructor()
## : bar(42)
## , baz(23)
#BreakConstructorInitializers: BeforeComma
## Same thing, but for class declarations.
BreakInheritanceList: BeforeComma
## Allow breaking long string literals across multiple lines.
BreakStringLiterals: true
## This disables the column limit. Rather unintuitively, this is
## also the only way to get clang-format to not remove all manually
## inserted line breaks.
ColumnLimit: 0
## Nested namespace declarations are on different lines. If they
## should be on the same line, just write `namespace foo::bar` instead.
CompactNamespaces: false
## Set to the same value as IndentWidth.
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
## Format braced init lists appropriately.
##
## > Fundamentally, C++11 braced lists are formatted exactly like
## > function calls would be formatted in their place. If the braced
## > list follows a name (e.g. a type or variable name), clang-format
## > formats as if the {} were the parentheses of a function call with
## > that name.
Cpp11BracedListStyle: true
## Do NOT attempt to infer pointer alignment. Format it to what I want
## it to be.
DerivePointerAlignment: false
## Duh.
DisableFormat: false
## Never put empty lines after `private:` etc.
EmptyLineAfterAccessModifier: Never
## Empty lines before access modifiers should be left alone.
EmptyLineBeforeAccessModifier: Leave
## Insert a `// namespace foo` comment after the closing brace of a
## namespace.
FixNamespaceComments: true
## Macros that should be formatted like the `for` keyword.
ForEachMacros: ["repeat", "until"]
## Same thing, but for `if`.
IfMacros: []
## Merge include blocks, sort them, and resplit.
IncludeBlocks: Regroup
## Enable outdenting `private:`.
# NOTE: This setting currently causes the content of structs
# to be indented twice.
#IndentAccessModifiers: true
## Don’t indent case blocks. Note, this is not about case *labels*,
## but the actual blocks of code. The labels *will* be indented, so
## we don’t need any extra indentation here.
IndentCaseBlocks: false
## Indent `case foo:` relative to the `switch`. We do this is because,
## otherwise, we can end up w/ two `}` on the same line like so:
##
## switch (foo) {
## case 1: {
## bar();
## break;
## }
## }
IndentCaseLabels: true
## We disable indenting the contents of `extern "C" {}` blocks, simply
## because indentation in such blocks is pretty useless as they tend to
## be rather long and often enough, an entire file would just end up
## being indented more than it needs to be.
IndentExternBlock: NoIndent
## We want goto labels to be indented relative to the current scope.
IndentGotoLabels: true
## Indent CPP directives after the `#` sign.
IndentPPDirectives: AfterHash
## Do NOT indent requires clauses.
IndentRequiresClause: false
## Four spaces. This is the only correct value.
IndentWidth: 4
## This should never happen anyway, but just in case, don’t.
IndentWrappedFunctionNames: false
## This would do the opposite of what I have spent far too much
## time to fix manually.
InsertBraces: false
## I keep forgetting about this, and I’d prefer to be consistent
## about it, so, therefore:
InsertNewlineAtEOF: true
## Format integer literals:
IntegerLiteralSeparator:
Binary: 4
Decimal: 3
Hex: 4
## This one is pretty self-explanatory.
KeepEmptyLinesAtTheStartOfBlocks: false
## Indent lambda bodies relative to the outer scope, and not
## relative to the indentation of the signature.
LambdaBodyIndentation: OuterScope
## Use LF, never CRLF.
LineEnding: LF
## Don’t allow multiple consecutive empty lines.
MaxEmptyLinesToKeep: 1
## Don’t indent namespaces. See the `extern "C"` option above,
## for more information as to why we disable this.
NamespaceIndentation: None
## Reuse IndentWidth.
PPIndentWidth: -1
## Format ctor initialisers sensibly. Put all of them on the same line if
## they fit, and put them on separate lines if they don’t.
#PackConstructorInitializers: CurrentLine
## We don’t want this to happen. Ever.
PenaltyReturnTypeOnItsOwnLine: 4294967295
## Left for C++, Right for C.
PointerAlignment: Left
## Leave qualifiers where they are as the docs state that this option
## may lead to incorrect code.
QualifierAlignment: Leave
## I suck at being consistent about this, so therefore:
## TODO: Figure out why CLion’s clang-format is rejecting this...
#QualifierOrder: ['friend', 'static', 'inline', 'constexpr', 'const', 'volatile', 'restrict', 'type']
## Should always be left, unless C decides to add references some day.
ReferenceAlignment: Left
## Allow reflowing comments. Not sure if this does anything since we’ve disabled the col limit.
ReflowComments: true
## Requires clauses go on a separate line.
RequiresClausePosition: OwnLine
## Thank goodness they finally added this. The default formatting used to be
## absolutely atrocious, because no, I don’t want all of my concept declarations
## to be indented 10 spaces or whatnot.
RequiresExpressionIndentation: OuterScope
## I know better when to separate stuff than clang-format.
SeparateDefinitionBlocks: Leave
## Five lines is short, I guess.
ShortNamespaceLines: 5
## Sort include directives.
SortIncludes: CaseInsensitive
## Sort using decls alphabetically.
# TODO: Set to Lexicographic
SortUsingDeclarations: true
## Space after C-style cast.
SpaceAfterCStyleCast: true
## No space after `!`.
SpaceAfterLogicalNot: false
## Put a space after `template`
SpaceAfterTemplateKeyword: true
## Ignore this option and use PointerAlignment instead.
SpaceAroundPointerQualifiers: Default
## Put spaces around `=` and friends.
SpaceBeforeAssignmentOperators: true
## We *definitely* don’t want spaces before a case colon.
SpaceBeforeCaseColon: false
## We want to treat init lists like function calls, so no space.
SpaceBeforeCpp11BracedList: false
## Funnily enough, we *do* want spaces before these colons
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeRangeBasedForLoopColon: true
## Spaces before parens:
SpaceBeforeParens: Custom
SpaceBeforeParensOptions:
AfterControlStatements: true
AfterForeachMacros: true
AfterFunctionDeclarationName: false
AfterFunctionDefinitionName: false
AfterIfMacros: true
AfterOverloadedOperator: false
AfterRequiresInClause: true
AfterRequiresInExpression: true
BeforeNonEmptyParentheses: false
## No space before subscripts.
SpaceBeforeSquareBrackets: false
## Empty block should be {}, not { }.
SpaceInEmptyBlock: false
## Same thing for parens.
SpaceInEmptyParentheses: false
## At least one space before trailing comments.
SpacesBeforeTrailingComments: 1
## Never put spaces in angle brackets.
SpacesInAngles: Never
## We definitely don’t want this.
SpacesInCStyleCastParentheses: false
## Or this.
SpacesInConditionalStatement: false
## Spaces at the beginning of line comments.
## Minimum: At least one.
## Maximum: More are allowed.
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: -1
## Disable this too.
SpacesInParentheses: false
## And this.
SpacesInSquareBrackets: false
## Currently not used, but it’s here for future reference.
StatementAttributeLikeMacros: []
## Macros that should be treated as statements.
StatementMacros: []
## Tabs are four columns.
TabWidth: 4
## Macros that create type names.
TypenameMacros: []
## NEVER use tabs. They only cause problems.
UseTab: Never
## Some macros care about whitespace.
WhitespaceSensitiveMacros: ['STR', 'STR_']
...