Skip to content

Commit 02b28c1

Browse files
authored
Merge pull request intel#109 from elbeno/update-clang-tidy
🐛 Fix `clang-tidy` operation
2 parents 4a53e8a + 5afeef4 commit 02b28c1

File tree

3 files changed

+124
-9
lines changed

3 files changed

+124
-9
lines changed

.clang-tidy

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,33 @@ Checks: >
33
boost-use-to-string,
44
bugprone-*,
55
-bugprone-easily-swappable-parameters,
6+
-bugprone-narrowing-conversions,
67
clang-diagnostic-*,
78
clang-analyzer-*,
89
cppcoreguidelines-*,
10+
-cppcoreguidelines-avoid-c-arrays,
911
-cppcoreguidelines-avoid-magic-numbers,
1012
-cppcoreguidelines-avoid-non-const-global-variables,
11-
-cppcoreguidelines-macro-usage,
12-
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
13+
-cppcoreguidelines-c-copy-assignment-signature,
14+
-cppcoreguidelines-explicit-virtual-functions,
15+
-cppcoreguidelines-macro-to-enum,
1316
-cppcoreguidelines-missing-std-forward,
17+
-cppcoreguidelines-noexcept-destructor,
18+
-cppcoreguidelines-noexcept-move-operations,
19+
-cppcoreguidelines-noexcept-swap,
20+
-cppcoreguidelines-non-private-member-variables-in-classes,
21+
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
22+
-cppcoreguidelines-use-default-member-init,
1423
google-build-explicit-make-pair,
24+
google-build-namespaces,
1525
google-default-arguments,
1626
google-explicit-constructor,
1727
google-readability-casting,
1828
google-runtime-int,
1929
hicpp-signed-bitwise,
20-
misc-misplaced-const,
21-
misc-non-copyable-objects,
22-
misc-redundant-expression,
23-
misc-static-assert,
24-
misc-throw-by-value-catch-by-reference,
25-
misc-uniqueptr-reset-release,
30+
misc-*,
31+
-misc-include-cleaner,
32+
-misc-non-private-member-variables-in-classes,
2633
modernize-*,
2734
-modernize-concat-nested-namespaces,
2835
performance-*,
@@ -33,9 +40,9 @@ Checks: >
3340
-readability-magic-numbers,
3441
-readability-named-parameter,
3542
-readability-qualified-auto,
43+
-readability-redundant-inline-specifier,
3644
-readability-uppercase-literal-suffix
3745
WarningsAsErrors: '*'
3846
HeaderFilterRegex: ''
39-
AnalyzeTemporaryDtors: false
4047
FormatStyle: file
4148
...

cmake/clang-tidy.cmake

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,16 @@ function(clang_tidy_interface)
128128

129129
compute_branch_diff(clang-tidy ".hpp")
130130
endfunction()
131+
132+
if(NOT TARGET clang-tidy-canary)
133+
message(STATUS "Adding clang-tidy-canary target for ${CMAKE_SOURCE_DIR}")
134+
add_custom_command(
135+
OUTPUT clang_tidy_canary.alive
136+
COMMAND ${CLANG_TIDY_PROGRAM} "--verify-config" 2>clang_tidy.log
137+
COMMAND "!" "[" "-s" "clang_tidy.log" "]"
138+
COMMAND ${CMAKE_COMMAND} "-E" "touch" "clang_tidy_canary.alive"
139+
DEPENDS ${CMAKE_SOURCE_DIR}/.clang-tidy)
140+
add_custom_target(clang-tidy-canary DEPENDS clang_tidy_canary.alive)
141+
add_dependencies(clang-tidy clang-tidy-canary)
142+
add_dependencies(clang-tidy-branch-diff clang-tidy-canary)
143+
endif()

docs/quality.adoc

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,101 @@ If you are not building with clang, the `clang-tidy` target will do nothing.
119119
NOTE: As with `clang-format`, for preference, we'll find the `clang-tidy` that
120120
exists alongside the compiler being used.
121121

