-
Notifications
You must be signed in to change notification settings - Fork 0
/
.clang-format
507 lines (390 loc) · 14.4 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
# Annotated clang-format configuration
# 基于的编码规范, 可选:
# - LLVM: https://llvm.org/docs/CodingStandards.html
# - Google: https://google.github.io/styleguide/cppguide.html
# - Chromium: https://chromium.googlesource.com/chromium/src/+/refs/heads/main/styleguide/styleguide.md
# - Mozilla: https://firefox-source-docs.mozilla.org/code-quality/coding-style/index.html
# - WebKit: https://www.webkit.org/coding/coding-style.html
# - Microsoft: https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference
# - GNU: https://www.gnu.org/prep/standards/standards.html
# - InheritParentConfig: 继承父目录的编码规范, 如果有的话, 不是一个真正的编码规范
# - None: 不使用, 即自动配置
# 注释掉的部分与 Google style 相同
---
BasedOnStyle: Google
Language: Cpp
# 访问说明符(public、private等)的偏移
AccessModifierOffset: -4
# 开括号后的对齐(包括小括号/大括号/尖括号), 建议使用Align
# - Align: 对齐开括号, 即在换行情况下, 换行的参数跟开括号对齐, 建议使用
# - DontAlign: 不对齐开括号, 即换行时使用配置的空格数
# - AlwaysBreak: 永远换行, 即第一个参数都不允许粘连括号, 会强制换行, 换行后使用配置空格数对齐
# - BlockIndent: 同AlwaysBreak, 多了一个操作: 如果参数不固定在同一行, 闭括号将在下一行, 目前这只适用于圆括号
#AlignAfterOpenBracket: Align
# - 结构体数组统一初始化对齐, 建议不配置
# - None: 不做处理, 即保留开发者的代码
# - Left: 左对齐
# - Right: 右对齐
#AlignArrayOfStructures: None
# 对齐连续宏定义
AlignConsecutiveMacros: AcrossEmptyLines
# Enabled: true
# AcrossEmptyLines: true
# AcrossComments: true
# 连续赋值时,对齐所有等号
AlignConsecutiveAssignments: None
# 对齐连续位域字段
#AlignConsecutiveBitFields: None
# 连续声明时,对齐所有声明的变量名
#AlignConsecutiveDeclarations: None
# 续行符(\\)对齐:
# How to align backslashes in escaped newlines
AlignEscapedNewlines: Right
# 水平对齐二元和三元表达式的操作数
# Horizontally align operands of binary and ternary expressions.
AlignOperands: true
# 对齐连续的尾随的注释
# Align trailing comments in consecutive lines
AlignTrailingComments:
Kind: Always
OverEmptyLines: 3
# 如果函数调用或带括号的初始化列表不适合全部在一行时,
# 允许将所有参数放到下一行,即使BinPackArguments为false
#AllowAllArgumentsOnNextLine: true
# 允许函数声明的所有参数在放在下一行
AllowAllParametersOfDeclarationOnNextLine: false
# Allow short enums on a single line.
#AllowShortEnumsOnASingleLine: true
# 允许短的块放在同一行(Always 总是将短块合并成一行,Empty 只合并空块)
# Dependent on the value, while (true) { continue; } can be put on a single line.
AllowShortBlocksOnASingleLine: Always
# 允许短的case标签放在同一行
AllowShortCaseLabelsOnASingleLine: false
# 允许短的函数放在同一行
# Dependent on the value, int f() { return 0; } can be put on a single line.
AllowShortFunctionsOnASingleLine: InlineOnly
# 允许短的Lambda表达式放在同一行
#AllowShortLambdasOnASingleLine: All
# 允许短的if语句保持在同一行
# Dependent on the value, if (a) return; can be put on a single line.
AllowShortIfStatementsOnASingleLine: Never
# 允许短的循环保持在同一行
# Dependent on the value, while (true) continue; can be put on a single line.
AllowShortLoopsOnASingleLine: false
# This option is deprecated and is retained for backwards compatibility.
#AlwaysBreakAfterDefinitionReturnType: None
# 函数声明返回类型后是否换行(None 自动,All全部,TopLevel)
#AlwaysBreakAfterReturnType: None
# 总是在多行string字面量前换行
# Always break before multiline string literals.
AlwaysBreakBeforeMultilineStrings: false
# 总是在template声明后换行
# Always break after the template<...> of a template declaration.
#AlwaysBreakTemplateDeclarations: Yes
#AttributeMacros:
# - __capability
# 函数调用时的参数(Arguments)是否放置于一行, false不放置, true强制一个调用参数一行
BinPackArguments: false
# 函数定义时的参数(Parameters)是否放置于一行
BinPackParameters: false
# 大括号换行,只有当 BreakBeforeBraces 设置为Custom时才有效
BraceWrapping:
# case 语句后面
AfterCaseLabel: true
# class定义后面
AfterClass: true
# 控制语句(if/for/while/switch/...)后是否换行
# - Never: 永远不, 即永远将语句体的大括号放置于控制语句同一行
# - MultiLine: 多行控制语句才进行换行
# - Always: 永远换行, 建议
AfterControlStatement: Never
# 枚举定义后面
AfterEnum: true
# 函数定义后面
AfterFunction: true
# 命名空间定义后面
AfterNamespace: false
# ObjC定义后面
# AfterObjCDeclaration: false
# 结构体定义后面
AfterStruct: true
# 联合定义后面
AfterUnion: true
# extern导出块后面
AfterExternBlock: true
# catch之前
BeforeCatch: true
# else之前
BeforeElse: true
# BeforeLambdaBody: false
# BeforeWhile: false
# 缩进大括号(整个大括号框起来的部分都缩进)
# IndentBraces: false
# 空函数的大括号
# SplitEmptyFunction: true
# 空记录体(struct/class/union)的大括号
# SplitEmptyRecord: true
# 空名字空间的大括号
# SplitEmptyNamespace: true
# 二元操作符前是否换行, 建议为None
BreakBeforeBinaryOperators: All
# 概念声明前是否换行, 建议Always
# BreakBeforeConceptDeclarations: Always
# 大括号换行风格,Custom即可, 具体值可参考上方文档
BreakBeforeBraces: Custom
# 继承列表括号前换行, false即可
# In the class inheritance break before : and , if there is multiple inheritance.
#BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeComma
# 三元运算操作符换行位置( ? 和 : 在新行还是尾部)
# Place ternary operators after line breaks, so ? and : lead lines with operands.
#BreakBeforeTernaryOperators: true
# 是否在构造函数初始化列表的","前换行
#BreakConstructorInitializersBeforeComma: false
# 继承列表换行风格, 使用BeforeComma适合
# Break constructor initializers before the colon and commas,
# and align the commas with the colon.
BreakConstructorInitializers: BeforeComma
# Ignored in C++
#BreakAfterJavaFieldAnnotations: false
# 字面字符串是否换行, true
# Allow breaking string literals when formatting.
#BreakStringLiterals: true
# 每行字符的限制,0表示没有限制
ColumnLimit: 100
# pragma注释,它不应该被分割为多行或以其它方式改变
#CommentPragmas: '^ IWYU pragma:'
#QualifierAlignment: Leave
# Consecutive namespace declarations will be on the same line wrapping
# any overflowing namespace.
#CompactNamespaces: false
# 构造函数初始化列表缩进
# Number of characters to use for indentation of constructor initializer lists.
#ConstructorInitializerIndentWidth: 4
# 函数调用续行对齐, 建议4
#ContinuationIndentWidth: 4
# Format braced lists as best suited for C++11 braced lists.
#Cpp11BracedListStyle: true
#This option is deprecated. See DeriveLF and DeriveCRLF of LineEnding.
#DeriveLineEnding: true
# Whether to analyze formatted file for the most common alignment of & and *.
# If true, PointerAlignment is then used only as fallback.
DerivePointerAlignment: false
# 关闭格式化
# Disables formatting completely.
#DisableFormat: false
#EmptyLineAfterAccessModifier: Never
#EmptyLineBeforeAccessModifier: LogicalBlock
#ExperimentalAutoDetectBinPacking: false
PackConstructorInitializers: Never
# This option is deprecated. See CurrentLine of PackConstructorInitializers.
#ConstructorInitializerAllOnOneLineOrOnePerLine: false
# This option is deprecated. See NextLine of PackConstructorInitializers.
#AllowAllConstructorInitializersOnNextLine: true
# 是否强制在namespace结尾增加 // namespace xxx, 建议为true
FixNamespaceComments: true
#ForEachMacros:
# - foreach
# - Q_FOREACH
# - BOOST_FOREACH
#If宏
#IfMacros:
# - KJ_IF_MAYBE
# include代码块操作, 前提是SortIncludes开启:
#IncludeBlocks: Regroup
# Include种类, 默认即可
#IncludeCategories:
# - Regex: '^<ext/.*\.h>'
# Priority: 2
# SortPriority: 0
# CaseSensitive: false
# - Regex: '^<.*\.h>'
# Priority: 1
# SortPriority: 0
# CaseSensitive: false
# - Regex: '^<.*'
# Priority: 2
# SortPriority: 0
# CaseSensitive: false
# - Regex: '.*'
# Priority: 3
# SortPriority: 0
# CaseSensitive: false
#IncludeIsMainRegex: '([-_](test|unittest))?$'
#IncludeIsMainSourceRegex: ''
# 缩进访问控制
#IndentAccessModifiers: false
# 缩进case标签
#IndentCaseLabels: true
# 缩进case块
#IndentCaseBlocks: false
# 缩进goto标签
#IndentGotoLabels: true
# 预处理指示(PPD-PreProcessor Directive)缩进, 建议None
IndentPPDirectives: None
# extern "C"缩进, 建议AfterExternBlock
#IndentExternBlock: AfterExternBlock
#IndentRequires: false
# 缩进宽度
IndentWidth: 4
# Indent if a function definition or declaration is wrapped after the type.
IndentWrappedFunctionNames: true
# 是否强制插入拖尾的',', 建议为None
#InsertTrailingCommas: None
# Ignored in C++
#JavaScriptQuotes: Leave
#JavaScriptWrapImports: true
#KeepEmptyLinesAtTheStartOfBlocks: false
#LambdaBodyIndentation: Signature
# 宏开始的正则, 不使用
#MacroBlockBegin: ''
# 宏结束的正则, 不使用
#MacroBlockEnd: ''
# 空行保持, 建议为1
#MaxEmptyLinesToKeep: 1
# Namespace内的对齐, 直接使用None即可, 即所有namespace内(包括内嵌的)都不indent
#NamespaceIndentation: None
# Ignored in C++
#ObjCBinPackProtocolList: Never
#ObjCBlockIndentWidth: 2
#ObjCBreakBeforeNestedBlockParam: true
#ObjCSpaceAfterProperty: false
#ObjCSpaceBeforeProtocolList: true
#PenaltyBreakAssignment: 2
#PenaltyBreakBeforeFirstCallParameter: 1
#PenaltyBreakComment: 300
#PenaltyBreakFirstLessLess: 120
#PenaltyBreakOpenParenthesis: 0
#PenaltyBreakString: 1000
#PenaltyBreakTemplateDeclaration: 10
#PenaltyExcessCharacter: 1000000
#PenaltyReturnTypeOnItsOwnLine: 200
#PenaltyIndentedWhitespace: 0
# 指针对齐
#PointerAlignment: Left
#PPIndentWidth: -1
#RawStringFormats:
# - Language: Cpp
# Delimiters:
# - cc
# - CC
# - cpp
# - Cpp
# - CPP
# - 'c++'
# - 'C++'
# CanonicalDelimiter: ''
# BasedOnStyle: google
# - Language: TextProto
# Delimiters:
# - pb
# - PB
# - proto
# - PROTO
# EnclosingFunctions:
# - EqualsProto
# - EquivToProto
# - PARSE_PARTIAL_TEXT_PROTO
# - PARSE_TEST_PROTO
# - PARSE_TEXT_PROTO
# - ParseTextOrDie
# - ParseTextProtoOrDie
# - ParseTestProto
# - ParsePartialTestProto
# CanonicalDelimiter: pb
# BasedOnStyle: google
#ReferenceAlignment: Pointer
# 允许重新排版注释
ReflowComments: false
# 是否移除多余的{}, 不建议
#RemoveBracesLLVM: false
# 分隔不同定义块
#SeparateDefinitionBlocks: Leave
#ShortNamespaceLines: 1
SortIncludes: Never
# Ignored in C++
#SortJavaStaticImport: Before
# 排序using语句(true/false), 不建议开启
SortUsingDeclarations: false
# C风格cast的类型括号后面是否增加space(true/false)
#SpaceAfterCStyleCast: false
# 逻辑非操作(!)后面是否加space(true/false)
#SpaceAfterLogicalNot: false
# template关键字后面是否加space(true/false), 建议true, 即template <xxx>, 而不是template<xxx>
#SpaceAfterTemplateKeyword: true
# 赋值语句操作符前是否添加space(true/false), 建议true
#SpaceBeforeAssignmentOperators: true
# case语句:前是否增加space(true/false), 建议false
#SpaceBeforeCaseColon: false
# c++11的统一初始化列表的大括号中是否添加space(true/false), 建议false
#SpaceBeforeCpp11BracedList: false
# 构造函数初始化列表:前是否加space(true/false), 建议false
#SpaceBeforeCtorInitializerColon: true
# 继承列表的:前是否加space(true/false), 建议true
#SpaceBeforeInheritanceColon: true
# 圆括号前是否增加空格: 建议只在控制语句的括号前增加, 即配置为ControlStatements即可
#SpaceBeforeParens: ControlStatements
# 如果 SpaceBeforeParens 设置为自定义,则使用此选项指定如何处理括号前的每个空格。否则,该选项将被忽略。
#SpaceBeforeParensOptions:
# AfterControlStatements: true
# AfterForeachMacros: true
# AfterFunctionDefinitionName: false
# AfterFunctionDeclarationName: false
# AfterIfMacros: true
# AfterOverloadedOperator: false
# BeforeNonEmptyParentheses: false
# Defines in which cases to put a space before or after pointer qualifiers
# 建议Default, 即使用 PointerAlignment 代替
#SpaceAroundPointerQualifiers: Default
# Loop关键字前前是否增加space
#SpaceBeforeRangeBasedForLoopColon: true
# 空块中是否添加space
#SpaceInEmptyBlock: false
# 在空的圆括号中添加空格
#SpaceInEmptyParentheses: false
# Trailing注释前的空格数, 建议1
SpacesBeforeTrailingComments: 1
# <>里面是否增加space
#SpacesInAngles: Never
# 条件语句()里面是否增加空格
#SpacesInConditionalStatement: false
# 容器初始化列表[]/{}里面是否增加空格
SpacesInContainerLiterals: false
# C风格的转换()里面是否增加空格
#SpacesInCStyleCastParentheses: false
# 行注释前的空格范围数量, 建议Maximum关闭(设置成-1),
# 即//到你的注释内容前的空格数量至少是1, 至多是无穷
#SpacesInLineCommentPrefix:
# Minimum: 1
# Maximum: -1
# 括号内是否加space
#SpacesInParentheses: false
#SpacesInSquareBrackets: false
#SpaceBeforeSquareBrackets: false
# 位定义:前后是否增加空格, 可选:
# - Both: 前后都添加
# - Before: 只在前增加
# - After: 只在后增加
# - None: 不增加, 建议, 没有必要因为过多的space(s)影响代码紧凑
#BitFieldColonSpacing: Both
# C++标准, Latest即可
Standard: Latest
#StatementAttributeLikeMacros:
# - Q_EMIT
#StatementMacros:
# - Q_UNUSED
# - QT_REQUIRE_VERSION
# Tab宽度, 建议4
TabWidth: 4
# This option is deprecated. See LF and CRLF of LineEnding.
#UseCRLF: false
# Tab使用, 没有必要使用, 直接Never
#UseTab: Never
# 空格敏感宏列表
#WhitespaceSensitiveMacros:
# - STRINGIZE
# - PP_STRINGIZE
# - BOOST_PP_STRINGIZE
# - NS_SWIFT_NAME
# - CF_SWIFT_NAME
...