Skip to content

Commit 7a16a20

Browse files
committed
Update Clang tools to version 18
1 parent a3a4978 commit 7a16a20

File tree

4 files changed

+140
-41
lines changed

4 files changed

+140
-41
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ jobs:
6363
- name: Install static analyzers
6464
if: matrix.os == 'ubuntu-24.04'
6565
run: >-
66-
sudo apt-get install clang-tidy-14 cppcheck -y -q
66+
sudo apt-get install clang-tidy-18 cppcheck -y -q
6767
6868
sudo update-alternatives --install
6969
/usr/bin/clang-tidy clang-tidy
70-
/usr/bin/clang-tidy-14 140
70+
/usr/bin/clang-tidy-18 180
7171
7272
- uses: actions/setup-python@v5
7373
with: { python-version: "3.12" }
@@ -80,7 +80,7 @@ jobs:
8080
- name: Lint generated project
8181
if: matrix.os == 'ubuntu-24.04'
8282
working-directory: proj
83-
run: cmake -D FORMAT_COMMAND=clang-format-14 -P cmake/lint.cmake
83+
run: cmake -D FORMAT_COMMAND=clang-format-18 -P cmake/lint.cmake
8484

8585
- name: Setup MultiToolTask
8686
if: matrix.os == 'windows-2022'

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@ Make sure you have these programs installed:
9595
* Python 3.8 or newer
9696
* CMake 3.20 or newer (3.21 or newer for C17 or newer projects)
9797
* git
98-
* [clang-tidy 14](#clang-tidy) (optional)
98+
* [clang-tidy 18](#clang-tidy) (optional)
9999
* [cppcheck](#cppcheck) (optional)
100100
* [Doxygen < 1.9](#doxygen) (optional)
101101
* [LCOV](#lcov) (optional)
102-
* [clang-format 14](#clang-format) (optional)
102+
* [clang-format 18](#clang-format) (optional)
103103
* [codespell](#codespell) (optional)
104104
* [Package managers](#package-managers): Conan or vcpkg (optional)
105105

@@ -197,7 +197,7 @@ Two targets are made available to check and fix code in developer mode using
197197
the `format-check` and `format-fix` targets respectively.
198198

199199
**NOTE**: the project generates files that are formatted according to
200-
clang-format 14. Newer or older versions may format the project differently.
200+
clang-format 18. Newer or older versions may format the project differently.
201201

202202
### codespell
203203

cmake-init/templates/common/.clang-format

Lines changed: 130 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,77 @@
11
---
22
Language: Cpp
3-
# BasedOnStyle: Chromium
43
AccessModifierOffset: -2
54
AlignAfterOpenBracket: Align
6-
AlignConsecutiveMacros: false
7-
AlignConsecutiveAssignments: false
8-
AlignConsecutiveBitFields: false
9-
AlignConsecutiveDeclarations: false
5+
AlignArrayOfStructures: None
6+
AlignConsecutiveAssignments:
7+
Enabled: false
8+
AcrossEmptyLines: false
9+
AcrossComments: false
10+
AlignCompound: false
11+
AlignFunctionPointers: false
12+
PadOperators: false
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
1039
AlignEscapedNewlines: DontAlign
1140
AlignOperands: DontAlign
12-
AlignTrailingComments: false
41+
AlignTrailingComments:
42+
Kind: Never
43+
OverEmptyLines: 0
1344
AllowAllArgumentsOnNextLine: true
14-
AllowAllConstructorInitializersOnNextLine: false
1545
AllowAllParametersOfDeclarationOnNextLine: true
16-
AllowShortEnumsOnASingleLine: false
46+
AllowBreakBeforeNoexceptSpecifier: OnlyWithParen
1747
AllowShortBlocksOnASingleLine: Empty
1848
AllowShortCaseLabelsOnASingleLine: false
49+
AllowShortCompoundRequirementOnASingleLine: true
50+
AllowShortEnumsOnASingleLine: false
1951
AllowShortFunctionsOnASingleLine: Inline
20-
AllowShortLambdasOnASingleLine: All
2152
AllowShortIfStatementsOnASingleLine: Never
53+
AllowShortLambdasOnASingleLine: All
2254
AllowShortLoopsOnASingleLine: false
2355
AlwaysBreakAfterDefinitionReturnType: None
2456
AlwaysBreakAfterReturnType: None
2557
AlwaysBreakBeforeMultilineStrings: true
2658
AlwaysBreakTemplateDeclarations: Yes
59+
AttributeMacros:
60+
- __capability
2761
BinPackArguments: false
2862
BinPackParameters: false
63+
BitFieldColonSpacing: Both
2964
BraceWrapping:
3065
AfterCaseLabel: false
3166
AfterClass: true
3267
AfterControlStatement: MultiLine
3368
AfterEnum: {% if cpp %}true{% else %}false{% end %}
69+
AfterExternBlock: {% if cpp %}true{% else %}false{% end %}
3470
AfterFunction: true
3571
AfterNamespace: true
3672
AfterObjCDeclaration: false
3773
AfterStruct: {% if cpp %}true{% else %}false{% end %}
3874
AfterUnion: {% if cpp %}true{% else %}false{% end %}
39-
AfterExternBlock: {% if cpp %}true{% else %}false{% end %}
4075
BeforeCatch: false
4176
BeforeElse: false
4277
BeforeLambdaBody: true
@@ -45,55 +80,82 @@ BraceWrapping:
4580
SplitEmptyFunction: true
4681
SplitEmptyRecord: true
4782
SplitEmptyNamespace: true
83+
BreakAdjacentStringLiterals: false
84+
BreakAfterAttributes: Leave
85+
BreakAfterJavaFieldAnnotations: true
86+
BreakArrays: true
4887
BreakBeforeBinaryOperators: NonAssignment
88+
BreakBeforeConceptDeclarations: Always
4989
BreakBeforeBraces: Custom
50-
# BreakBeforeInheritanceComma: true
51-
BreakInheritanceList: BeforeComma
90+
BreakBeforeInlineASMColon: OnlyMultiline
5291
BreakBeforeTernaryOperators: true
53-
BreakConstructorInitializersBeforeComma: true
5492
BreakConstructorInitializers: BeforeComma
55-
BreakAfterJavaFieldAnnotations: true
93+
BreakInheritanceList: BeforeComma
5694
BreakStringLiterals: true
5795
ColumnLimit: 80
5896
CommentPragmas: '^ IWYU pragma:'
5997
CompactNamespaces: false
60-
ConstructorInitializerAllOnOneLineOrOnePerLine: false
6198
ConstructorInitializerIndentWidth: 4
6299
ContinuationIndentWidth: 4
63100
Cpp11BracedListStyle: true
64-
DeriveLineEnding: false
65101
DerivePointerAlignment: false
66102
DisableFormat: false
103+
EmptyLineAfterAccessModifier: Never
104+
EmptyLineBeforeAccessModifier: LogicalBlock
67105
ExperimentalAutoDetectBinPacking: false
68106
FixNamespaceComments: true
69107
ForEachMacros:
70108
- foreach
71109
- Q_FOREACH
72110
- BOOST_FOREACH
111+
IfMacros:
112+
- KJ_IF_MAYBE
73113
IncludeBlocks: Regroup
74114
IncludeCategories:{% if cpp %}
75115
# Standard library headers come before anything else
76116
- Regex: '^<[a-z_]+>'
77-
Priority: -1{% end %}
117+
Priority: -1
118+
SortPriority: 0
119+
CaseSensitive: false{% end %}
78120
- Regex: '^<.+\.h{% if cpp %}(pp)?{% end %}>'
79-
Priority: 1{% if cpp %}
121+
Priority: 1
122+
SortPriority: 0
123+
CaseSensitive: false{% if cpp %}
80124
- Regex: '^<.*'
81-
Priority: 2{% end %}
125+
Priority: 2
126+
SortPriority: 0
127+
CaseSensitive: false{% end %}
82128
- Regex: '.*'
83129
Priority: {% if cpp %}3{% else %}2{% end %}
130+
SortPriority: 0
131+
CaseSensitive: false
84132
IncludeIsMainRegex: ''
85133
IncludeIsMainSourceRegex: ''
86-
IndentCaseLabels: true
134+
IndentAccessModifiers: false
87135
IndentCaseBlocks: false
136+
IndentCaseLabels: true
137+
IndentExternBlock: NoIndent
88138
IndentGotoLabels: true
89139
IndentPPDirectives: AfterHash
90-
IndentExternBlock: NoIndent
140+
IndentRequiresClause: true
91141
IndentWidth: 2
92142
IndentWrappedFunctionNames: false
143+
InsertBraces: true
144+
InsertNewlineAtEOF: true
93145
InsertTrailingCommas: Wrapped
146+
IntegerLiteralSeparator:
147+
Binary: 0
148+
BinaryMinDigits: 0
149+
Decimal: 0
150+
DecimalMinDigits: 0
151+
Hex: 0
152+
HexMinDigits: 0
94153
JavaScriptQuotes: Double
95154
JavaScriptWrapImports: true
96155
KeepEmptyLinesAtTheStartOfBlocks: false
156+
KeepEmptyLinesAtEOF: false
157+
LambdaBodyIndentation: Signature
158+
LineEnding: LF
97159
MacroBlockBegin: ''
98160
MacroBlockEnd: ''
99161
MaxEmptyLinesToKeep: 1
@@ -103,15 +165,21 @@ ObjCBlockIndentWidth: 2
103165
ObjCBreakBeforeNestedBlockParam: true
104166
ObjCSpaceAfterProperty: false
105167
ObjCSpaceBeforeProtocolList: true
168+
PackConstructorInitializers: Never
106169
PenaltyBreakAssignment: 2
107170
PenaltyBreakBeforeFirstCallParameter: 1
108171
PenaltyBreakComment: 300
109172
PenaltyBreakFirstLessLess: 120
173+
PenaltyBreakOpenParenthesis: 0
174+
PenaltyBreakScopeResolution: 500
110175
PenaltyBreakString: 1000
111176
PenaltyBreakTemplateDeclaration: 10
112177
PenaltyExcessCharacter: 1000000
178+
PenaltyIndentedWhitespace: 0
113179
PenaltyReturnTypeOnItsOwnLine: 200
114180
PointerAlignment: Left
181+
PPIndentWidth: -1
182+
QualifierAlignment: Leave
115183
RawStringFormats:
116184
- Language: Cpp
117185
Delimiters:
@@ -142,35 +210,66 @@ RawStringFormats:
142210
- ParsePartialTestProto
143211
CanonicalDelimiter: ''
144212
BasedOnStyle: google
213+
ReferenceAlignment: Pointer
145214
ReflowComments: true
146-
SortIncludes: true
147-
SortUsingDeclarations: true
215+
RemoveBracesLLVM: false
216+
RemoveParentheses: Leave
217+
RemoveSemicolon: false
218+
RequiresClausePosition: OwnLine
219+
RequiresExpressionIndentation: OuterScope
220+
SeparateDefinitionBlocks: Always
221+
ShortNamespaceLines: 1
222+
SkipMacroDefinitionBody: false
223+
SortIncludes: CaseSensitive
224+
SortJavaStaticImport: Before
225+
SortUsingDeclarations: LexicographicNumeric
148226
SpaceAfterCStyleCast: false
149227
SpaceAfterLogicalNot: false
150228
SpaceAfterTemplateKeyword: false
229+
SpaceAroundPointerQualifiers: Default
151230
SpaceBeforeAssignmentOperators: true
231+
SpaceBeforeCaseColon: false
152232
SpaceBeforeCpp11BracedList: true
153233
SpaceBeforeCtorInitializerColon: true
154234
SpaceBeforeInheritanceColon: true
155-
SpaceBeforeParens: ControlStatementsExceptForEachMacros
235+
SpaceBeforeJsonColon: false
236+
SpaceBeforeParens: ControlStatementsExceptControlMacros
237+
SpaceBeforeParensOptions:
238+
AfterControlStatements: true
239+
AfterForeachMacros: false
240+
AfterFunctionDefinitionName: false
241+
AfterFunctionDeclarationName: false
242+
AfterIfMacros: false
243+
AfterOverloadedOperator: false
244+
AfterPlacementOperator: true
245+
AfterRequiresInClause: false
246+
AfterRequiresInExpression: false
247+
BeforeNonEmptyParentheses: false
156248
SpaceBeforeRangeBasedForLoopColon: true
249+
SpaceBeforeSquareBrackets: false
157250
SpaceInEmptyBlock: false
158-
SpaceInEmptyParentheses: false
159251
SpacesBeforeTrailingComments: 2
160-
SpacesInAngles: false
161-
SpacesInConditionalStatement: false
252+
SpacesInAngles: Never
162253
SpacesInContainerLiterals: false
163-
SpacesInCStyleCastParentheses: false
164-
SpacesInParentheses: false
254+
SpacesInLineCommentPrefix:
255+
Minimum: 1
256+
Maximum: -1
257+
SpacesInParens: Never
258+
SpacesInParensOptions:
259+
InCStyleCasts: false
260+
InConditionalStatements: false
261+
InEmptyParentheses: false
262+
Other: false
165263
SpacesInSquareBrackets: false
166-
SpaceBeforeSquareBrackets: false
167264
Standard: Auto
265+
StatementAttributeLikeMacros:
266+
- Q_EMIT
168267
StatementMacros:
169268
- Q_UNUSED
170269
- QT_REQUIRE_VERSION
171270
TabWidth: 8
172-
UseCRLF: false
173271
UseTab: Never
272+
VerilogBreakBetweenInstancePorts: true
174273
WhitespaceSensitiveMacros:
175274
- STRINGIZE
176275
- PP_STRINGIZE

cmake-init/templates/common/.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
run: pip3 install codespell
2727

2828
- name: Lint
29-
run: cmake -D FORMAT_COMMAND=clang-format-14 -P cmake/lint.cmake
29+
run: cmake -D FORMAT_COMMAND=clang-format-18 -P cmake/lint.cmake
3030

3131
- name: Spell check
3232
if: always()
@@ -92,7 +92,7 @@ jobs:
9292

9393
runs-on: ubuntu-24.04
9494

95-
env: { C{% if c %}C{% else %}XX{% end %}: clang{% if cpp %}++{% end %}-14{% if c and pm %}, CXX: clang++-14{% end %} }
95+
env: { C{% if c %}C{% else %}XX{% end %}: clang{% if cpp %}++{% end %}-18{% if c and pm %}, CXX: clang++-18{% end %} }
9696

9797
steps:
9898
- uses: actions/checkout@v4{% if conan %}
@@ -154,11 +154,11 @@ jobs:
154154
- name: Install static analyzers
155155
if: matrix.os == 'ubuntu-24.04'
156156
run: >-
157-
sudo apt-get install clang-tidy-14 cppcheck -y -q
157+
sudo apt-get install clang-tidy-18 cppcheck -y -q
158158
159159
sudo update-alternatives --install
160160
/usr/bin/clang-tidy clang-tidy
161-
/usr/bin/clang-tidy-14 140{% if conan %}
161+
/usr/bin/clang-tidy-18 180{% if conan %}
162162
163163
- name: Install Python
164164
uses: actions/setup-python@v5

0 commit comments

Comments
 (0)