Skip to content

Commit 43bef68

Browse files
chandlercerenon
authored andcommitted
Add a workaround for a bug in clang-tidy 16 and C++20.
In that mode, the Bazel suppression of a Clang warning doesn't actually suppress the clang-tidy check. Neither does disabling the check in a `.clang-tidy` config file. Instead, disable it directly on the command line when running `clang-tidy`. The clang-tidy bug is: llvm/llvm-project#61969 This is harmless for other versions as this check is not useful with most Bazel configurations, and can be achieved with a compiler warning if truly needed. Fixes #29
1 parent f43f9d6 commit 43bef68

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

clang_tidy/run_clang_tidy.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,16 @@ test -e .clang-tidy || ln -s -f $CONFIG .clang-tidy
2525
logfile="$(mktemp)"
2626
trap 'if (($?)); then cat "$logfile" 1>&2; fi; rm "$logfile"' EXIT
2727

28+
# Prepend a flag-based disabling of a check that has a serious bug in
29+
# clang-tidy 16 when used with C++20. Bazel always violates this check and the
30+
# warning is typically disabled, but that warning disablement doesn't work
31+
# correctly in this circumstance and so we need to disable it at the clang-tidy
32+
# level both as a check and from `warnings-as-errors` to avoid it getting
33+
# re-promoted to an error. See the clang-tidy bug here for details:
34+
# https://github.com/llvm/llvm-project/issues/61969
35+
set -- \
36+
--checks=-clang-diagnostic-builtin-macro-redefined \
37+
--warnings-as-errors=-clang-diagnostic-builtin-macro-redefined \
38+
"$@"
39+
2840
"${CLANG_TIDY_BIN}" "$@" >"$logfile" 2>&1

0 commit comments

Comments
 (0)