diff --git a/.clang-tidy.in b/.clang-tidy.in index ca915b6db40..d3e6997ddda 100644 --- a/.clang-tidy.in +++ b/.clang-tidy.in @@ -152,7 +152,6 @@ Checks: '-*, -readability-string-compare, -readability-uniqueptr-delete-release ' -WarningsAsErrors: '*,-clang-diagnostic-builtin-macro-redefined' HeaderFilterRegex: '(mongo/.*|@MONGO_BUILD_DIR@)' CheckOptions: - key: bugprone-assert-side-effect.AssertMacros diff --git a/BUILD.bazel b/BUILD.bazel index 0bd697457af..f0663865e2e 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,5 +1,5 @@ -load("@npm//:defs.bzl", "npm_link_all_packages") load("@hedron_compile_commands//:refresh_compile_commands.bzl", "refresh_compile_commands") +load("@npm//:defs.bzl", "npm_link_all_packages") package(default_visibility = ["//visibility:public"]) @@ -31,15 +31,14 @@ genrule( # Note: we use sed to substitute the known good value `build/compiledb/mongo`; testing # has confirmed that this is the correct value. + # We also use it to append a line to opt-in to warnings as errors. cmd = """ cp $(location .clang-tidy.in) $@ && \ - sed -i 's|@MONGO_BUILD_DIR@|$(RULEDIR)/src/mongo|g' $@ + sed -i 's|@MONGO_BUILD_DIR@|$(RULEDIR)/src/mongo|g ; $$aWarningsAsErrors: "*"' $@ """, visibility = ["//visibility:public"], ) -load("@hedron_compile_commands//:refresh_compile_commands.bzl", "refresh_compile_commands") - refresh_compile_commands( name = "compiledb", exclude_external_sources = True, diff --git a/buildscripts/clang_tidy.py b/buildscripts/clang_tidy.py index f02a20bf08c..49cb5cf181e 100755 --- a/buildscripts/clang_tidy.py +++ b/buildscripts/clang_tidy.py @@ -50,6 +50,7 @@ def _clang_tidy_executor( clang_tidy_filename, f"-export-fixes={output_filename_fixes}", f"-config={json.dumps(clang_tidy_cfg)}", + "--warnings-as-errors=*,-clang-diagnostic-builtin-macro-redefined", ] proc = subprocess.run(clang_tidy_command, capture_output=True, check=False) files_to_parse = None