No clang-analyzer-* checks by default for generated files
Test: make with WITH_TIDY=1 CLANG_ANALYZER_CHECKS=1 Bug: 198098397 Change-Id: I386be0b4ee0fcc1785b2eeb8d1eb26ced68246d7
This commit is contained in:
parent
8f33dcc9e3
commit
062e934a9e
2 changed files with 16 additions and 1 deletions
|
@ -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),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue