1- #! /bin/bash
1+ #! /usr/ bin/env bash
22
33CHECKS=" *"
4+ ERRORS=" *"
5+
6+ # Need to investigate or disable and document these.
7+ # =========================================================
8+
9+ # TODO(iphydf): Fix these.
10+ ERRORS=" $ERRORS ,-cert-err34-c"
11+ ERRORS=" $ERRORS ,-cert-str34-c"
12+ ERRORS=" $ERRORS ,-readability-suspicious-call-argument"
13+
14+ # TODO(iphydf): Fix these.
15+ CHECKS=" $CHECKS ,-bugprone-switch-missing-default-case"
16+ CHECKS=" $CHECKS ,-misc-include-cleaner"
17+
18+ # TODO(iphydf): We might want some of these. For the ones we don't want, add a
19+ # comment explaining why not.
20+ CHECKS=" $CHECKS ,-clang-analyzer-optin.performance.Padding"
21+ CHECKS=" $CHECKS ,-hicpp-signed-bitwise"
22+ CHECKS=" $CHECKS ,-readability-function-cognitive-complexity"
23+
24+ # TODO(iphydf): Maybe fix these?
25+ CHECKS=" $CHECKS ,-bugprone-easily-swappable-parameters"
26+ CHECKS=" $CHECKS ,-bugprone-implicit-widening-of-multiplication-result"
27+ CHECKS=" $CHECKS ,-bugprone-integer-division"
28+ CHECKS=" $CHECKS ,-clang-analyzer-core.NullDereference"
29+ CHECKS=" $CHECKS ,-clang-analyzer-valist.Uninitialized"
30+ CHECKS=" $CHECKS ,-cppcoreguidelines-avoid-non-const-global-variables"
31+ CHECKS=" $CHECKS ,-misc-no-recursion"
32+
33+ # TODO(iphydf): Probably fix these.
34+ CHECKS=" $CHECKS ,-cert-err33-c"
35+ CHECKS=" $CHECKS ,-cppcoreguidelines-avoid-magic-numbers"
36+ CHECKS=" $CHECKS ,-google-readability-casting"
37+ CHECKS=" $CHECKS ,-modernize-macro-to-enum"
38+ CHECKS=" $CHECKS ,-readability-magic-numbers"
39+
40+ # Documented disabled checks. We don't want these for sure.
41+ # =========================================================
42+
43+ # Callback handlers often don't use all their parameters. There's
44+ # IgnoreVirtual, but that doesn't work for C-style callbacks.
45+ CHECKS=" $CHECKS ,-misc-unused-parameters"
46+
47+ # We sometimes use #if 0.
48+ CHECKS=" $CHECKS ,-readability-avoid-unconditional-preprocessor-if"
49+
50+ # We have better macro hygiene checks with tokstyle. We can never pass macro
51+ # arguments that require parentheses inside the macro.
52+ CHECKS=" $CHECKS ,-bugprone-macro-parentheses"
453
554# We don't use memcpy_s.
655CHECKS=" $CHECKS ,-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling"
@@ -81,42 +130,6 @@ CHECKS="$CHECKS,-cert-dcl03-c"
81130CHECKS=" $CHECKS ,-hicpp-static-assert"
82131CHECKS=" $CHECKS ,-misc-static-assert"
83132
84- # TODO(iphydf): We might want some of these. For the ones we don't want, add a
85- # comment explaining why not.
86- CHECKS=" $CHECKS ,-clang-analyzer-optin.performance.Padding"
87- CHECKS=" $CHECKS ,-hicpp-signed-bitwise"
88- CHECKS=" $CHECKS ,-misc-unused-parameters"
89- CHECKS=" $CHECKS ,-readability-function-cognitive-complexity"
90-
91- # TODO(iphydf): Maybe fix these?
92- CHECKS=" $CHECKS ,-bugprone-easily-swappable-parameters"
93- CHECKS=" $CHECKS ,-bugprone-implicit-widening-of-multiplication-result"
94- CHECKS=" $CHECKS ,-bugprone-integer-division"
95- CHECKS=" $CHECKS ,-clang-analyzer-core.NullDereference"
96- CHECKS=" $CHECKS ,-clang-analyzer-valist.Uninitialized"
97- CHECKS=" $CHECKS ,-concurrency-mt-unsafe"
98- CHECKS=" $CHECKS ,-cppcoreguidelines-avoid-non-const-global-variables"
99- CHECKS=" $CHECKS ,-misc-no-recursion"
100-
101- # TODO(iphydf): Probably fix these.
102- CHECKS=" $CHECKS ,-cert-err33-c"
103- CHECKS=" $CHECKS ,-cppcoreguidelines-avoid-magic-numbers"
104- CHECKS=" $CHECKS ,-google-readability-casting"
105- CHECKS=" $CHECKS ,-modernize-macro-to-enum"
106- CHECKS=" $CHECKS ,-readability-magic-numbers"
107-
108- # TODO(iphydf): These two trip on list.c. Investigate why.
109- CHECKS=" $CHECKS ,-clang-analyzer-core.NonNullParamChecker"
110- CHECKS=" $CHECKS ,-clang-analyzer-unix.Malloc"
111-
112- ERRORS=" *"
113-
114- # TODO(iphydf): Fix these.
115- ERRORS=" $ERRORS ,-bugprone-macro-parentheses"
116- ERRORS=" $ERRORS ,-cert-err34-c"
117- ERRORS=" $ERRORS ,-cert-str34-c"
118- ERRORS=" $ERRORS ,-readability-suspicious-call-argument"
119-
120133set -eux
121134
122135run () {
@@ -125,18 +138,21 @@ run() {
125138 for i in " ${! EXTRA_ARGS[@]} " ; do
126139 EXTRA_ARGS[$i ]=" --extra-arg=${EXTRA_ARGS[$i]} "
127140 done
128- clang-tidy-14 \
129- -p=_build \
130- --extra-arg=-DMIN_LOGGER_LEVEL=LOGGER_LEVEL_TRACE \
131- " ${EXTRA_ARGS[@]} " \
132- --checks=" $CHECKS " \
133- --warnings-as-errors=" $ERRORS " \
134- --use-color \
135- other/bootstrap_daemon/src/* .c \
136- other/* .c \
137- toxav/* .c \
138- toxcore/* .c \
139- toxencryptsave/* .c
141+ find \
142+ other/bootstrap_daemon/src \
143+ other \
144+ toxav \
145+ toxcore \
146+ toxcore/events \
147+ toxencryptsave \
148+ -maxdepth 1 -name " *.c" -print0 \
149+ | xargs -0 -n15 -P" $( nproc) " clang-tidy \
150+ -p=_build \
151+ --extra-arg=-DMIN_LOGGER_LEVEL=LOGGER_LEVEL_TRACE \
152+ " ${EXTRA_ARGS[@]} " \
153+ --checks=" $CHECKS " \
154+ --warnings-as-errors=" $ERRORS " \
155+ --use-color
140156}
141157
142158cmake . -B_build -GNinja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
0 commit comments