Add clang-analyzer check if selected.
* WITH_TIDY=1 should not include clang-analyzer-* checks
because they are too slow.
* Nightly builds will use both WITH_TIDY=1 and
CLANG_ANALYZER_CHECKS=1.
Bug: 173736193
Test: make with WITH_TIDY=1 and CLANG_ANALYZER_CHECKS=1
Change-Id: I3885fd0e20475ceee5e3798bffc11a61994ac113
diff --git a/cc/config/tidy.go b/cc/config/tidy.go
index b3a86f3..d5d01b4 100644
--- a/cc/config/tidy.go
+++ b/cc/config/tidy.go
@@ -29,15 +29,12 @@
if override := ctx.Config().Getenv("DEFAULT_GLOBAL_TIDY_CHECKS"); override != "" {
return override
}
- return strings.Join([]string{
+ checks := strings.Join([]string{
"-*",
"abseil-*",
"android-*",
"bugprone-*",
"cert-*",
- // clang-analyzer-* check is slow and enables clang-diagnostic-padded,
- // which cannot be suppressed yet.
- // "clang-analyzer-*",
"clang-diagnostic-unused-command-line-argument",
"google-*",
"misc-*",
@@ -63,6 +60,14 @@
// -readability-*
// -zircon-*
}, ",")
+ // clang-analyzer-* checks are too slow to be in the default for WITH_TIDY=1.
+ // nightly builds add CLANG_ANALYZER_CHECKS=1 to run those checks.
+ // Some test code have clang-diagnostic-padded warnings that cannot be
+ // suppressed, but only by disabling clang-analyzer-optin.performance.*.
+ if ctx.Config().IsEnvTrue("CLANG_ANALYZER_CHECKS") {
+ checks += ",clang-analyzer-*,-clang-analyzer-optin.performance.*"
+ }
+ return checks
})
// There are too many clang-tidy warnings in external and vendor projects.