2022-01-14 08:28:06 +08:00
|
|
|
#!/bin/bash
|
2021-12-09 07:01:13 +08:00
|
|
|
|
2022-02-08 19:30:59 +08:00
|
|
|
CHECKS="*"
|
|
|
|
|
|
|
|
# __attribute__((nonnull)) causes this warning on defensive null checks.
|
|
|
|
CHECKS="$CHECKS,-clang-diagnostic-pointer-bool-conversion"
|
|
|
|
CHECKS="$CHECKS,-clang-diagnostic-tautological-pointer-compare"
|
|
|
|
|
2023-09-03 05:50:10 +08:00
|
|
|
# Conflicts with "Variable is assigned a value that is never used."
|
|
|
|
# [unreadVariable]
|
|
|
|
CHECKS="$CHECKS,-cppcoreguidelines-init-variables"
|
2023-08-31 18:45:00 +08:00
|
|
|
|
|
|
|
# Short variable names are used quite a lot, and we don't consider them a
|
|
|
|
# readability issue.
|
|
|
|
CHECKS="$CHECKS,-readability-identifier-length"
|
|
|
|
|
|
|
|
# This finds all the do {} while (0) loops and tells us to unroll them.
|
2022-01-14 08:28:06 +08:00
|
|
|
CHECKS="$CHECKS,-altera-unroll-loops"
|
2023-08-31 18:45:00 +08:00
|
|
|
|
|
|
|
# We target systems other than Android, so we don't want to use non-standard
|
|
|
|
# functions from the Android libc.
|
2021-12-10 05:13:49 +08:00
|
|
|
CHECKS="$CHECKS,-android-cloexec-accept"
|
|
|
|
CHECKS="$CHECKS,-android-cloexec-fopen"
|
2023-08-31 18:45:00 +08:00
|
|
|
|
|
|
|
# This catches all the feature test macros (_POSIX_SOURCE etc.).
|
2021-12-09 07:01:13 +08:00
|
|
|
CHECKS="$CHECKS,-bugprone-reserved-identifier"
|
|
|
|
CHECKS="$CHECKS,-cert-dcl37-c"
|
|
|
|
CHECKS="$CHECKS,-cert-dcl51-cpp"
|
2023-08-31 18:45:00 +08:00
|
|
|
|
|
|
|
# We intentionally send some not null-terminated strings in tests and use it for
|
|
|
|
# the toxencryptsave magic number.
|
|
|
|
CHECKS="$CHECKS,-bugprone-not-null-terminated-result"
|
|
|
|
|
2023-09-03 05:50:10 +08:00
|
|
|
# We don't want default labels in enum switches.
|
|
|
|
CHECKS="$CHECKS,-hicpp-multiway-paths-covered"
|
|
|
|
|
|
|
|
# This can make readability quite a bit worse when the 2 cases look very
|
|
|
|
# similar.
|
|
|
|
CHECKS="$CHECKS,-llvm-else-after-return"
|
|
|
|
CHECKS="$CHECKS,-readability-else-after-return"
|
|
|
|
|
|
|
|
# We need 'return;' in empty functions because cimple won't allow empty
|
|
|
|
# functions otherwise.
|
|
|
|
CHECKS="$CHECKS,-readability-redundant-control-flow"
|
|
|
|
|
2023-08-31 18:45:00 +08:00
|
|
|
# TODO(iphydf): We might want some of these. For the ones we don't want, add a
|
|
|
|
# comment explaining why not.
|
2021-12-09 07:01:13 +08:00
|
|
|
CHECKS="$CHECKS,-clang-analyzer-optin.performance.Padding"
|
|
|
|
CHECKS="$CHECKS,-hicpp-signed-bitwise"
|
|
|
|
CHECKS="$CHECKS,-misc-unused-parameters"
|
2022-01-14 08:28:06 +08:00
|
|
|
CHECKS="$CHECKS,-readability-function-cognitive-complexity"
|
2021-12-09 07:01:13 +08:00
|
|
|
|
2022-01-14 08:28:06 +08:00
|
|
|
# TODO(iphydf): Maybe fix these?
|
|
|
|
CHECKS="$CHECKS,-altera-id-dependent-backward-branch"
|
|
|
|
CHECKS="$CHECKS,-altera-struct-pack-align"
|
|
|
|
CHECKS="$CHECKS,-bugprone-branch-clone"
|
|
|
|
CHECKS="$CHECKS,-bugprone-easily-swappable-parameters"
|
|
|
|
CHECKS="$CHECKS,-bugprone-implicit-widening-of-multiplication-result"
|
|
|
|
CHECKS="$CHECKS,-bugprone-integer-division"
|
|
|
|
CHECKS="$CHECKS,-bugprone-narrowing-conversions"
|
|
|
|
CHECKS="$CHECKS,-clang-analyzer-core.NonNullParamChecker"
|
|
|
|
CHECKS="$CHECKS,-clang-analyzer-core.NullDereference"
|
|
|
|
CHECKS="$CHECKS,-clang-analyzer-optin.portability.UnixAPI"
|
|
|
|
CHECKS="$CHECKS,-clang-analyzer-unix.Malloc"
|
|
|
|
CHECKS="$CHECKS,-clang-analyzer-valist.Uninitialized"
|
|
|
|
CHECKS="$CHECKS,-concurrency-mt-unsafe"
|
|
|
|
CHECKS="$CHECKS,-cppcoreguidelines-avoid-non-const-global-variables"
|
|
|
|
CHECKS="$CHECKS,-cppcoreguidelines-narrowing-conversions"
|
|
|
|
CHECKS="$CHECKS,-misc-no-recursion"
|
|
|
|
|
2023-08-31 18:45:00 +08:00
|
|
|
# TODO(iphydf): Probably fix these.
|
|
|
|
CHECKS="$CHECKS,-cert-err33-c"
|
|
|
|
CHECKS="$CHECKS,-cppcoreguidelines-avoid-magic-numbers"
|
2023-09-03 05:50:10 +08:00
|
|
|
CHECKS="$CHECKS,-google-readability-casting"
|
2023-08-31 18:45:00 +08:00
|
|
|
CHECKS="$CHECKS,-modernize-macro-to-enum"
|
2023-09-03 05:50:10 +08:00
|
|
|
CHECKS="$CHECKS,-readability-magic-numbers"
|
2023-08-31 18:45:00 +08:00
|
|
|
|
2021-12-09 07:01:13 +08:00
|
|
|
ERRORS="*"
|
|
|
|
|
|
|
|
# TODO(iphydf): Fix these.
|
|
|
|
ERRORS="$ERRORS,-bugprone-macro-parentheses"
|
|
|
|
ERRORS="$ERRORS,-bugprone-posix-return"
|
|
|
|
ERRORS="$ERRORS,-bugprone-signed-char-misuse"
|
|
|
|
ERRORS="$ERRORS,-cert-err34-c"
|
|
|
|
ERRORS="$ERRORS,-cert-str34-c"
|
|
|
|
ERRORS="$ERRORS,-hicpp-uppercase-literal-suffix"
|
2022-01-14 08:28:06 +08:00
|
|
|
ERRORS="$ERRORS,-readability-suspicious-call-argument"
|
2021-12-09 07:01:13 +08:00
|
|
|
|
|
|
|
set -eux
|
|
|
|
|
2022-01-14 08:28:06 +08:00
|
|
|
run() {
|
|
|
|
echo "Running clang-tidy in variant '$*'"
|
|
|
|
EXTRA_ARGS=("$@")
|
|
|
|
for i in "${!EXTRA_ARGS[@]}"; do
|
|
|
|
EXTRA_ARGS[$i]="--extra-arg=${EXTRA_ARGS[$i]}"
|
|
|
|
done
|
2023-08-31 18:45:00 +08:00
|
|
|
clang-tidy-14 \
|
2022-01-14 08:28:06 +08:00
|
|
|
-p=_build \
|
|
|
|
--extra-arg=-DMIN_LOGGER_LEVEL=LOGGER_LEVEL_TRACE \
|
|
|
|
"${EXTRA_ARGS[@]}" \
|
|
|
|
--checks="$CHECKS" \
|
|
|
|
--warnings-as-errors="$ERRORS" \
|
|
|
|
--use-color \
|
|
|
|
other/bootstrap_daemon/src/*.c \
|
|
|
|
other/*.c \
|
|
|
|
toxav/*.c \
|
|
|
|
toxcore/*.c \
|
|
|
|
toxencryptsave/*.c
|
|
|
|
}
|
|
|
|
|
2023-08-31 18:45:00 +08:00
|
|
|
cmake . -B_build -GNinja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
|
|
|
|
|
2022-01-14 08:28:06 +08:00
|
|
|
. other/analysis/variants.sh
|