-
Notifications
You must be signed in to change notification settings - Fork 1
/
.clang-format
268 lines (245 loc) · 7.79 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
##====---- ./.clang-format - Clang-Format configuration ----====##
##
## For the Sudoku project, learning cpp
##====--------------------------------------------------------------------====##
## Documentation:
## https://clang.llvm.org/docs/ClangFormatStyleOptions.html
##
## Disable locally:
## // clang-format off
## ...
## // clang-format on
##
## Report formatting errors: # Clang 11
## > clang-format --style=file --dry-run --Werror ./**/*.h ./**/*.cpp
## Apply formatting on project:
## > clang-format --i --style=file ./**/*.h ./**/*.cpp
##
##====--------------------------------------------------------------------====##
##
## TOC
## - Sizes
## - Comments
## - Include
## - Namespace
## - Template
## - Using
## - Blocks
## -Single-Line Statements
## - Braces
## - Functions
## - Constructors
## - Operators
## - Strings
## - Penalties
## - Languages
##
## Updated for Clang-Format v10.0.0
##
---
# For starters use defaults from the LLVM style
# (required since the complete rule set is needed)
BasedOnStyle: LLVM
DeriveLineEnding: false # Clang 10
UseCRLF: false # Clang 10
UseTab: ForContinuationAndIndentation
## Sizes
TabWidth: 4
IndentWidth: 4
ColumnLimit: 80
MaxEmptyLinesToKeep: 2
ContinuationIndentWidth: 4
IndentCaseBlocks: true # Clang 11
IndentCaseLabels: false
IndentExternBlock: AfterExternBlock # Clang 11
IndentGotoLabels: false # Clang 10
IndentPPDirectives: None
AccessModifierOffset: -4
# public: or private: etc.
## Comments
ReflowComments: true
SpacesBeforeTrailingComments: 1
AlignTrailingComments: true
CommentPragmas: '^ NOLINT'
## Include
# #include <xxx> STL includes
# #include <xxx.h> library includes
# #include "xxx.h" local project includes
#
# Order: (alphabetic within each)
# Headers should not depend upon other headers being included first.
#
# #pragma once // if header file
# -1 Precompiled header // if cpp and using a precompiled header
# 0 Main Module Header // if cpp
# 0 Local components // if used "..."
# 1 External components // <Sudoku/*.h>
# 2 Other libraries // ! add all used! like abseil or the gsl
# 3 Other includes // <.*>
# 4 STL data-structures // ! add all known
# 5 STL other
# 6 Forward declaration // *.fwd.h for recursive external definitions
# 7 Testing framework // macro-heavy
# 8 C standard headers // like <cassert>
IncludeBlocks: Regroup
SortIncludes: true
IncludeIsMainRegex: '(_test)?$'
#IncludeIsMainSourceRegex: '(Impl\.h(pp)?)$' # Clang 10
IncludeCategories:
- Regex: '^"([Pp]recompiled|stdafx)'
Priority: -1
- Regex: '\.fwd\.h(pp)?"$'
Priority: 6
- Regex: '^[\"<](Sudoku|Strategic)[/\\]'
Priority: 1
- Regex: '^<(absl|boost|gsl)[\/\\>]'
Priority: 1
SortPriority: 2
- Regex: '^<(array|vector|deque|stack|queue|string(_view)?|span|((initializer|forward)_)?list|(unordered_)?(set|map)|bitset|tuple|optional|variant|any)>'
Priority: 4
- Regex: '^<(gtest|gmock|catch)'
Priority: 7
- Regex: '^<c(assert|errno|std(lib|int|def|arg|io)|limits|float|fenv|inttypes|signal|setjmp|math|w?ctype|string|[wu]char|time|locale)>'
Priority: 8
- Regex: '^<(co(mplex|mpare|ncepts|routine|ndition_variable)|valarray|random|num(eric|bers)|ratio|bit|version|source_location|type(info|index|_traits)|functional|utility|chrono|new|memory(_resource)?|scoped_allocator|limits|ex(ecu|cep)tion|stdexcept|system_error|charconv|format|iterator|ranges|algorithm|ios(fwd)?|(i|o|io|f|s|sync)stream|iomanip|streambuf|locale|regex|atomic|thread|stop_token|(shared_)?mutex|future|semaphore|latch|barrier|filesystem)'
Priority: 5
- Regex: '^<'
Priority: 1
SortPriority: 3
- Regex: '^"'
Priority: 0
## macros
AlignConsecutiveMacros: false # Clang 9
# ForEachMacros: ['RANGES_FOR', 'FOREACH']
# MacroBlockBegin: ""
# MacroBlockEnd: ""
# NamespaceMacros: ['NAMESPACE'] # Clang 9
# StatementMacros: ['CALCULATION'] # Clang 8 # statement, no ";" needed
# TypenameMacros: ['STACK_OF', 'LIST'] # Clang 9
## Namespace
NamespaceIndentation: Inner
CompactNamespaces: true
FixNamespaceComments: true
## Template
# yamllint disable-line rule:truthy
AlwaysBreakTemplateDeclarations: Yes # Modified Clang 7
SpaceAfterTemplateKeyword: false
## Using
SortUsingDeclarations: false
## Blocks
KeepEmptyLinesAtTheStartOfBlocks: false
#BreakBeforeBraces: Allman
BreakBeforeBraces: Custom
BraceWrapping:
AfterNamespace: true
SplitEmptyNamespace: true
AfterClass: true
AfterStruct: true
AfterUnion: true
SplitEmptyRecord: true
AfterEnum: false
AfterFunction: true
SplitEmptyFunction: true
BeforeLambdaBody: true # Clang 11
AfterExternBlock: true # Clang 6
AfterControlStatement: Always # Modified Clang 10
BeforeCatch: true
BeforeElse: true
AfterCaseLabel: true # Clang 9
BeforeWhile: false # Clang 11
IndentBraces: false
### Single-Line Statements
AllowShortBlocksOnASingleLine: Never # Modified Clang 10
AllowShortFunctionsOnASingleLine: Inline
AllowShortLambdasOnASingleLine: Inline # Clang 10
AllowShortIfStatementsOnASingleLine: Never # Modified Clang 9
AllowShortLoopsOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: true
## Braces
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpaceBeforeParens: ControlStatements
SpacesInParentheses: false
SpaceInEmptyParentheses: false
SpacesInConditionalStatement: false # Clang 10
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false # Clang 10
SpaceInEmptyBlock: false # Clang 10
Cpp11BracedListStyle: true
# if false always spaces in { dd }
SpaceBeforeCpp11BracedList: false # Clang 7
## Classes
BreakInheritanceList: BeforeColon # Clang 7
SpaceBeforeInheritanceColon: true # Clang 7
## Declarations
AlignConsecutiveDeclarations: false
## Functions
IndentWrappedFunctionNames: true
# BinPack: if false, all on same line, or one line each
BinPackArguments: false
AllowAllArgumentsOnNextLine: true # Clang 9
BinPackParameters: false
AllowAllParametersOfDeclarationOnNextLine: true
AlignAfterOpenBracket: AlwaysBreak
AlwaysBreakAfterReturnType: None
# None= uses PenaltyReturnTypeOnItsOwnLine
## Constructors
ConstructorInitializerIndentWidth: 4
ConstructorInitializerAllOnOneLineOrOnePerLine: false
AllowAllConstructorInitializersOnNextLine: false # no effect # Clang 9
BreakConstructorInitializers: BeforeColon
SpaceBeforeCtorInitializerColon: true # Clang 7
## Operators
AlignOperands: true
AlignConsecutiveAssignments: true
SpaceBeforeAssignmentOperators: true
BreakBeforeBinaryOperators: None
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: true
DerivePointerAlignment: false
PointerAlignment: Left
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false # Clang 9
SpaceBeforeRangeBasedForLoopColon: true # Clang 7
AlignConsecutiveBitFields: true
## Strings
BreakStringLiterals: true
AlignEscapedNewlines: Right
AlwaysBreakBeforeMultilineStrings: true
# RawStringFormats: # Clang 6
## Penalties:
PenaltyExcessCharacter: 1000000
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 30
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
# PenaltyBreakTemplateDeclaration: # Clang 7
PenaltyReturnTypeOnItsOwnLine: 60
---
Language: Cpp
Standard: c++20 # Clang 10
DisableFormat: false
---
Language: CSharp # Clang 9
DisableFormat: false
---
Language: Java
DisableFormat: false
---
Language: JavaScript
DisableFormat: false
---
Language: ObjC
DisableFormat: false
---
Language: Proto
DisableFormat: false
---
Language: TableGen
DisableFormat: false
---
Language: TextProto # Clang 6
DisableFormat: false
...