|
@@ -19,6 +19,37 @@ import (
|
|
|
"strings"
|
|
|
)
|
|
|
|
|
|
+var (
|
|
|
+ // Some clang-tidy checks have bugs or not work for Android.
|
|
|
+ // They are disabled here, overriding any locally selected checks.
|
|
|
+ globalNoCheckList = []string{
|
|
|
+ // https://b.corp.google.com/issues/153464409
|
|
|
+ // many local projects enable cert-* checks, which
|
|
|
+ // trigger bugprone-reserved-identifier.
|
|
|
+ "-bugprone-reserved-identifier*,-cert-dcl51-cpp,-cert-dcl37-c",
|
|
|
+ // http://b/153757728
|
|
|
+ "-readability-qualified-auto",
|
|
|
+ // http://b/193716442
|
|
|
+ "-bugprone-implicit-widening-of-multiplication-result",
|
|
|
+ // Too many existing functions trigger this rule, and fixing it requires large code
|
|
|
+ // refactoring. The cost of maintaining this tidy rule outweighs the benefit it brings.
|
|
|
+ "-bugprone-easily-swappable-parameters",
|
|
|
+ // http://b/216364337 - TODO: Follow-up after compiler update to
|
|
|
+ // disable or fix individual instances.
|
|
|
+ "-cert-err33-c",
|
|
|
+ }
|
|
|
+
|
|
|
+ // Some clang-tidy checks are included in some tidy_checks_as_errors lists,
|
|
|
+ // but not all warnings are fixed/suppressed yet. These checks are not
|
|
|
+ // disabled in the TidyGlobalNoChecks list, so we can see them and fix/suppress them.
|
|
|
+ globalNoErrorCheckList = []string{
|
|
|
+ // http://b/155034563
|
|
|
+ "-bugprone-signed-char-misuse",
|
|
|
+ // http://b/155034972
|
|
|
+ "-bugprone-branch-clone",
|
|
|
+ }
|
|
|
+)
|
|
|
+
|
|
|
func init() {
|
|
|
// Many clang-tidy checks like altera-*, llvm-*, modernize-*
|
|
|
// are not designed for Android source code or creating too
|
|
@@ -94,29 +125,12 @@ func init() {
|
|
|
}, ",")
|
|
|
})
|
|
|
|
|
|
- // Some clang-tidy checks have bugs or not work for Android.
|
|
|
- // They are disabled here, overriding any locally selected checks.
|
|
|
pctx.VariableFunc("TidyGlobalNoChecks", func(ctx android.PackageVarContext) string {
|
|
|
- return strings.Join([]string{
|
|
|
- // https://b.corp.google.com/issues/153464409
|
|
|
- // many local projects enable cert-* checks, which
|
|
|
- // trigger bugprone-reserved-identifier.
|
|
|
- "-bugprone-reserved-identifier*,-cert-dcl51-cpp,-cert-dcl37-c",
|
|
|
- // http://b/153757728
|
|
|
- "-readability-qualified-auto",
|
|
|
- // http://b/155034563
|
|
|
- "-bugprone-signed-char-misuse",
|
|
|
- // http://b/155034972
|
|
|
- "-bugprone-branch-clone",
|
|
|
- // http://b/193716442
|
|
|
- "-bugprone-implicit-widening-of-multiplication-result",
|
|
|
- // Too many existing functions trigger this rule, and fixing it requires large code
|
|
|
- // refactoring. The cost of maintaining this tidy rule outweighs the benefit it brings.
|
|
|
- "-bugprone-easily-swappable-parameters",
|
|
|
- // http://b/216364337 - TODO: Follow-up after compiler update to
|
|
|
- // disable or fix individual instances.
|
|
|
- "-cert-err33-c",
|
|
|
- }, ",")
|
|
|
+ return strings.Join(globalNoCheckList, ",")
|
|
|
+ })
|
|
|
+
|
|
|
+ pctx.VariableFunc("TidyGlobalNoErrorChecks", func(ctx android.PackageVarContext) string {
|
|
|
+ return strings.Join(globalNoErrorCheckList, ",")
|
|
|
})
|
|
|
|
|
|
// To reduce duplicate warnings from the same header files,
|
|
@@ -140,7 +154,6 @@ type PathBasedTidyCheck struct {
|
|
|
const tidyDefault = "${config.TidyDefaultGlobalChecks}"
|
|
|
const tidyExternalVendor = "${config.TidyExternalVendorChecks}"
|
|
|
const tidyDefaultNoAnalyzer = "${config.TidyDefaultGlobalChecks},-clang-analyzer-*"
|
|
|
-const tidyGlobalNoChecks = "${config.TidyGlobalNoChecks}"
|
|
|
|
|
|
// This is a map of local path prefixes to the set of default clang-tidy checks
|
|
|
// to be used.
|
|
@@ -180,7 +193,18 @@ func TidyChecksForDir(dir string) string {
|
|
|
|
|
|
// Returns a globally disabled tidy checks, overriding locally selected checks.
|
|
|
func TidyGlobalNoChecks() string {
|
|
|
- return tidyGlobalNoChecks
|
|
|
+ if len(globalNoCheckList) > 0 {
|
|
|
+ return ",${config.TidyGlobalNoChecks}"
|
|
|
+ }
|
|
|
+ return ""
|
|
|
+}
|
|
|
+
|
|
|
+// Returns a globally allowed/no-error tidy checks, appended to -warnings-as-errors.
|
|
|
+func TidyGlobalNoErrorChecks() string {
|
|
|
+ if len(globalNoErrorCheckList) > 0 {
|
|
|
+ return ",${config.TidyGlobalNoErrorChecks}"
|
|
|
+ }
|
|
|
+ return ""
|
|
|
}
|
|
|
|
|
|
func TidyFlagsForSrcFile(srcFile android.Path, flags string) string {
|