1- #! /bin/sh
1+ #! /bin/bash
22
3+ # TODO(iphydf): We might want some of these. For the ones we don't want, add a
4+ # comment explaining why not.
35CHECKS=" *"
6+ CHECKS=" $CHECKS ,-altera-unroll-loops"
47CHECKS=" $CHECKS ,-android-cloexec-accept"
58CHECKS=" $CHECKS ,-android-cloexec-fopen"
69CHECKS=" $CHECKS ,-bugprone-not-null-terminated-result"
@@ -18,24 +21,31 @@ CHECKS="$CHECKS,-llvmlibc-restrict-system-libc-headers"
1821CHECKS=" $CHECKS ,-misc-redundant-expression"
1922CHECKS=" $CHECKS ,-misc-unused-parameters"
2023CHECKS=" $CHECKS ,-readability-else-after-return"
24+ CHECKS=" $CHECKS ,-readability-function-cognitive-complexity"
2125CHECKS=" $CHECKS ,-readability-inconsistent-declaration-parameter-name"
2226CHECKS=" $CHECKS ,-readability-magic-numbers"
2327CHECKS=" $CHECKS ,-readability-redundant-control-flow"
2428
29+ # TODO(iphydf): Maybe fix these?
30+ CHECKS=" $CHECKS ,-altera-id-dependent-backward-branch"
31+ CHECKS=" $CHECKS ,-altera-struct-pack-align"
32+ CHECKS=" $CHECKS ,-bugprone-branch-clone"
33+ CHECKS=" $CHECKS ,-bugprone-easily-swappable-parameters"
34+ CHECKS=" $CHECKS ,-bugprone-implicit-widening-of-multiplication-result"
35+ CHECKS=" $CHECKS ,-bugprone-integer-division"
36+ CHECKS=" $CHECKS ,-bugprone-narrowing-conversions"
37+ CHECKS=" $CHECKS ,-clang-analyzer-core.NonNullParamChecker"
38+ CHECKS=" $CHECKS ,-clang-analyzer-core.NullDereference"
39+ CHECKS=" $CHECKS ,-clang-analyzer-optin.portability.UnixAPI"
40+ CHECKS=" $CHECKS ,-clang-analyzer-unix.Malloc"
41+ CHECKS=" $CHECKS ,-clang-analyzer-valist.Uninitialized"
42+ CHECKS=" $CHECKS ,-concurrency-mt-unsafe"
43+ CHECKS=" $CHECKS ,-cppcoreguidelines-avoid-non-const-global-variables"
44+ CHECKS=" $CHECKS ,-cppcoreguidelines-narrowing-conversions"
45+ CHECKS=" $CHECKS ,-google-readability-casting"
46+ CHECKS=" $CHECKS ,-misc-no-recursion"
47+
2548ERRORS=" *"
26- # TODO(iphydf): Maybe fix these? Otherwise don't show them, if they are useless.
27- ERRORS=" $ERRORS ,-bugprone-branch-clone"
28- ERRORS=" $ERRORS ,-bugprone-integer-division"
29- ERRORS=" $ERRORS ,-bugprone-narrowing-conversions"
30- ERRORS=" $ERRORS ,-clang-analyzer-core.NonNullParamChecker"
31- ERRORS=" $ERRORS ,-clang-analyzer-core.NullDereference"
32- ERRORS=" $ERRORS ,-clang-analyzer-optin.portability.UnixAPI"
33- ERRORS=" $ERRORS ,-clang-analyzer-unix.Malloc"
34- ERRORS=" $ERRORS ,-clang-analyzer-valist.Uninitialized"
35- ERRORS=" $ERRORS ,-cppcoreguidelines-avoid-non-const-global-variables"
36- ERRORS=" $ERRORS ,-cppcoreguidelines-narrowing-conversions"
37- ERRORS=" $ERRORS ,-google-readability-casting"
38- ERRORS=" $ERRORS ,-misc-no-recursion"
3949
4050# TODO(iphydf): Fix these.
4151ERRORS=" $ERRORS ,-bugprone-macro-parentheses"
@@ -45,19 +55,29 @@ ERRORS="$ERRORS,-cert-err34-c"
4555ERRORS=" $ERRORS ,-cert-str34-c"
4656ERRORS=" $ERRORS ,-clang-analyzer-security.insecureAPI.strcpy"
4757ERRORS=" $ERRORS ,-hicpp-uppercase-literal-suffix"
58+ ERRORS=" $ERRORS ,-readability-suspicious-call-argument"
4859ERRORS=" $ERRORS ,-readability-uppercase-literal-suffix"
4960
5061set -eux
5162
52- clang-tidy-11 \
53- -p=_build \
54- --extra-arg=-DMIN_LOGGER_LEVEL=LOGGER_LEVEL_TRACE \
55- --checks=" $CHECKS " \
56- --warnings-as-errors=" $ERRORS " \
57- --use-color \
58- other/bootstrap_daemon/src/* .c \
59- other/* .c \
60- toxav/* .c \
61- toxcore/* .c \
62- toxencryptsave/* .c \
63- " $@ "
63+ run () {
64+ echo " Running clang-tidy in variant '$* '"
65+ EXTRA_ARGS=(" $@ " )
66+ for i in " ${! EXTRA_ARGS[@]} " ; do
67+ EXTRA_ARGS[$i ]=" --extra-arg=${EXTRA_ARGS[$i]} "
68+ done
69+ clang-tidy-12 \
70+ -p=_build \
71+ --extra-arg=-DMIN_LOGGER_LEVEL=LOGGER_LEVEL_TRACE \
72+ " ${EXTRA_ARGS[@]} " \
73+ --checks=" $CHECKS " \
74+ --warnings-as-errors=" $ERRORS " \
75+ --use-color \
76+ other/bootstrap_daemon/src/* .c \
77+ other/* .c \
78+ toxav/* .c \
79+ toxcore/* .c \
80+ toxencryptsave/* .c
81+ }
82+
83+ . other/analysis/variants.sh
0 commit comments