mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-07 07:41:06 +00:00
Flag Global Usings in Headers with clang-tidy (#16225)
A using-directive or using-declaration in the global namespace of a header reaches every file that includes it, and a using-declaration also makes the include checker treat that header as the one to include for the name. google-global-names-in-headers reports both, on changed lines like the existing check, so headers that still have one are not held to it until the line is touched. The check does not see a using inside a namespace. clang_tidy_diff.py's closing message assumed every finding was a missing include; it now says other findings need a manual fix.
This commit is contained in:
+9
-4
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user