Skip to content

Commit 53cbbf6

Browse files
authored
Merge pull request #29 from zeus-cpp/style/clang-format-22
style: modernize code formatting with clang-format 22 and clean up trailing comment hacks
2 parents c0ff8ca + a0363a8 commit 53cbbf6

5 files changed

Lines changed: 418 additions & 391 deletions

File tree

.clang-format

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
---
2+
# vim: ft=yaml
23
Language: Cpp
34
BasedOnStyle: Microsoft
45

56
AccessModifierOffset: -4
67

7-
AlignAfterOpenBracket: BlockIndent
8+
AlignAfterOpenBracket: true
89
AlignArrayOfStructures: Left
910
AlignConsecutiveAssignments:
1011
Enabled: true
@@ -20,7 +21,7 @@ AlignConsecutiveDeclarations:
2021
Enabled: true
2122
AcrossEmptyLines: false
2223
AcrossComments: true
23-
#AlignFunctionDeclarations: false # only for AlignConsecutiveDeclarations # clang-format 20
24+
AlignFunctionDeclarations: true # only for AlignConsecutiveDeclarations # clang-format 20
2425
AlignFunctionPointers: false # only for AlignConsecutiveDeclarations
2526
AlignConsecutiveMacros:
2627
Enabled: true
@@ -43,6 +44,7 @@ AllowAllConstructorInitializersOnNextLine: true
4344
AllowAllParametersOfDeclarationOnNextLine: true
4445

4546
AllowBreakBeforeNoexceptSpecifier: Never
47+
AllowBreakBeforeQtProperty: false # clang-format 22
4648

4749
AllowShortBlocksOnASingleLine: Empty
4850
AllowShortCaseExpressionOnASingleLine: true
@@ -53,6 +55,7 @@ AllowShortFunctionsOnASingleLine: InlineOnly
5355
AllowShortIfStatementsOnASingleLine: Never
5456
AllowShortLambdasOnASingleLine: Inline
5557
AllowShortLoopsOnASingleLine: false
58+
AllowShortNamespacesOnASingleLine: false # clang-format 20
5659

5760
AlwaysBreakAfterReturnType: None
5861
AlwaysBreakBeforeMultilineStrings: true
@@ -64,8 +67,9 @@ AttributeMacros:
6467
- __ununsed
6568
- GSL_SUPPRESS
6669

67-
BinPackArguments: false
68-
BinPackParameters: false
70+
BinPackArguments: false
71+
BinPackLongBracedList: true # clang-format 21
72+
BinPackParameters: OnePerLine
6973

7074
BitFieldColonSpacing: Both
7175
BraceWrapping:
@@ -90,12 +94,24 @@ BraceWrapping:
9094
BracedInitializerIndentWidth: 4
9195
BreakAdjacentStringLiterals: true
9296
BreakAfterAttributes: Leave
93-
BreakAfterReturnType: ExceptShortType
97+
BreakAfterOpenBracketBracedList: true # clang-format 22
98+
BreakAfterOpenBracketFunction: true # clang-format 22
99+
BreakAfterOpenBracketIf: true # clang-format 22
100+
BreakAfterOpenBracketLoop: true # clang-format 22
101+
BreakAfterOpenBracketSwitch: true # clang-format 22
102+
BreakAfterReturnType: Automatic
94103
BreakBeforeBinaryOperators: None # TBD
95104
BreakBeforeBraces: Custom
105+
BreakBeforeCloseBracketBracedList: true # clang-format 22
106+
BreakBeforeCloseBracketFunction: true # clang-format 22
107+
BreakBeforeCloseBracketIf: true # clang-format 22
108+
BreakBeforeCloseBracketLoop: true # clang-format 22
109+
BreakBeforeCloseBracketSwitch: true # clang-format 22
96110
BreakBeforeConceptDeclarations: Always
97111
BreakBeforeInlineASMColon: Always
112+
BreakBeforeTemplateCloser: true # clang-format 21
98113
BreakBeforeTernaryOperators: false
114+
BreakBinaryOperations: RespectPrecedence # clang-format 20
99115
BreakConstructorInitializers: BeforeComma
100116
BreakFunctionDefinitionParameters: false
101117
BreakInheritanceList: BeforeComma
@@ -108,14 +124,15 @@ CompactNamespaces: false
108124
ConstructorInitializerAllOnOneLineOrOnePerLine: true
109125
ConstructorInitializerIndentWidth: 4
110126
ContinuationIndentWidth: 4
111-
Cpp11BracedListStyle: true
127+
Cpp11BracedListStyle: FunctionCall # clang-format 22
112128

