Skip to content

Commit f54ffb4

Browse files
committed
Merge bitcoin/bitcoin#32813: clang-format: make formatting deterministic for different formatter versions
13f36c0 clang-format: regenerate configs (Lőrinc) Pull request description: Updates `.clang-format` file to reflect [latest supported Clang-Format standards](https://releases.llvm.org/16.0.0/tools/clang/docs/ClangFormatStyleOptions.html) while preserving most of the existing formatting behavior. Note that [`AfterStruct` brace placement](bitcoin/bitcoin#32414 (comment)) was originally aligned here with `AfterClass`, but was reverted by reviewer demand. ACKs for top commit: maflcko: re-ACK 13f36c0 🖼 achow101: ACK 13f36c0 hodlinator: re-ACK 13f36c0 Tree-SHA512: 02bd9d8a22a9af268297aeddd1f2b2cce079fddd0e1f764d6e9650bb614cb7bcfbd20b38d6e4e5db1744b3dd1ba540380010c085f2cbc0be8aa936f21d27d8de
2 parents 1916c51 + 13f36c0 commit f54ffb4

File tree

2 files changed

+191
-18
lines changed

2 files changed

+191
-18
lines changed

doc/developer-notes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Do not submit patches solely to modify the style of existing code.
1717
[clang-format-diff script](/contrib/devtools/README.md#clang-format-diffpy)
1818
tool to clean up patches automatically before submission.
1919
- Braces on new lines for classes, functions, methods.
20-
- Braces on the same line for everything else.
20+
- Braces on the same line for everything else (including structs).
2121
- 4 space indentation (no tabs) for every block except namespaces.
2222
- No indentation for `public`/`protected`/`private` or for `namespace`.
2323
- No extra spaces inside parentheses; don't do `( this )`.

src/.clang-format

Lines changed: 190 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,222 @@
11
Language: Cpp
22
AccessModifierOffset: -4
3-
AlignAfterOpenBracket: true
4-
AlignEscapedNewlinesLeft: true
5-
AlignTrailingComments: true
3+
AlignAfterOpenBracket: Align
4+
AlignArrayOfStructures: None
5+
AlignConsecutiveAssignments:
6+
Enabled: false
7+
AcrossEmptyLines: false
8+
AcrossComments: false
9+
AlignCompound: false
10+
PadOperators: true
11+
AlignConsecutiveBitFields:
12+
Enabled: false
13+
AcrossEmptyLines: false
14+
AcrossComments: false
15+
AlignCompound: false
16+
PadOperators: false
17+
AlignConsecutiveDeclarations:
18+
Enabled: false
19+
AcrossEmptyLines: false
20+
AcrossComments: false
21+
AlignCompound: false
22+
PadOperators: false
23+
AlignConsecutiveMacros:
24+
Enabled: false
25+
AcrossEmptyLines: false
26+
AcrossComments: false
27+
AlignCompound: false
28+
PadOperators: false
29+
AlignEscapedNewlines: Left
30+
AlignOperands: Align
31+
AlignTrailingComments:
32+
Kind: Always
33+
OverEmptyLines: 0
34+
AllowAllArgumentsOnNextLine: true
635
AllowAllParametersOfDeclarationOnNextLine: true
7-
AllowShortBlocksOnASingleLine: false
36+
AllowShortBlocksOnASingleLine: Never
837
AllowShortCaseLabelsOnASingleLine: true
38+
AllowShortEnumsOnASingleLine: true
939
AllowShortFunctionsOnASingleLine: All
10-
AllowShortIfStatementsOnASingleLine: true
40+
AllowShortIfStatementsOnASingleLine: WithoutElse
41+
AllowShortLambdasOnASingleLine: All
1142
AllowShortLoopsOnASingleLine: false
43+
AlwaysBreakAfterDefinitionReturnType: None
44+
AlwaysBreakAfterReturnType: None
1245
AlwaysBreakBeforeMultilineStrings: false
13-
AlwaysBreakTemplateDeclarations: true
46+
AlwaysBreakTemplateDeclarations: Yes
47+
AttributeMacros:
48+
- __capability
1449
BinPackArguments: true
1550
BinPackParameters: true
16-
BreakBeforeBinaryOperators: false
17-
BreakBeforeBraces: Custom
51+
BitFieldColonSpacing: Both
1852
BraceWrapping:
19-
AfterClass: true
20-
AfterFunction: true
53+
AfterCaseLabel: false
54+
AfterClass: true
55+
AfterControlStatement: Never
56+
AfterEnum: false
57+
AfterExternBlock: false
58+
AfterFunction: true
59+
AfterNamespace: false
60+
AfterObjCDeclaration: false
61+
AfterStruct: false
62+
AfterUnion: false
63+
BeforeCatch: false
64+
BeforeElse: false
65+
BeforeLambdaBody: false
66+
BeforeWhile: false
67+
IndentBraces: false
68+
SplitEmptyFunction: true
69+
SplitEmptyRecord: true
70+
SplitEmptyNamespace: true
71+
BreakAfterAttributes: Never
72+
BreakAfterJavaFieldAnnotations: false
73+
BreakArrays: true
74+
BreakBeforeBinaryOperators: None
75+
BreakBeforeConceptDeclarations: Always
76+
BreakBeforeBraces: Custom
77+
BreakBeforeInlineASMColon: OnlyMultiline
2178
BreakBeforeTernaryOperators: false
22-
BreakConstructorInitializersBeforeComma: false
79+
BreakConstructorInitializers: BeforeColon
80+
BreakInheritanceList: BeforeColon
81+
BreakStringLiterals: true
2382
ColumnLimit: 0
2483
CommentPragmas: '^ IWYU pragma:'
25-
ConstructorInitializerAllOnOneLineOrOnePerLine: false
84+
CompactNamespaces: false
2685
ConstructorInitializerIndentWidth: 4
2786
ContinuationIndentWidth: 4
2887
Cpp11BracedListStyle: true
2988
DerivePointerAlignment: false
3089
DisableFormat: false
90+
EmptyLineAfterAccessModifier: Never
91+
EmptyLineBeforeAccessModifier: LogicalBlock
92+
ExperimentalAutoDetectBinPacking: false
93+
FixNamespaceComments: true
94+
ForEachMacros:
95+
- foreach
96+
- Q_FOREACH
97+
- BOOST_FOREACH
98+
IfMacros:
99+
- KJ_IF_MAYBE
100+
IncludeBlocks: Preserve
101+
IncludeCategories:
102+
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
103+
Priority: 2
104+
SortPriority: 0
105+
CaseSensitive: false
106+
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
107+
Priority: 3
108+
SortPriority: 0
109+
CaseSensitive: false
110+
- Regex: '.*'
111+
Priority: 1
112+
SortPriority: 0
113+
CaseSensitive: false
114+
IncludeIsMainRegex: '(Test)?$'
115+
IncludeIsMainSourceRegex: ''
116+
IndentAccessModifiers: false
117+
IndentCaseBlocks: false
31118
IndentCaseLabels: false
32-
IndentFunctionDeclarationAfterType: false
119+
IndentExternBlock: AfterExternBlock
120+
IndentGotoLabels: true
121+
IndentPPDirectives: None
122+
IndentRequiresClause: true
33123
IndentWidth: 4
124+
IndentWrappedFunctionNames: false
125+
InsertBraces: false
126+
InsertNewlineAtEOF: false
127+
InsertTrailingCommas: None
128+
IntegerLiteralSeparator:
129+
Binary: 0
130+
BinaryMinDigits: 0
131+
Decimal: 0
132+
DecimalMinDigits: 0
133+
Hex: 0
134+
HexMinDigits: 0
135+
JavaScriptQuotes: Leave
136+
JavaScriptWrapImports: true
34137
KeepEmptyLinesAtTheStartOfBlocks: false
138+
LambdaBodyIndentation: Signature
139+
LineEnding: DeriveLF
140+
MacroBlockBegin: ''
141+
MacroBlockEnd: ''
35142
MaxEmptyLinesToKeep: 2
36143
NamespaceIndentation: None
144+
ObjCBinPackProtocolList: Auto
145+
ObjCBlockIndentWidth: 2
146+
ObjCBreakBeforeNestedBlockParam: true
147+
ObjCSpaceAfterProperty: false
148+
ObjCSpaceBeforeProtocolList: true
149+
PackConstructorInitializers: BinPack
150+
PenaltyBreakAssignment: 2
151+
PenaltyBreakBeforeFirstCallParameter: 19
152+
PenaltyBreakComment: 300
153+
PenaltyBreakFirstLessLess: 120
154+
PenaltyBreakOpenParenthesis: 0
155+
PenaltyBreakString: 1000
156+
PenaltyBreakTemplateDeclaration: 10
157+
PenaltyExcessCharacter: 1000000
158+
PenaltyIndentedWhitespace: 0
159+
PenaltyReturnTypeOnItsOwnLine: 60
37160
PointerAlignment: Left
161+
PPIndentWidth: -1
162+
QualifierAlignment: Leave
163+
ReferenceAlignment: Pointer
164+
ReflowComments: true
165+
RemoveBracesLLVM: false
166+
RemoveSemicolon: false
167+
RequiresClausePosition: OwnLine
168+
RequiresExpressionIndentation: OuterScope
169+
SeparateDefinitionBlocks: Leave
170+
ShortNamespaceLines: 1
171+
SortIncludes: CaseSensitive
172+
SortJavaStaticImport: Before
173+
SortUsingDeclarations: LexicographicNumeric
174+
SpaceAfterCStyleCast: false
175+
SpaceAfterLogicalNot: false
176+
SpaceAfterTemplateKeyword: true
177+
SpaceAroundPointerQualifiers: Default
38178
SpaceBeforeAssignmentOperators: true
179+
SpaceBeforeCaseColon: false
180+
SpaceBeforeCpp11BracedList: false
181+
SpaceBeforeCtorInitializerColon: true
182+
SpaceBeforeInheritanceColon: true
39183
SpaceBeforeParens: ControlStatements
184+
SpaceBeforeParensOptions:
185+
AfterControlStatements: true
186+
AfterForeachMacros: true
187+
AfterFunctionDefinitionName: false
188+
AfterFunctionDeclarationName: false
189+
AfterIfMacros: true
190+
AfterOverloadedOperator: false
191+
AfterRequiresInClause: false
192+
AfterRequiresInExpression: false
193+
BeforeNonEmptyParentheses: false
194+
SpaceBeforeRangeBasedForLoopColon: true
195+
SpaceBeforeSquareBrackets: false
196+
SpaceInEmptyBlock: false
40197
SpaceInEmptyParentheses: false
41198
SpacesBeforeTrailingComments: 1
42-
SpacesInAngles: false
199+
SpacesInAngles: Never
200+
SpacesInConditionalStatement: false
43201
SpacesInContainerLiterals: true
44202
SpacesInCStyleCastParentheses: false
203+
SpacesInLineCommentPrefix:
204+
Minimum: 1
205+
Maximum: -1
45206
SpacesInParentheses: false
46-
BreakBeforeConceptDeclarations: Always
47-
RequiresExpressionIndentation: OuterScope
48-
Standard: c++20
207+
SpacesInSquareBrackets: false
208+
Standard: c++20
209+
StatementAttributeLikeMacros:
210+
- Q_EMIT
211+
StatementMacros:
212+
- Q_UNUSED
213+
- QT_REQUIRE_VERSION
214+
TabWidth: 8
49215
UseTab: Never
216+
WhitespaceSensitiveMacros:
217+
- BOOST_PP_STRINGIZE
218+
- CF_SWIFT_NAME
219+
- NS_SWIFT_NAME
220+
- PP_STRINGIZE
221+
- STRINGIZE
222+
...

0 commit comments

Comments
 (0)