Skip to content

Commit 2132ba7

Browse files
committed
Add Clang Format settings, and add it to GHA
1 parent f6396f2 commit 2132ba7

File tree

2 files changed

+279
-1
lines changed

2 files changed

+279
-1
lines changed

.clang-format

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

.github/workflows/ci.yml

+9-1
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,12 @@ jobs:
3232
sudo add-apt-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main"
3333
sudo apt-get update
3434
sudo apt-get install -y clang-18 clang-tidy-18
35-
# clang-format-17
3635
if: matrix.compiler == 'clang'
3736

37+
- name: Install Clang Format
38+
run: sudo apt-get install -y clang-format-18
39+
if: matrix.compiler == 'clang' && matrix.gc == 'GENERATIONAL'
40+
3841
- name: Build SOM VM
3942
run: |
4043
if [ "${{ matrix.compiler }}" = "clang" ]
@@ -67,6 +70,11 @@ jobs:
6770
run: |
6871
clang-tidy-18 --config-file=.clang-tidy src/**/*.cpp -- -fdiagnostics-absolute-paths -DGC_TYPE=${{ matrix.gc}} ${{ matrix.integers }} -DUNITTESTS
6972
73+
- name: Clang Format
74+
if: matrix.compiler == 'clang' && matrix.gc == 'GENERATIONAL'
75+
run: |
76+
clang-format-18 --dry-run --style=file --Werror src/*.cpp src/**/*.cpp src/**/*.h
77+
7078
# Disabled because it's too slow with the sanitizers
7179
# - name: Test SomSom
7280
# run: |

0 commit comments

Comments
 (0)