122+
=== Enabled clang-tidy checks
123+
124+
The following https://clang.llvm.org/extra/clang-tidy/checks/list.html[`clang-tidy` check] categories are enabled:
125+
126+
* bugprone-*
127+
* clang-diagnostic-*
128+
* clang-analyzer-*
129+
* cppcoreguidelines-*
130+
* misc-*
131+
* modernize-*
132+
* performance-*
133+
* portability-*
134+
* readability-*
135+
136+
In addition, the following specific checks are enabled:
137+
138+
* https://clang.llvm.org/extra/clang-tidy/checks/boost/use-to-string.html[boost-use-to-string]
139+
* https://clang.llvm.org/extra/clang-tidy/checks/google/build-explicit-make-pair.html[google-build-explicit-make-pair]
140+
* https://clang.llvm.org/extra/clang-tidy/checks/google/build-namespaces.html[google-build-namespaces]
141+
* https://clang.llvm.org/extra/clang-tidy/checks/google/default-arguments.html[google-default-arguments]
142+
* https://clang.llvm.org/extra/clang-tidy/checks/google/explicit-constructor.html[google-explicit-constructor]
143+
* https://clang.llvm.org/extra/clang-tidy/checks/google/readability-casting.html[google-readability-casting]
144+
* https://clang.llvm.org/extra/clang-tidy/checks/google/runtime-int.html[google-runtime-int]
145+
* https://clang.llvm.org/extra/clang-tidy/checks/hicpp/signed-bitwise.html[hicpp-signed-bitwise]
146+
147+
The following specific checks are _disabled_ because they are aliases for other
148+
checks, and clang-tidy does not deduplicate them:
149+
150+
* https://clang.llvm.org/extra/clang-tidy/checks/bugprone/narrowing-conversions.html[bugprone-narrowing-conversions]
151+
aliases
152+
https://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/narrowing-conversions.html[cpp-coreguidelines-narrowing-conversions]
153+
* https://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/avoid-c-arrays.html[cppcoreguidelines-avoid-c-arrays]
154+
aliases
155+
https://clang.llvm.org/extra/clang-tidy/checks/modernize/avoid-c-arrays.html[modernize-avoid-c-arrays]
156+
* https://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/avoid-magic-numbers.html[cppcoreguidelines-avoid-magic-numbers]
157+
aliases
158+
https://clang.llvm.org/extra/clang-tidy/checks/readability/magic-numbers.html[readability-magic-numbers]
159+
* https://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/c-copy-assignment-signature.html[cppcoreguidelines-c-copy-assignment-signature]
160+
aliases
161+
https://clang.llvm.org/extra/clang-tidy/checks/misc/unconventional-assign-operator.html[misc-unconventional-assignment-operator]
162+
* https://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/explicit-virtual-functions.html[cppcoreguidelines-explicit-virtual-functions]
163+
aliases
164+
https://clang.llvm.org/extra/clang-tidy/checks/modernize/use-override.html[modernize-use-override]
165+
* https://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/macro-to-enum.html[cppcoreguidelines-macro-to-enum]
166+
aliases
167+
https://clang.llvm.org/extra/clang-tidy/checks/modernize/macro-to-enum.html[modernize-macro-to-enum]
168+
* https://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/noexcept-destructor.html[cppcoreguidelines-noexcept-destructor]
169+
aliases
170+
https://clang.llvm.org/extra/clang-tidy/checks/performance/noexcept-destructor.html[performance-noexcept-destructor]
171+
* https://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/noexcept-move-operations.html[cppcoreguidelines-noexcept-move-operations]
172+
aliases
173+
https://clang.llvm.org/extra/clang-tidy/checks/performance/noexcept-move-constructor.html[performance-noexcept-move-constructor]
174+
* https://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/noexcept-swap.html[cppcoreguidelines-noexcept-swap]
175+
aliases
176+
https://clang.llvm.org/extra/clang-tidy/checks/performance/noexcept-swap.html[performance-noexcept-swap]
177+
* https://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/non-private-member-variables-in-classes.html[cppcoreguidelines-non-private-member-variables-in-classes]
178+
aliases
179+
https://clang.llvm.org/extra/clang-tidy/checks/misc/non-private-member-variables-in-classes.html[misc-non-private-member-variables-in-classes]
180+
* https://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/use-default-member-init.html[cppcoreguidelines-use-default-member-init]
181+
aliases
182+
https://clang.llvm.org/extra/clang-tidy/checks/modernize/use-default-member-init.html[modernize-use-default-member-init]
183+
184+
The following checks are disabled for specific reasons:
185+
186+
* https://clang.llvm.org/extra/clang-tidy/checks/bugprone/easily-swappable-parameters.html[bugprone-easily-swappable-parameters] -
187+
may be enabled someday, but currently too onerous.
188+
* https://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/avoid-non-const-global-variables.html[cppcoreguidelines-avoid-non-const-global-variables] -
189+
the nature of embedded work makes this check ill-conceived.
190+
* https://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/missing-std-forward.html[cppcoreguidelines-missing-std-forward] -
191+
this check misdiagnoses some common things.
192+
* https://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/pro-bounds-pointer-arithmetic.html[cppcoreguidelines-pro-bounds-pointer-arithmetic] -
193+
may be enabled someday, but currently too onerous.
194+
* https://clang.llvm.org/extra/clang-tidy/checks/misc/include-cleaner.html[misc-include-cleaner] -
195+
warns on omnibus headers.
196+
* https://clang.llvm.org/extra/clang-tidy/checks/misc/non-private-member-variables-in-classes.html[misc-non-private-member-variables-in-classes] -
197+
public variables don't contribute to class invariants.
198+
* https://clang.llvm.org/extra/clang-tidy/checks/modernize/concat-nested-namespaces.html[modernize-concat-nested-namespaces] -
199+
it's a style choice.
200+
* https://clang.llvm.org/extra/clang-tidy/checks/readability/identifier-length.html[readability-identifier-length] -
201+
generic code uses lots of short identifiers.
202+
* https://clang.llvm.org/extra/clang-tidy/checks/readability/identifier-naming.html[readability-identifier-naming] -
203+
one of the most expensive checks; not worth the cost.
204+
* https://clang.llvm.org/extra/clang-tidy/checks/readability/magic-numbers.html[readability-magic-numbers] -
205+
the nature of embedded work makes this too onerous.
206+
* https://clang.llvm.org/extra/clang-tidy/checks/readability/named-parameter.html[readability-named-parameter] -
207+
it's a style choice.
208+
* https://clang.llvm.org/extra/clang-tidy/checks/readability/qualified-auto.html[readability-qualified-auto] -
209+
it's a style choice.
210+
* https://clang.llvm.org/extra/clang-tidy/checks/readability/redundant-inline-specifier.html[readability-redundant-inline-specifier] -
211+
`inline` is mostly, but not _only_ for the linker.
212+
* https://clang.llvm.org/extra/clang-tidy/checks/readability/uppercase-literal-suffix.html[readability-uppercase-literal-suffix] -
213+
it's a style choice.
214+
215+
It is likely in the future that more clang-tidy checks will be enabled.
216+
122217
=== `mypy`
123218

124219
Python linting is available using https://mypy-lang.org/[`mypy`]. To lint python

0 commit comments

Comments
 (0)