-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy path.clang-format
514 lines (406 loc) · 15.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
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
# TdS Auto clang-format configuration file (clang-format 6.0)
#
# Use:
# - Install clang-format-6.0
# >sudo apt-get install clang-format-6.0
# (or sudo aptitude install, ...)
# - Put the .clang-format file in the working directory
# - For avoiding problems: put a "default" .clang-format configuration file in
# the home repertory Either this one or a simple one with at least the
# "Langage" and "BasedOnStyle" properties
# - Execute clang-format
# >clang-format-6.0 -i -style=file <fileName1>.cpp
# If several files:
# >clang-format-6.0 -i -style=file <fileName1>.cpp <fileName2>.hpp ...
# Note: the -i option tells clang-format to modify the file rather than
# creating a new one
#
# For formatting a lot of files:
# >find . -name "*hpp" -exec clang-format-6.0 -i -style=file {} \;
# >find . -name "*cpp" -exec clang-format-6.0 -i -style=file {} \;
# Format all the files in the current folder (including subfolders)
# For immunizing a section against clang-format, encapsulate it with the
# the comments "clang-format off" and "clang-format on"
# // clang-format off
# ...
# // clang-format on
# For more information on the available properties and their possible value
# http://releases.llvm.org/6.0.1/tools/clang/docs/ClangFormatStyleOptions.html
# Language
Language: Cpp
# All values are set by default according to this convention
# These value are then overriden with the ones specified in this file
# -> Here we are closer to mozilla and chromium
BasedOnStyle: Chromium
# The extra indent or outdent of access modifiers, e.g. public:
# -> Set to -(the indentation) so that these modifiers are not indented
AccessModifierOffset: -4
# Alignement of inputs inside a round brackets (parentheses), angle brackets and
# square brackets
# when there is not enough space on a same line
# -> Align: stack them, one per line, vertically aligned with the first
# character of the first input
# someLongFunction(argument1,
# argument2)
AlignAfterOpenBracket: Align
# If not None, when using initialization for an array of structs aligns the fields into columns.
# Possible values: Left, Right, None
AlignArrayOfStructures: None
# If true, aligns consecutive assignments
# -> false: since it can be strange when types with different length are near
# each other
AlignConsecutiveAssignments: false
AlignConsecutiveBitFields: false
# If true, aligns consecutive declarations
# -> false: since it can be strange when types with different length are near
# each other
AlignConsecutiveDeclarations: false
AlignConsecutiveMacros: false
# Options for aligning backslashes in escaped newlines
# -> Align: escaped newlines as far left as possible
# #define A \
# int aaaa; \
# int b; \
# int dddddddddd;
AlignEscapedNewlines: Left
# If true, horizontally align operands of binary and ternary expressions
# -> true: aligns operands of a single expression that needs to be split over
# multiple lines
# int aaa = bbbbbbbbbbbbbbb +
# ccccccccccccccc;
AlignOperands: true
# If true, aligns trailing comments
# -> true: this is cleaner
# int a // Comment
# Vector3f b // Comment
# double* c // Comment
AlignTrailingComments: true
# We favor breaking between arguments
AllowAllArgumentsOnNextLine: false
# If the function declaration doesn’t fit on a line, allow putting all
# parameters of a function declaration onto the next line even if
# BinPackParameters is false.
# -> false: Not allowed, split in one per line
# void myFunction(int a,
# int b,
# int c,
# int d,
# int e);
AllowAllParametersOfDeclarationOnNextLine: false
AllowBreakBeforeNoexceptSpecifier: Never
# If true, allows contracting simple braced statements to a single line
# -> false: Not allowed for the sake of absolute clarity
AllowShortBlocksOnASingleLine: false
# No short instructions on single line
AllowShortEnumsOnASingleLine: false
# If true, short case labels will be contracted to a single line
# -> false: Not allowed, only one instruction per line
AllowShortCaseLabelsOnASingleLine: false
# If true int f() { return 0; } can be put on a single line
# -> false: Not allowed, skip a line after a brace
AllowShortFunctionsOnASingleLine: false
# If true, if (a) return; can be put on a single line
# -> false: Not allowed
AllowShortIfStatementsOnASingleLine: false
# Exception to our "no single line" rule,
# to allow for lambda-based one liners:
# std::sort(vec.begin(), vec.end(), [](auto v) { return v.a < v.b; });
AllowShortLambdasOnASingleLine: All
# If true, while (true) continue; can be put on a single line
# -> false: Not allowed
AllowShortLoopsOnASingleLine: false
# The function declaration return type breaking style to use
# -> None: Break after return type automatically,
# according to penalty system
AlwaysBreakAfterReturnType: None
# If true, always break before multiline string literals
# -> false
AlwaysBreakBeforeMultilineStrings: false
# If true, always break after the template<...> of a template declaration
# -> true: faster identification of templated objects
# template <typename T>
# class C {};
AlwaysBreakTemplateDeclarations: true
# If false, a function call’s arguments will either be all on the same line or
# will have one line each
# -> false, can look messy otherwise
BinPackArguments: false
# 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, can look messy otherwise
BinPackParameters: false
# BraceWrapping: ignored since BreakBeforeBraces is not set to custom
# This field specifies how to treat each kind of braces when the property
# BreakBeforeBraces is set to custom
# In this file, BreakBeforeBraces is set to Allman which treats all the braces
# the same way: break before all braces
# See BreakBeforeBraces
# The way to wrap binary operators when expression are too long to hold on a
# single line
# -> All: Break before operators, so that they can easily be identified at the
# beginning of the line
#
# LooooooooooongType loooooooooooooooooooooongVariable
# = someLooooooooooooooooongFunction();
#
# bool value
# = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
# + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
# == aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
# && aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
# > ccccccccccccccccccccccccccccccccccccccccc;
BreakBeforeBinaryOperators: All
# The brace breaking style to use
# -> Allman: Always break before braces, longer but clearer files
BreakBeforeBraces: Allman
# If true, in the class inheritance expression clang-format will break
# before ":" and "," if there is multiple inheritance
# -> false: breaking is overkill here most of the time
BreakBeforeInheritanceComma: false
# If true, ternary operators will be placed after line breaks
# -> true: for consistency with BreakBeforeBinaryOperators
BreakBeforeTernaryOperators: true
# The constructor initializers style to use
# -> AfterColon: Break constructor initializers after the colon and commas
# because alone comma at the beginning of the line is ugly
BreakConstructorInitializers: AfterColon
# Allow breaking string literals when formatting
# -> true: clang format does it better than you
BreakStringLiterals: true
# Maximum number of characters per line
# -> 100: Historically 80 for C++, but quite deprecated today; it is dicutable
# but 100 seemed to be more adequat in our case.
ColumnLimit: 100
# A regular expression that describes comments with special meaning, which
# should not be split into lines or otherwise changed
# -> default value
CommentPragmas: '^ IWYU pragma:'
# If true, consecutive namespace declarations will be on the same line. If
# false, each namespace is declared on a new line
# -> false: one line per namespace, ugly otherwise
CompactNamespaces: false
# The number of characters to use for indentation of constructor initializer
# lists
# -> 4 Same indentation level as the block instructions
ConstructorInitializerIndentWidth: 4
# Indent width for line continuations
# -> 2: So that it is differenciable from other identations
ContinuationIndentWidth: 2
# If true, format braced lists as best suited for C++11 braced lists
# -> true
Cpp11BracedListStyle: true
# If 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
# -> false: allways use the convention specified in this file
DerivePointerAlignment: false
# Disables formatting completely
# -> false
DisableFormat: false
# No line between access modifier and code
EmptyLineAfterAccessModifier: Never
# Always one line before public/private/protected
# to clearly separate the following block
EmptyLineBeforeAccessModifier: Always
# If true, clang-format detects whether function calls and definitions are
# formatted with one parameter per line
# -> false: allways use the convention specified in this file
ExperimentalAutoDetectBinPacking: false
# If true, clang-format adds missing namespace end comments and fixes invalid
# existing ones
# -> true: add a lot of clarity to these endless braces at the end of a file
FixNamespaceComments: true
# A vector of macros that should be interpreted as foreach loops instead of as
# function calls.
# -> no macro
ForEachMacros: [ ]
# Use include blocks
IncludeBlocks: Regroup
# First main header, then std libs, then boost, then yuni, then antares
IncludeCategories:
# antares headers with "
- Regex: '^"antares/.*'
Priority: 10
SortPriority: 10
CaseSensitive: false
# antares headers with <
- Regex: '^<antares/.*'
Priority: 10
SortPriority: 9
CaseSensitive: false
# Main yuni headers need to go first...
- Regex: '^(<|")yuni/(yuni|core).h(>|")'
Priority: 5
SortPriority: 4
# yuni headers
- Regex: '^(<|")yuni/.*'
Priority: 5
CaseSensitive: false
# boost
- Regex: '^(<|")boost/.*'
Priority: 2
# stdlib
- Regex: '^<.*'
Priority: 1
CaseSensitive: false
# everything else (targets to be internal lib headers)
- Regex: '.*'
Priority: 15
CaseSensitive: false
# Definition of main header of a cpp file
IncludeIsMainRegex: '([-_](test))?$'
IncludeIsMainSourceRegex: ''
# public/private/protected not indented
IndentAccessModifiers: false
IndentCaseBlocks: false
# Indent case labels one level from the switch statement
# -> false
IndentCaseLabels: false
IndentExternBlock: NoIndent
IndentGotoLabels: false
# The preprocessor directive indenting style to use
# -> None: never indent preprocessor directives
IndentPPDirectives: None
IndentRequiresClause: false
# The number of columns to use for indentation
# -> 4: Good compromise between visible and limiting additional spaces
IndentWidth: 4
# Indent if a function definition or declaration is wrapped after the type
# -> false: so that function name remains at indentation level
IndentWrappedFunctionNames: false
# We always use braces to identify blocks, even one-lines
InsertBraces: true
# This is standard
InsertNewlineAtEOF: true
# Leave integer literals as they are
IntegerLiteralSeparator:
Binary: 0
Decimal: 0
Hex: 0
# Remove unnecessary empty lines
KeepEmptyLinesAtEOF: false
# If true, the empty line at the start of blocks is kept
# -> false: this is useless
KeepEmptyLinesAtTheStartOfBlocks: false
# Indent lambda according to its signature, to make it clear it relates to it
LambdaBodyIndentation: Signature
# Ensure consistent use of unix like EOF.
LineEnding: LF
# The maximum number of consecutive empty lines to keep
# -> 1: Use comments to differenciate important parts of a big portion of code
# (or split it into functions for instance) rather than a big block of
# empty lines
MaxEmptyLinesToKeep: 1
# The indentation used for namespaces
# -> None: Do not add an indentation level
NamespaceIndentation: None
# Each constructor initializer on its own line.
PackConstructorInitializers: Never
# Penalties are used to decide where to break long lines,
# when multiple alternatives are possible.
# We use a "high" cost for breaking before assignment and first parameter,
# to favor breaking between function parameters and chained methods.
PenaltyBreakAssignment: 1000
PenaltyBreakBeforeFirstCallParameter: 100
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakOpenParenthesis: 0
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
# Important to allow method chaining,
# and not breaking assignment or after function parenthesis
PenaltyIndentedWhitespace: 0
PenaltyReturnTypeOnItsOwnLine: 200
# Pointer and reference alignment style
# -> Left: the type of a variable is at its left, and the * or the & are part of
# this type
PointerAlignment: Left
# const goes before type
QualifierAlignment: Left
# & and * go with type, not variable name
ReferenceAlignment: Left
# If true, clang-format will attempt to re-flow comments
# -> true: because clang-format does it better than you
ReflowComments: true
# No unnecessary ;
RemoveSemicolon: true
# Concept-related options to be discussed at some point
RequiresClausePosition: OwnLine
RequiresExpressionIndentation: OuterScope
# Always have empty lines between function and classes definitions
SeparateDefinitionBlocks: Always
# If true, clang-format will sort #includes
# -> false: see coding guidelines
SortIncludes: true
# If true, clang-format will sort using declarations
# -> LexicographicNumeric to take into account sub-namespaces
SortUsingDeclarations: LexicographicNumeric
# If true, a space is inserted after C style casts
# -> false
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
# If true, a space will be inserted after the ‘template’ keyword
# -> false
SpaceAfterTemplateKeyword: false
# If false, spaces will be removed before assignment operators
# -> true
SpaceBeforeAssignmentOperators: true
# "case 1: break;" instead of "case 1 : break;"
SpaceBeforeCaseColon: false
# Foo foo{ bar };
SpaceBeforeCpp11BracedList: false
# Foo::Foo(): a(a) {}
SpaceBeforeCtorInitializerColon: false
# class Foo: Bar {}
SpaceBeforeInheritanceColon: false
# Defines in which cases to put a space before opening parentheses
# -> ControlStatements: Before if/while/for statements
SpaceBeforeParens: ControlStatements
# for (auto v: values) {}
SpaceBeforeRangeBasedForLoopColon: false
# int a[5]
SpaceBeforeSquareBrackets: false
# void f() {}
SpaceInEmptyBlock: false
# If true, spaces may be inserted into ()
# -> false
SpaceInEmptyParentheses: false
# The number of spaces before trailing line comments (// - comments)
# -> 1
SpacesBeforeTrailingComments: 1
# If true, spaces will be inserted after < and before > in template argument
# lists
# -> false
SpacesInAngles: false
# If true, spaces may be inserted into C style casts
# -> false
SpacesInCStyleCastParentheses: false
# If true, spaces are inserted inside container literals (e.g. ObjC and
# Javascript array and dict literals)
# -> false
SpacesInContainerLiterals: false
# Minimum one space to separate the start of the comment
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: -1
# If true, spaces will be inserted after ( and before )
# -> false
# SpacesInParentheses: false
# Keep previous behaviour with SpacesInParentheses: false
SpacesInParens: Never
# If true, spaces will be inserted after [ and before ]. Lambdas or unspecified
# size array declarations will not be affected
# -> false
SpacesInSquareBrackets: false
# Format compatible with this standard, e.g. use A<A<int> > instead of A<A<int>>
# for LS_Cpp03
Standard: c++20
# The number of columns used for tab stops
# Note: this property is not used since tabs are forbidden (see UseTab)
# -> 8
TabWidth: 8
# The way to use tab characters in the resulting file
# -> Never: Allways use spaces
UseTab: Never