-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.clang-format
423 lines (356 loc) · 11.9 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
# -----------------------------------------------------------------------------
# Language
# -----------------------------------------------------------------------------
Language: Cpp
Standard: Latest
Cpp11BracedListStyle: true
# -----------------------------------------------------------------------------
# Common
# -----------------------------------------------------------------------------
# Numeric
TabWidth: 4
IndentWidth: 4
ColumnLimit: 80
PPIndentWidth: 1
MaxEmptyLinesToKeep: 1
AccessModifierOffset: -2
ContinuationIndentWidth: 4
SpacesBeforeTrailingComments: 1
# Enable/Disable/Option
UseTab: Never
LineEnding: DeriveLF
BinPackArguments: false
BinPackParameters: false
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakAfterDefinitionReturnType: All
# -----------------------------------------------------------------------------
# Not so common
# -----------------------------------------------------------------------------
SortIncludes: false
InsertBraces: false
ReflowComments: false
RemoveSemicolon: false
RemoveBracesLLVM: false
PointerAlignment: Right
QualifierAlignment: Leave
InsertNewlineAtEOF: true
InsertTrailingCommas: None
BitFieldColonSpacing: Both
SeparateDefinitionBlocks: Leave
KeepEmptyLinesAtTheStartOfBlocks: false
ExperimentalAutoDetectBinPacking: false
# -----------------------------------------------------------------------------
# Align X
# -----------------------------------------------------------------------------
AlignOperands: Align
AlignEscapedNewlines: Left
AlignAfterOpenBracket: AlwaysBreak
AlignArrayOfStructures: None
AlignTrailingComments: false
AlignConsecutiveBitFields: false
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
# -----------------------------------------------------------------------------
# Indent X
# -----------------------------------------------------------------------------
IndentCaseLabels: false
IndentCaseBlocks: false
IndentExternBlock: AfterExternBlock
IndentPPDirectives: AfterHash
IndentAccessModifiers: false
IndentWrappedFunctionNames: false
# -----------------------------------------------------------------------------
# Break X, Before X, After X
# -----------------------------------------------------------------------------
# X
BreakArrays: true
BreakStringLiterals: false
# Before X
BreakBeforeBraces: Linux
BreakBeforeBinaryOperators: All
BreakBeforeTernaryOperators: true
BreakBeforeConceptDeclarations: Always
# After X
BreakAfterReturnType: All
BreakAfterAttributes: Always
# -----------------------------------------------------------------------------
# Space Before X, In X, After X
# -----------------------------------------------------------------------------
# Before
SpaceBeforeParens: ControlStatements
SpaceBeforeCaseColon: false
SpaceBeforeSquareBrackets: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeRangeBasedForLoopColon: false
# In
SpacesInAngles: Never
SpaceInEmptyBlock: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceInEmptyParentheses: false
SpacesInContainerLiterals: false
SpacesInConditionalStatement: false
SpacesInCStyleCastParentheses: false
# After
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
# -----------------------------------------------------------------------------
# Allow X On A Single Line
# -----------------------------------------------------------------------------
AllowShortEnumsOnASingleLine: true
AllowShortLoopsOnASingleLine: false
AllowShortBlocksOnASingleLine: Never
AllowShortLambdasOnASingleLine: Empty
AllowShortFunctionsOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: Never
# -----------------------------------------------------------------------------
# Allow X On Next Line
# -----------------------------------------------------------------------------
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
# -----------------------------------------------------------------------------
# Macros
# -----------------------------------------------------------------------------
IfMacros:
- 'if_test'
ForEachMacros:
- 'for_each_builtin'
- 'for_each_string_list_item'
- 'for_each_ut'
- 'for_each_wanted_builtin'
- 'hashmap_for_each_entry'
- 'hashmap_for_each_entry_from'
- 'kh_foreach'
- 'kh_foreach_value'
- 'list_for_each'
- 'list_for_each_dir'
- 'list_for_each_prev'
- 'list_for_each_prev_safe'
- 'list_for_each_safe'
- 'strintmap_for_each_entry'
- 'strmap_for_each_entry'
- 'strset_for_each_entry'
# -----------------------------------------------------------------------------
# Penalties
# -----------------------------------------------------------------------------
PenaltyBreakString: 10
PenaltyBreakComment: 10
PenaltyBreakAssignment: 10
PenaltyExcessCharacter: 100
PenaltyBreakFirstLessLess: 0
PenaltyReturnTypeOnItsOwnLine: 0
PenaltyBreakBeforeFirstCallParameter: 30
# -----------------------------------------------------------------------------
# May be useful
# -----------------------------------------------------------------------------
# BraceWrapping:
# AfterCaseLabel: false
# AfterClass: true
# AfterControlStatement: Never
# AfterEnum: false
# AfterExternBlock: false
# AfterFunction: true
# AfterNamespace: true
# AfterObjCDeclaration: false
# AfterStruct: false
# AfterUnion: false
# BeforeCatch: false
# BeforeElse: false
# BeforeLambdaBody: false
# BeforeWhile: false
# IndentBraces: false
# SplitEmptyFunction: true
# SplitEmptyRecord: true
# SplitEmptyNamespace: true
# DerivePointerAlignment: false
# RequiresClausePosition: OwnLine
# EmptyLineAfterAccessModifier: Never
# EmptyLineBeforeAccessModifier: LogicalBlock
# RequiresExpressionIndentation: OuterScope
# -----------------------------------------------------------------------------
# Original clang-format of git/git.git
# -----------------------------------------------------------------------------
## This file is an example configuration for clang-format 5.0.
##
## Note that this style definition should only be understood as a hint
## for writing new code. The rules are still work-in-progress and does
## not yet exactly match the style we have in the existing code.
##
## Use tabs whenever we need to fill whitespace that spans at least from one tab
## stop to the next one.
##
## These settings are mirrored in .editorconfig. Keep them in sync.
#UseTab: Never
#TabWidth: 4
#IndentWidth: 4
#ContinuationIndentWidth: 4
#ColumnLimit: 80
## C Language specifics
#Language: Cpp
## Align parameters on the open bracket
## someLongFunction(argument1,
## argument2);
#AlignAfterOpenBracket: Align
## Don't align consecutive assignments
## int aaaa = 12;
## int b = 14;
#AlignConsecutiveAssignments: false
## Don't align consecutive declarations
## int aaaa = 12;
## double b = 3.14;
#AlignConsecutiveDeclarations: false
## Align escaped newlines as far left as possible
## #define A \
## int aaaa; \
## int b; \
## int cccccccc;
#AlignEscapedNewlines: Left
## Align operands of binary and ternary expressions
## int aaa = bbbbbbbbbbb +
## cccccc;
#AlignOperands: true
## Don't align trailing comments
## int a; // Comment a
## int b = 2; // Comment b
#AlignTrailingComments: false
## By default don't allow putting parameters onto the next line
## myFunction(foo, bar, baz);
#AllowAllParametersOfDeclarationOnNextLine: false
## Don't allow short braced statements to be on a single line
## if (a) not if (a) return;
## return;
#AllowShortBlocksOnASingleLine: false
#AllowShortCaseLabelsOnASingleLine: false
#AllowShortFunctionsOnASingleLine: false
#AllowShortIfStatementsOnASingleLine: false
#AllowShortLoopsOnASingleLine: false
## By default don't add a line break after the return type of top-level functions
## int foo();
#AlwaysBreakAfterReturnType: None
## Pack as many parameters or arguments onto the same line as possible
## int myFunction(int aaaaaaaaaaaa, int bbbbbbbb,
## int cccc);
#BinPackArguments: true
#BinPackParameters: true
## Add no space around the bit field
## unsigned bf:2;
#BitFieldColonSpacing: None
## Attach braces to surrounding context except break before braces on function
## definitions.
## void foo()
## {
## if (true) {
## } else {
## }
## };
#BreakBeforeBraces: Linux
## Break after operators
## int value = aaaaaaaaaaaaa +
## bbbbbb -
## ccccccccccc;
#BreakBeforeBinaryOperators: None
#BreakBeforeTernaryOperators: false
## Don't break string literals
#BreakStringLiterals: false
## Use the same indentation level as for the switch statement.
## Switch statement body is always indented one level more than case labels.
#IndentCaseLabels: false
## Indents directives before the hash. Each level uses a single space for
## indentation.
## #if FOO
## # include <foo>
## #endif
#IndentPPDirectives: AfterHash
#PPIndentWidth: 1
## Don't indent a function definition or declaration if it is wrapped after the
## type
#IndentWrappedFunctionNames: false
## Align pointer to the right
## int *a;
#PointerAlignment: Right
## Don't insert a space after a cast
## x = (int32)y; not x = (int32) y;
#SpaceAfterCStyleCast: false
## No space is inserted after the logical not operator
#SpaceAfterLogicalNot: false
## Insert spaces before and after assignment operators
## int a = 5; not int a=5;
## a += 42; a+=42;
#SpaceBeforeAssignmentOperators: true
## Spaces will be removed before case colon.
## case 1: break; not case 1 : break;
#SpaceBeforeCaseColon: false
## Put a space before opening parentheses only after control statement keywords.
## void f() {
## if (true) {
## f();
## }
## }
#SpaceBeforeParens: ControlStatements
## Don't insert spaces inside empty '()'
#SpaceInEmptyParentheses: false
## No space before first '[' in arrays
## int a[5][5]; not int a [5][5];
#SpaceBeforeSquareBrackets: false
## No space will be inserted into {}
## while (true) {} not while (true) { }
#SpaceInEmptyBlock: false
## The number of spaces before trailing line comments (// - comments).
## This does not affect trailing block comments (/* - comments).
#SpacesBeforeTrailingComments: 1
## Don't insert spaces in casts
## x = (int32) y; not x = ( int32 ) y;
#SpacesInCStyleCastParentheses: false
## Don't insert spaces inside container literals
## var arr = [1, 2, 3]; not var arr = [ 1, 2, 3 ];
#SpacesInContainerLiterals: false
## Don't insert spaces after '(' or before ')'
## f(arg); not f( arg );
#SpacesInParentheses: false
## Don't insert spaces after '[' or before ']'
## int a[5]; not int a[ 5 ];
#SpacesInSquareBrackets: false
## Insert a space after '{' and before '}' in struct initializers
#Cpp11BracedListStyle: false
## A list of macros that should be interpreted as foreach loops instead of as
## function calls. Taken from:
## git grep -h '^#define [^[:space:]]*for_\?each[^[:space:]]*(' |
## sed "s/^#define / - '/; s/(.*$/'/" | sort | uniq
#ForEachMacros:
# - 'for_each_builtin'
# - 'for_each_string_list_item'
# - 'for_each_ut'
# - 'for_each_wanted_builtin'
# - 'hashmap_for_each_entry'
# - 'hashmap_for_each_entry_from'
# - 'kh_foreach'
# - 'kh_foreach_value'
# - 'list_for_each'
# - 'list_for_each_dir'
# - 'list_for_each_prev'
# - 'list_for_each_prev_safe'
# - 'list_for_each_safe'
# - 'strintmap_for_each_entry'
# - 'strmap_for_each_entry'
# - 'strset_for_each_entry'
## A list of macros that should be interpreted as conditionals instead of as
## function calls.
#IfMacros:
# - 'if_test'
## The maximum number of consecutive empty lines to keep.
#MaxEmptyLinesToKeep: 1
## No empty line at the start of a block.
#KeepEmptyLinesAtTheStartOfBlocks: false
## Penalties
## This decides what order things should be done if a line is too long
#PenaltyBreakAssignment: 10
#PenaltyBreakBeforeFirstCallParameter: 30
#PenaltyBreakComment: 10
#PenaltyBreakFirstLessLess: 0
#PenaltyBreakString: 10
#PenaltyExcessCharacter: 100
#PenaltyReturnTypeOnItsOwnLine: 60
## Don't sort #include's
#SortIncludes: false