113129
DeriveLineEnding: true
114130
DerivePointerAlignment: true
115131

116132
DisableFormat: false
117133
EmptyLineAfterAccessModifier: Leave
118134
EmptyLineBeforeAccessModifier: Leave
135+
EnumTrailingComma: Leave # clang-format 21, not safe if not set to Leave
119136
FixNamespaceComments: true
120137
ForEachMacros:
121138
- foreach
@@ -139,6 +156,7 @@ IncludeIsMainSourceRegex: ""
139156
IndentAccessModifiers: false
140157
IndentCaseBlocks: false
141158
IndentCaseLabels: false
159+
IndentExportBlock: false # clang-format 20
142160
IndentExternBlock: NoIndent
143161
IndentGotoLabels: false
144162
IndentPPDirectives: BeforeHash
@@ -159,22 +177,33 @@ KeepEmptyLines:
159177
AtEndOfFile: true
160178
AtStartOfBlock: false
161179
AtStartOfFile: false
180+
KeepFormFeed: true # clang-format 20
162181

163182
LambdaBodyIndentation: Signature
164183
MacroBlockBegin: "" # TBD
165184
MacroBlockEnd: "" # TBD
166185
Macros: [] # TBD
167-
#MainIncludeChar: Quota # clang-format 20
186+
# A vector of function-like macros whose invocations should be skipped by RemoveParentheses.
187+
MacrosSkippedByRemoveParentheses: [] # TBD, clang-format 21
188+
MainIncludeChar: Quote # clang-format 19
168189
MaxEmptyLinesToKeep: 1
169190
NamespaceIndentation: None
170191
NamespaceMacros: [] # TBD A vector of macros which are used to open namespace blocks.
192+
NumericLiteralCase: # clang-format 22
193+
ExponentLetter: Leave
194+
HexDigit: Leave
195+
Prefix: Leave
196+
Suffix: Leave
197+
198+
OneLineFormatOffRegex: '' # clone-format 21
171199

172200
PPIndentWidth: -1 # default to IndentWidth
173201
PackConstructorInitializers: Never
174202

175203
# Penalty is hard to understand, leave it to default(style=Microsoft)
176204
#PenaltyBreakAssignment: 2
177205
#PenaltyBreakBeforeFirstCallParameter: 19
206+
#PenaltyBreakBeforeMemberAccess: 150 # clang-format 20
178207
#PenaltyBreakComment: 300
179208
#PenaltyBreakFirstLessLess: 120
180209
#PenaltyBreakOpenParenthesis: 0
@@ -195,6 +224,8 @@ ReferenceAlignment: Left
195224

196225
ReflowComments: false
197226

227+
RemoveEmptyLinesInUnwrappedLines: true # clang-format 20
228+
RemoveParentheses: Leave # not safe if not Leave
198229
RemoveSemicolon: false # not safe if true
199230

200231
RequiresClausePosition: OwnLine
@@ -209,6 +240,7 @@ SortUsingDeclarations: false
209240

210241
SpaceAfterCStyleCast: true
211242
SpaceAfterLogicalNot: false
243+
SpaceAfterOperatorKeyword: false # clang-format 21
212244
SpaceAfterTemplateKeyword: false
213245

214246
SpaceAroundPointerQualifiers: Default
@@ -268,6 +300,8 @@ WhitespaceSensitiveMacros:
268300
- PP_STRINGIZE
269301
- BOOST_PP_STRINGIZE
270302

303+
WrapNamespaceBodyWithEmptyLines: Always # clang-format 20
304+
271305
---
272306
Language: Json
273307
BreakArrays: false

0 commit comments

Comments
 (0)