-
Notifications
You must be signed in to change notification settings - Fork 35
/
.clang-tidy
370 lines (369 loc) · 15.4 KB
/
.clang-tidy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
---
# Classes of checks we enable, exclusions are listed further down:
# * All clang diagnostic and analyzer checks are enabled.
# * All CERT checks are enabled, many are disabled as the rules to cause a lot
# of collateral fallout. CERT does not make their justifications
# publicly available, so it is hard to understand their rationale.
# * All High Integrity C++ checks are enabled, though again many are excluded.
# * Various other bug-pattern checks: Bugprone, High-Integrity C++,
# Miscellaneous. All with exclusions where they seem to cause harm.
# * Readability and modernization checks, though with exclusions that
# sometimes just relate to style so far.
# * Concurrency orientated checks.
# * Performance orientated checks.
#
# Classes of checks that we do not enable:
# * We ignore all codebase specific checks (Google, Android, etc), except for
# LLVM checks and Google Test checks. We disable the checks that are related
# purely to coding style though, as we don't follow LLVM style.
# * We do not enable the cppcoreguidelines checks because a quick attempt
# suggests that they are not appropriate for our codebase. A deeper analysis
# could result in some specific checks being enabled after fixes.
#
# Use `clang-tidy --list-checks` inside the codebase, so that this file is
# parsed, to see what checks run.
#
# Individual tests that are concretely undesirable in ComputeAorta:
# * bugprone-reserved-identifier, cert-dcl37-c, cert-dcl51-cpp - These all
# hit on using `__foo` names as that is a reserved pattern. But it's
# reserved for the compiler, and ComputeAorta is a compiler.
# * bugprone-signed-char-misuse - Triggers on valid code around `int8_t`
# being implicitly converted to `int`. Wants to go via `unsigned char`
# which is just concretely wrong for us.
# * cert-dcl21-cpp - Makes copies of iterators const for no benefit.
# * clang-analyzer-cplusplus.NewDeleteLeaks - Seems to result in many false
# positives in compiler code that uses FooInst::Create.
# * clang-analyzer-optin.performance.Padding - Would result in lots of noise
# if rearranging tables, creating diffs harder to review.
# * hicpp-named-parameter, readability-named-parameter - Insists on
# parameter names being present as a comment, which just adds noise.
# * misc-misplaced-const - Incompatible with using OpenCL types in our code,
# it wants to put const in the middle of OpenCL types, `cl_context` etc,
# but we can't modify those.
# * misc-unused-parameters - Already use an equivalent compiler warning,
# that we explicitly disable per-file where desirable. Hard to disable
# clang-tidy checks per-file, so just leave it off.
# * readability-function-cognitive-complexity - This is tunable, so could set
# this to a large number, but essentially this problem is too endemic to
# fix. Also, OpenCL and Vulkan APIs naturally result in complex entry
# points.
# * readability-magic-numbers - This just hits far far too often for us.
# * misc-no-recursion - ComputeAorta chooses to use recursion.
# * readability-redundant-member-init - Makes code less readable, because you
# end up with partial member initialization lists when some members are
# default constructed and some are not.
#
# Individual tests that are maybe undesirable in ComputeAorta, perhaps enable
# and use specific `NOLINT(check-name-here)` exclusions:
# * bugprone-branch-clone - Many of the clones improve readability.
# * bugprone-macro-parentheses - Applying the suggested fixes often results
# in code that does not compile, especially when types are passed as macro
# parameters.
# * bugprone-not-null-terminated-result - Dubious memcpy conversions.
# * bugprone-use-after-move - UnitCargo does weird stuff on purpose.
# * bugprone-sizeof-expression - These checks make sense, but the CL, Core,
# and VK interfaces all use lots of opaque types, which means lots of
# `sizeof(A*)` type code which this check warns on. I hope in the future
# that there is a configuration option for this particular sub-class of
# this check.
# * cert-dcl59-cpp - Following this makes things verbose?
# * concurrency-mt-unsafe - The warnings are fundamentally true, but it
# complains about uses of things such as `std::getenv` when there is no
# real alternative.
# * google-readability-avoid-underscore-in-googletest-name - The Google Test
# FAQ gives good reasons for this, but we have many test names with `_`.
# * misc-macro-parentheses - See bugprone-macro-parentheses.
# * misc-redundant-expression - Complains about things like
# `static_assert(MACRO1 == MACRO2, "");` where the expression is always
# true, but `[static_]assert` is meant to be always true.
# * performance-no-int-to-ptr - The logic behind this is good, but it hits on
# casting error codes to pointers, which is sometimes functionally
# required.
#
# Still to be considered (i.e. either fixed, left for later, or document why
# they are disabled):
# * bugprone-forwarding-reference-overload # Wait for C++14 enable_if_t?
# * bugprone-narrowing-conversions
# * bugprone-parent-virtual-call
# * bugprone-too-small-loop-variable
# * cert-err34-c
# * cert-err58-cpp
# * cert-flp30-c
# * cert-msc30-c
# * cert-msc32-c
# * cert-msc50-cpp
# * cert-msc51-cpp
# * cert-oop11-cpp
# * cert-oop54-cpp: See CA-2374
# * cert-str34-c
# * hicpp-avoid-c-arrays
# * hicpp-avoid-goto
# * hicpp-deprecated-headers
# * hicpp-explicit-conversions
# * hicpp-function-size
# * hicpp-invalid-access-moved
# * hicpp-member-init
# * hicpp-move-const-arg
# * hicpp-multiway-paths-covered
# * hicpp-no-array-decay
# * hicpp-noexcept-move
# * hicpp-no-malloc
# * hicpp-signed-bitwise
# * hicpp-special-member-functions
# * hicpp-uppercase-literal-suffix
# * hicpp-use-auto
# * hicpp-use-emplace
# * hicpp-use-equals-default
# * hicpp-use-equals-delete
# * hicpp-use-nullptr
# * hicpp-use-override
# * hicpp-vararg
# * llvm-else-after-return
# * llvm-include-order
# * llvm-header-guard
# * llvm-namespace-comment
# * llvm-twine-local: See CA-2567
# * llvm-qualified-auto
# * misc-definitions-in-headers
# * misc-forwarding-reference-overload # Wait for C++14 enable_if_t?
# * misc-non-private-member-variables-in-classes
# * misc-string-compare
# * misc-unconventional-assign-operator
# * modernize-avoid-bind
# * modernize-avoid-c-arrays
# * modernize-deprecated-headers
# * modernize-loop-convert
# * modernize-make-unique
# * modernize-pass-by-value
# * modernize-redundant-void-arg
# * modernize-return-braced-init-list
# * modernize-use-auto
# * modernize-use-bool-literals
# * modernize-use-default-member-init
# * modernize-use-emplace
# * modernize-use-equals-default
# * modernize-use-equals-delete
# * modernize-use-nullptr
# * modernize-use-override
# * modernize-use-trailing-return-type
# * modernize-use-using
# * performance-move-const-arg
# * performance-move-constructor-init
# * performance-noexcept-move-constructor
# * performance-unnecessary-value-param
# * readability-avoid-const-params-in-decls
# * readability-const-return-type
# * readability-container-size-empty
# * readability-convert-member-functions-to-static,
# * readability-delete-null-pointer
# * readability-else-after-return
# * readability-function-size
# * readability-implicit-bool-conversion
# * readability-inconsistent-declaration-parameter-name
# * readability-isolate-declaration
# * readability-non-const-parameter
# * readability-qualified-auto
# * readability-redundant-control-flow
# * readability-redundant-smartptr-get
# * readability-redundant-string-cstr
# * readability-redundant-string-init
# * readability-simplify-boolean-expr
# * readability-static-accessed-through-instance
# * readability-static-definition-in-anonymous-namespace
# * readability-string-compare
# * readability-uppercase-literal-suffix
# * readability-use-anyofallof
Checks: "bugprone-*,\
-bugprone-branch-clone,\
-bugprone-easily-swappable-parameters,\
-bugprone-forwarding-reference-overload,\
-bugprone-macro-parentheses,\
-bugprone-narrowing-conversions,\
-bugprone-not-null-terminated-result,\
-bugprone-parent-virtual-call,\
-bugprone-signed-char-misuse,\
-bugprone-sizeof-expression,\
-bugprone-reserved-identifier,\
-bugprone-too-small-loop-variable,\
-bugprone-use-after-move,\
cert-*,\
-cert-dcl21-cpp,\
-cert-dcl37-c,\
-cert-dcl51-cpp,\
-cert-dcl59-cpp,\
-cert-err34-c,\
-cert-err58-cpp,\
-cert-flp30-c,\
-cert-int09-c,\
-cert-msc30-c,\
-cert-msc32-c,\
-cert-msc50-cpp,\
-cert-msc51-cpp,\
-cert-oop11-cpp,\
-cert-oop54-cpp,\
-cert-str34-c,\
clang-diagnostic-*,\
-clang-diagnostic-deprecated-declarations,\
-clang-diagnostic-typedef-redefinition,\
clang-analyzer-*,\
-clang-analyzer-cplusplus.NewDelete,\
-clang-analyzer-cplusplus.NewDeleteLeaks,\
-clang-analyzer-optin.core.EnumCastOutOfRange,\
-clang-analyzer-optin.performance.Padding,\
-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,\
*googletest*,\
-google-readability-avoid-underscore-in-googletest-name,\
concurrency-*,\
-concurrency-mt-unsafe,\
hicpp-*,\
-hicpp-avoid-c-arrays,\
-hicpp-avoid-goto,\
-hicpp-deprecated-headers,\
-hicpp-explicit-conversions,\
-hicpp-function-size,\
-hicpp-invalid-access-moved,\
-hicpp-member-init,\
-hicpp-move-const-arg,\
-hicpp-multiway-paths-covered,\
-hicpp-named-parameter,\
-hicpp-no-array-decay,\
-hicpp-noexcept-move,\
-hicpp-no-malloc,\
-hicpp-signed-bitwise,\
-hicpp-special-member-functions,\
-hicpp-uppercase-literal-suffix,\
-hicpp-use-auto,\
-hicpp-use-emplace,\
-hicpp-use-equals-default,\
-hicpp-use-equals-delete,\
-hicpp-use-nullptr,\
-hicpp-use-override,\
-hicpp-vararg,\
llvm-*,\
-llvm-else-after-return,\
-llvm-include-order,\
-llvm-header-guard,\
-llvm-namespace-comment,\
-llvm-twine-local,\
-llvm-qualified-auto,\
misc-*,\
-misc-definitions-in-headers,\
-misc-forwarding-reference-overload,\
-misc-include-cleaner,\
-misc-macro-parentheses,\
-misc-misplaced-const,\
-misc-non-private-member-variables-in-classes,\
-misc-no-recursion,\
-misc-redundant-expression,\
-misc-string-compare,\
-misc-unconventional-assign-operator,\
-misc-unused-parameters,\
-misc-use-anonymous-namespace,\
modernize-*,\
-modernize-avoid-bind,\
-modernize-avoid-c-arrays,\
-modernize-concat-nested-namespaces,\
-modernize-deprecated-headers,\
-modernize-loop-convert,\
-modernize-macro-to-enum,\
-modernize-make-unique,\
-modernize-pass-by-value,\
-modernize-redundant-void-arg,\
-modernize-return-braced-init-list,\
-modernize-use-auto,\
-modernize-use-bool-literals,\
-modernize-use-default-member-init,\
-modernize-use-emplace,\
-modernize-use-equals-default,\
-modernize-use-equals-delete,\
-modernize-use-nodiscard,\
-modernize-use-nullptr,\
-modernize-use-override,\
-modernize-use-trailing-return-type,\
-modernize-use-using,\
performance-*,\
-performance-enum-size,\
-performance-move-const-arg,\
-performance-move-constructor-init,\
-performance-noexcept-move-constructor,\
-performance-no-int-to-ptr,\
-performance-unnecessary-value-param,\
portability-*,\
readability-*,\
-readability-avoid-const-params-in-decls,\
-readability-const-return-type,\
-readability-container-size-empty,\
-readability-convert-member-functions-to-static,
-readability-delete-null-pointer,\
-readability-else-after-return,\
-readability-enum-initial-value,\
-readability-function-cognitive-complexity,\
-readability-function-size,\
-readability-implicit-bool-conversion,\
-readability-inconsistent-declaration-parameter-name,\
-readability-isolate-declaration,\
-readability-magic-numbers,\
-readability-make-member-function-const,\
-readability-named-parameter,\
-readability-non-const-parameter,\
-readability-qualified-auto,\
-readability-redundant-control-flow,\
-readability-redundant-member-init,\
-readability-redundant-smartptr-get,\
-readability-redundant-string-cstr,\
-readability-redundant-string-init,\
-readability-simplify-boolean-expr,\
-readability-static-accessed-through-instance,\
-readability-static-definition-in-anonymous-namespace,\
-readability-string-compare,\
-readability-uppercase-literal-suffix,\
-readability-use-anyofallof"
# -UNDEBUG so that clang-tidy always sees asserts, whatever the build type.
# -fno-caret-diagnostics to silence warning counts from headers.
# -Wno-unknown-warning-option so we can use compilation database on GCC configs
# -Wno-return-type-c-linkage so we can export functions that return C++ types using C linkage.
ExtraArgs: [
'-UNDEBUG',
'-fno-caret-diagnostics',
'-Wno-unknown-warning-option',
'-Wno-return-type-c-linkage'
]
WarningsAsErrors: '*'
HeaderFilterRegex: '.*'
FormatStyle: 'file'
CheckOptions:
- key: bugprone-unused-return-value.AllowCastToVoid
value: true
- key: readability-braces-around-statements.ShortStatementLines
value: '1'
- key: hicpp-braces-around-statements.ShortStatementLines
value: '1'
- key: readability-function-size.StatementThreshold
value: '800'
- key: google-readability-namespace-comments.ShortNamespaceLines
value: '10'
- key: google-readability-namespace-comments.SpacesBeforeComments
value: '2'
- key: modernize-loop-convert.MaxCopySize
value: '16'
- key: modernize-loop-convert.MinConfidence
value: reasonable
- key: modernize-loop-convert.NamingStyle
value: CamelCase
- key: modernize-pass-by-value.IncludeStyle
value: llvm
- key: modernize-replace-auto-ptr.IncludeStyle
value: llvm
- key: modernize-use-nullptr.NullMacros
value: 'NULL'
- key: modernize-use-transparent-functors.SafeMode
value: '1'
- key: readability-redundant-access-specifiers.CheckFirstDeclaration
value: '1'
- key: readability-identifier-length.MinimumParameterNameLength
value: '1'
- key: readability-identifier-length.MinimumVariableNameLength
value: '1'
- key: readability-identifier-length.MinimumLoopCounterNameLength
value: '1'
...