diff --git a/.clang-tidy b/.clang-tidy index ed2378536e..ab2a1dfbd7 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,10 +1,15 @@ # clang-tidy configuration, enforced by the clang-tidy CI job on the lines a pull -# request changes (scripts/clang_tidy_diff.py). Only missing includes are reported -# for now: a file should include the header for every symbol it uses, not rely on -# the precompiled header or another header's includes. Run with --fix to add them. +# request changes (scripts/clang_tidy_diff.py). Two things are reported. +# Missing includes: a file should include the header for every symbol it uses, not +# rely on the precompiled header or another header's includes. Run with --fix to +# add them. +# Using-directives and using-declarations in the global namespace of a header: +# they reach every file that includes the header, and a using-declaration also +# makes the header look like the one to include for that name. Qualify the name +# in the header, and put the using in the source files that want it. # Every check listed here gates pull requests, so enable a new one only once the # code it flags on touched lines is reasonable to fix in passing. -Checks: '-*,misc-include-cleaner' +Checks: '-*,misc-include-cleaner,google-global-names-in-headers' WarningsAsErrors: '*' CheckOptions: # Missing includes only. Builds without the precompiled header break on these. diff --git a/scripts/clang_tidy_diff.py b/scripts/clang_tidy_diff.py index 130e4661df..1e716b6baf 100644 --- a/scripts/clang_tidy_diff.py +++ b/scripts/clang_tidy_diff.py @@ -311,11 +311,12 @@ def main(): for path in fixed: print(f" {path}") if failed and fixed: - print(f"\nclang-tidy still fails on {len(failed)} file(s); the findings above are what --fix could not add.") + print(f"\nclang-tidy still fails on {len(failed)} file(s); the findings above are what --fix could not fix.") return 1 if failed: print(f"\nclang-tidy failed on {len(failed)} file(s). Add the includes it names, or apply its " - "suggestions locally with scripts/run_clang_tidy.sh --fix (scripts\\run_clang_tidy.ps1 -Fix on Windows).") + "suggestions locally with scripts/run_clang_tidy.sh --fix (scripts\\run_clang_tidy.ps1 -Fix on Windows). " + "Other findings need a manual fix.") return 1 print("clang-tidy passed.") return 0