no out/soong/... in default header-filter
* There are too many warnings from out/.../*.pb.h
and other generated header files.
Bug: 180862582
Bug: 231245501
Test: WITH_TIDY=1 make
Change-Id: Ibabc1040666b50c6dec4fd66ae999a3441324fbd
diff --git a/cc/tidy.go b/cc/tidy.go
index 03e967d..ac1521b 100644
--- a/cc/tidy.go
+++ b/cc/tidy.go
@@ -96,10 +96,15 @@
if !android.SubstringInList(flags.TidyFlags, "-header-filter=") {
defaultDirs := ctx.Config().Getenv("DEFAULT_TIDY_HEADER_DIRS")
headerFilter := "-header-filter="
+ // Default header filter should include only the module directory,
+ // not the out/soong/.../ModuleDir/...
+ // Otherwise, there will be too many warnings from generated files in out/...
+ // If a module wants to see warnings in the generated source files,
+ // it should specify its own -header-filter flag.
if defaultDirs == "" {
- headerFilter += ctx.ModuleDir() + "/"
+ headerFilter += "^" + ctx.ModuleDir() + "/"
} else {
- headerFilter += "\"(" + ctx.ModuleDir() + "/|" + defaultDirs + ")\""
+ headerFilter += "\"(^" + ctx.ModuleDir() + "/|" + defaultDirs + ")\""
}
flags.TidyFlags = append(flags.TidyFlags, headerFilter)
}