Skip to content

Commit 26b7e44

Browse files
committed
fix the clang-format ci and clang-format all files
1 parent 6a7043e commit 26b7e44

28 files changed

+5019
-4814
lines changed

.clang-format

Lines changed: 1 addition & 274 deletions
Original file line numberDiff line numberDiff line change
@@ -1,275 +1,2 @@
11
---
2-
Language: Cpp
3-
BasedOnStyle: LLVM
4-
AccessModifierOffset: -2
5-
AlignAfterOpenBracket: Align
6-
AlignArrayOfStructures: None
7-
AlignConsecutiveAssignments:
8-
Enabled: false
9-
AcrossEmptyLines: false
10-
AcrossComments: false
11-
AlignCompound: false
12-
AlignFunctionPointers: false
13-
PadOperators: true
14-
AlignConsecutiveBitFields:
15-
Enabled: false
16-
AcrossEmptyLines: false
17-
AcrossComments: false
18-
AlignCompound: false
19-
AlignFunctionPointers: false
20-
PadOperators: false
21-
AlignConsecutiveDeclarations:
22-
Enabled: false
23-
AcrossEmptyLines: false
24-
AcrossComments: false
25-
AlignCompound: false
26-
AlignFunctionPointers: false
27-
PadOperators: false
28-
AlignConsecutiveMacros:
29-
Enabled: false
30-
AcrossEmptyLines: false
31-
AcrossComments: false
32-
AlignCompound: false
33-
AlignFunctionPointers: false
34-
PadOperators: false
35-
AlignConsecutiveShortCaseStatements:
36-
Enabled: false
37-
AcrossEmptyLines: false
38-
AcrossComments: false
39-
AlignCaseArrows: false
40-
AlignCaseColons: false
41-
AlignConsecutiveTableGenBreakingDAGArgColons:
42-
Enabled: false
43-
AcrossEmptyLines: false
44-
AcrossComments: false
45-
AlignCompound: false
46-
AlignFunctionPointers: false
47-
PadOperators: false
48-
AlignConsecutiveTableGenCondOperatorColons:
49-
Enabled: false
50-
AcrossEmptyLines: false
51-
AcrossComments: false
52-
AlignCompound: false
53-
AlignFunctionPointers: false
54-
PadOperators: false
55-
AlignConsecutiveTableGenDefinitionColons:
56-
Enabled: false
57-
AcrossEmptyLines: false
58-
AcrossComments: false
59-
AlignCompound: false
60-
AlignFunctionPointers: false
61-
PadOperators: false
62-
AlignEscapedNewlines: Right
63-
AlignOperands: Align
64-
AlignTrailingComments:
65-
Kind: Always
66-
OverEmptyLines: 0
67-
AllowAllArgumentsOnNextLine: true
68-
AllowAllParametersOfDeclarationOnNextLine: true
69-
AllowBreakBeforeNoexceptSpecifier: Never
70-
AllowShortBlocksOnASingleLine: Never
71-
AllowShortCaseExpressionOnASingleLine: true
72-
AllowShortCaseLabelsOnASingleLine: false
73-
AllowShortCompoundRequirementOnASingleLine: true
74-
AllowShortEnumsOnASingleLine: true
75-
AllowShortFunctionsOnASingleLine: All
76-
AllowShortIfStatementsOnASingleLine: Never
77-
AllowShortLambdasOnASingleLine: All
78-
AllowShortLoopsOnASingleLine: false
79-
AlwaysBreakAfterDefinitionReturnType: None
80-
AlwaysBreakBeforeMultilineStrings: false
81-
AttributeMacros:
82-
- __capability
83-
BinPackArguments: true
84-
BinPackParameters: true
85-
BitFieldColonSpacing: Both
86-
BraceWrapping:
87-
AfterCaseLabel: false
88-
AfterClass: false
89-
AfterControlStatement: Never
90-
AfterEnum: false
91-
AfterExternBlock: false
92-
AfterFunction: false
93-
AfterNamespace: false
94-
AfterObjCDeclaration: false
95-
AfterStruct: false
96-
AfterUnion: false
97-
BeforeCatch: false
98-
BeforeElse: false
99-
BeforeLambdaBody: false
100-
BeforeWhile: false
101-
IndentBraces: false
102-
SplitEmptyFunction: true
103-
SplitEmptyRecord: true
104-
SplitEmptyNamespace: true
105-
BreakAdjacentStringLiterals: true
106-
BreakAfterAttributes: Leave
107-
BreakAfterJavaFieldAnnotations: false
108-
BreakAfterReturnType: None
109-
BreakArrays: true
110-
BreakBeforeBinaryOperators: None
111-
BreakBeforeConceptDeclarations: Always
112-
BreakBeforeBraces: Attach
113-
BreakBeforeInlineASMColon: OnlyMultiline
114-
BreakBeforeTernaryOperators: true
115-
BreakConstructorInitializers: BeforeColon
116-
BreakFunctionDefinitionParameters: false
117-
BreakInheritanceList: BeforeColon
118-
BreakStringLiterals: true
119-
BreakTemplateDeclarations: MultiLine
120-
ColumnLimit: 80
121-
CommentPragmas: '^ IWYU pragma:'
122-
CompactNamespaces: false
123-
ConstructorInitializerIndentWidth: 4
124-
ContinuationIndentWidth: 4
125-
Cpp11BracedListStyle: true
126-
DerivePointerAlignment: false
127-
DisableFormat: false
128-
EmptyLineAfterAccessModifier: Never
129-
EmptyLineBeforeAccessModifier: LogicalBlock
130-
ExperimentalAutoDetectBinPacking: false
131-
FixNamespaceComments: true
132-
ForEachMacros:
133-
- foreach
134-
- Q_FOREACH
135-
- BOOST_FOREACH
136-
IfMacros:
137-
- KJ_IF_MAYBE
138-
IncludeBlocks: Preserve
139-
IncludeCategories:
140-
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
141-
Priority: 2
142-
SortPriority: 0
143-
CaseSensitive: false
144-
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
145-
Priority: 3
146-
SortPriority: 0
147-
CaseSensitive: false
148-
- Regex: '.*'
149-
Priority: 1
150-
SortPriority: 0
151-
CaseSensitive: false
152-
IncludeIsMainRegex: '(Test)?$'
153-
IncludeIsMainSourceRegex: ''
154-
IndentAccessModifiers: false
155-
IndentCaseBlocks: false
156-
IndentCaseLabels: false
157-
IndentExternBlock: AfterExternBlock
158-
IndentGotoLabels: true
159-
IndentPPDirectives: None
160-
IndentRequiresClause: true
161-
IndentWidth: 2
162-
IndentWrappedFunctionNames: false
163-
InsertBraces: false
164-
InsertNewlineAtEOF: false
165-
InsertTrailingCommas: None
166-
IntegerLiteralSeparator:
167-
Binary: 0
168-
BinaryMinDigits: 0
169-
Decimal: 0
170-
DecimalMinDigits: 0
171-
Hex: 0
172-
HexMinDigits: 0
173-
JavaScriptQuotes: Leave
174-
JavaScriptWrapImports: true
175-
KeepEmptyLines:
176-
AtEndOfFile: false
177-
AtStartOfBlock: true
178-
AtStartOfFile: true
179-
LambdaBodyIndentation: Signature
180-
LineEnding: DeriveLF
181-
MacroBlockBegin: ''
182-
MacroBlockEnd: ''
183-
MainIncludeChar: Quote
184-
MaxEmptyLinesToKeep: 1
185-
NamespaceIndentation: None
186-
ObjCBinPackProtocolList: Auto
187-
ObjCBlockIndentWidth: 2
188-
ObjCBreakBeforeNestedBlockParam: true
189-
ObjCSpaceAfterProperty: false
190-
ObjCSpaceBeforeProtocolList: true
191-
PackConstructorInitializers: BinPack
192-
PenaltyBreakAssignment: 2
193-
PenaltyBreakBeforeFirstCallParameter: 19
194-
PenaltyBreakComment: 300
195-
PenaltyBreakFirstLessLess: 120
196-
PenaltyBreakOpenParenthesis: 0
197-
PenaltyBreakScopeResolution: 500
198-
PenaltyBreakString: 1000
199-
PenaltyBreakTemplateDeclaration: 10
200-
PenaltyExcessCharacter: 1000000
201-
PenaltyIndentedWhitespace: 0
202-
PenaltyReturnTypeOnItsOwnLine: 60
203-
PointerAlignment: Right
204-
PPIndentWidth: -1
205-
QualifierAlignment: Leave
206-
ReferenceAlignment: Pointer
207-
ReflowComments: true
208-
RemoveBracesLLVM: false
209-
RemoveParentheses: Leave
210-
RemoveSemicolon: false
211-
RequiresClausePosition: OwnLine
212-
RequiresExpressionIndentation: OuterScope
213-
SeparateDefinitionBlocks: Leave
214-
ShortNamespaceLines: 1
215-
SkipMacroDefinitionBody: false
216-
SortIncludes: CaseSensitive
217-
SortJavaStaticImport: Before
218-
SortUsingDeclarations: LexicographicNumeric
219-
SpaceAfterCStyleCast: false
220-
SpaceAfterLogicalNot: false
221-
SpaceAfterTemplateKeyword: true
222-
SpaceAroundPointerQualifiers: Default
223-
SpaceBeforeAssignmentOperators: true
224-
SpaceBeforeCaseColon: false
225-
SpaceBeforeCpp11BracedList: false
226-
SpaceBeforeCtorInitializerColon: true
227-
SpaceBeforeInheritanceColon: true
228-
SpaceBeforeJsonColon: false
229-
SpaceBeforeParens: ControlStatements
230-
SpaceBeforeParensOptions:
231-
AfterControlStatements: true
232-
AfterForeachMacros: true
233-
AfterFunctionDefinitionName: false
234-
AfterFunctionDeclarationName: false
235-
AfterIfMacros: true
236-
AfterOverloadedOperator: false
237-
AfterPlacementOperator: true
238-
AfterRequiresInClause: false
239-
AfterRequiresInExpression: false
240-
BeforeNonEmptyParentheses: false
241-
SpaceBeforeRangeBasedForLoopColon: true
242-
SpaceBeforeSquareBrackets: false
243-
SpaceInEmptyBlock: false
244-
SpacesBeforeTrailingComments: 1
245-
SpacesInAngles: Never
246-
SpacesInContainerLiterals: true
247-
SpacesInLineCommentPrefix:
248-
Minimum: 1
249-
Maximum: -1
250-
SpacesInParens: Never
251-
SpacesInParensOptions:
252-
ExceptDoubleParentheses: false
253-
InCStyleCasts: false
254-
InConditionalStatements: false
255-
InEmptyParentheses: false
256-
Other: false
257-
SpacesInSquareBrackets: false
258-
Standard: Latest
259-
StatementAttributeLikeMacros:
260-
- Q_EMIT
261-
StatementMacros:
262-
- Q_UNUSED
263-
- QT_REQUIRE_VERSION
264-
TableGenBreakInsideDAGArg: DontBreak
265-
TabWidth: 8
266-
UseTab: Never
267-
VerilogBreakBetweenInstancePorts: true
268-
WhitespaceSensitiveMacros:
269-
- BOOST_PP_STRINGIZE
270-
- CF_SWIFT_NAME
271-
- NS_SWIFT_NAME
272-
- PP_STRINGIZE
273-
- STRINGIZE
274-
...
275-
2+
BasedOnStyle: LLVM

.github/workflows/clang-format.yaml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,19 @@ jobs:
2121
sudo apt-get update
2222
sudo apt-get install clang-format
2323
24-
- name: Run clang-format
24+
- name: Verify clang-format installation
2525
run: |
26-
git diff --exit-code --ignore-submodules -- '*.cpp' '*.h' '*.c' '*.hpp'
27-
if [ $? -ne 0 ]; then
28-
echo "Clang-format failed. Please format your code."
26+
clang-format --version
27+
28+
- name: Run clang-format on all files
29+
run: |
30+
# From anywhere inside the repo:
31+
repo_root=$(git rev-parse --show-toplevel) && cd "$repo_root"
32+
git ls-files -z -- '*.c' '*.cc' '*.cpp' '*.cxx' '*.h' '*.hh' '*.hpp' '*.hxx' \
33+
| xargs -0 -r clang-format -i
34+
35+
# Fail if formatting made changes
36+
git diff --exit-code || {
37+
echo "clang-format changed files above. Please commit the formatting."
2938
exit 1
30-
fi
39+
}

0 commit comments

Comments
 (0)