44# check_clang_tidy.sh
55# checks for any lint warnings and errors out.
66# does not modify files in-place.
7+ # uses run-clang-tidy for parallel execution.
78# ###############################################################
89
910set -euo pipefail
1011
11- echo " >> Checking for clang-tidy warnings in src/ ..."
12+ echo " >> Checking for clang-tidy warnings..."
1213
13- CLANG_TIDY_BIN=" clang-tidy"
14+ CLANG_TIDY_BIN=" run- clang-tidy-18 "
1415SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
1516BUILD_DIR=" $SCRIPT_DIR /../build/Debug"
1617
@@ -20,21 +21,17 @@ if [ ! -f "$BUILD_DIR/compile_commands.json" ]; then
2021 exit 1
2122fi
2223
23- files=$( find " $SCRIPT_DIR " /../src/ \( -name ' *.cpp' -o -name ' *.c' \) | sort)
24- tidy_errors=0
25- for file in $files ; do
26- echo " Running clang-tidy on $file "
27- $CLANG_TIDY_BIN " $file " -p " $BUILD_DIR " > tidy_output.txt 2>&1 || true
28- if grep -q " warning:" tidy_output.txt; then
29- echo " clang-tidy warnings found in file, exiting. file: [$file ] warnings:"
30- cat tidy_output.txt
31- tidy_errors=1
32- break
33- fi
34- done
35- rm tidy_output.txt
36-
37- if [ $tidy_errors -ne 0 ]; then
38- echo " ERROR: clang-tidy found warnings. Try \` make tidy\` "
24+ # Run run-clang-tidy in parallel on src/ and tests/ directories
25+ # no -fix flag to just report warnings/errors
26+ output=$( $CLANG_TIDY_BIN -p " $BUILD_DIR " -j " $( nproc) " -header-filter=' src/.*|tests/.*' src tests 2>&1 ) || true
27+
28+ echo " $output "
29+
30+ # Check if output contains any warnings or errors
31+ if echo " $output " | grep -qE " warning:|error:" ; then
32+ echo " ERROR: clang-tidy found warnings or errors. Try \` make tidy\` "
3933 exit 1
4034fi
35+
36+ echo " ..."
37+ echo " No clang-tidy warnings found."
0 commit comments