summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cc/builder.go2
-rw-r--r--cc/config/tidy.go15
2 files changed, 16 insertions, 1 deletions
diff --git a/cc/builder.go b/cc/builder.go
index 842ce8515..d01141485 100644
--- a/cc/builder.go
+++ b/cc/builder.go
@@ -646,7 +646,7 @@ func transformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles and
OrderOnly: pathDeps,
Args: map[string]string{
"cFlags": moduleToolingFlags,
- "tidyFlags": flags.tidyFlags,
+ "tidyFlags": config.TidyFlagsForSrcFile(srcFile, flags.tidyFlags),
},
})
}
diff --git a/cc/config/tidy.go b/cc/config/tidy.go
index c4563e273..cf1350381 100644
--- a/cc/config/tidy.go
+++ b/cc/config/tidy.go
@@ -106,6 +106,7 @@ type PathBasedTidyCheck struct {
const tidyDefault = "${config.TidyDefaultGlobalChecks}"
const tidyExternalVendor = "${config.TidyExternalVendorChecks}"
+const tidyDefaultNoAnalyzer = "${config.TidyDefaultGlobalChecks},-clang-analyzer-*"
// This is a map of local path prefixes to the set of default clang-tidy checks
// to be used.
@@ -139,3 +140,17 @@ func TidyChecksForDir(dir string) string {
}
return tidyDefault
}
+
+func TidyFlagsForSrcFile(srcFile android.Path, flags string) string {
+ // Disable clang-analyzer-* checks globally for generated source files
+ // because some of them are too huge. Local .bp files can add wanted
+ // clang-analyzer checks through the tidy_checks property.
+ // Need to do this patch per source file, because some modules
+ // have both generated and organic source files.
+ if _, ok := srcFile.(android.WritablePath); ok {
+ if strings.Contains(flags, tidyDefault) {
+ return strings.ReplaceAll(flags, tidyDefault, tidyDefaultNoAnalyzer)
+ }
+ }
+ return flags
+}