Merge "Disable tidy checks in TidyGlobalNoChecks"
This commit is contained in:
@@ -94,6 +94,31 @@ 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",
|
||||||
|
}, ",")
|
||||||
|
})
|
||||||
|
|
||||||
// To reduce duplicate warnings from the same header files,
|
// To reduce duplicate warnings from the same header files,
|
||||||
// header-filter will contain only the module directory and
|
// header-filter will contain only the module directory and
|
||||||
// those specified by DEFAULT_TIDY_HEADER_DIRS.
|
// those specified by DEFAULT_TIDY_HEADER_DIRS.
|
||||||
@@ -115,6 +140,7 @@ type PathBasedTidyCheck struct {
|
|||||||
const tidyDefault = "${config.TidyDefaultGlobalChecks}"
|
const tidyDefault = "${config.TidyDefaultGlobalChecks}"
|
||||||
const tidyExternalVendor = "${config.TidyExternalVendorChecks}"
|
const tidyExternalVendor = "${config.TidyExternalVendorChecks}"
|
||||||
const tidyDefaultNoAnalyzer = "${config.TidyDefaultGlobalChecks},-clang-analyzer-*"
|
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
|
// This is a map of local path prefixes to the set of default clang-tidy checks
|
||||||
// to be used.
|
// to be used.
|
||||||
@@ -152,6 +178,11 @@ func TidyChecksForDir(dir string) string {
|
|||||||
return tidyDefault
|
return tidyDefault
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns a globally disabled tidy checks, overriding locally selected checks.
|
||||||
|
func TidyGlobalNoChecks() string {
|
||||||
|
return tidyGlobalNoChecks
|
||||||
|
}
|
||||||
|
|
||||||
func TidyFlagsForSrcFile(srcFile android.Path, flags string) string {
|
func TidyFlagsForSrcFile(srcFile android.Path, flags string) string {
|
||||||
// Disable clang-analyzer-* checks globally for generated source files
|
// Disable clang-analyzer-* checks globally for generated source files
|
||||||
// because some of them are too huge. Local .bp files can add wanted
|
// because some of them are too huge. Local .bp files can add wanted
|
||||||
|
21
cc/tidy.go
21
cc/tidy.go
@@ -160,32 +160,15 @@ func (tidy *tidyFeature) flags(ctx ModuleContext, flags Flags) Flags {
|
|||||||
tidyChecks = tidyChecks + "," + strings.Join(esc(ctx, "tidy_checks",
|
tidyChecks = tidyChecks + "," + strings.Join(esc(ctx, "tidy_checks",
|
||||||
config.ClangRewriteTidyChecks(localChecks)), ",")
|
config.ClangRewriteTidyChecks(localChecks)), ",")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
tidyChecks = tidyChecks + "," + config.TidyGlobalNoChecks()
|
||||||
if ctx.Windows() {
|
if ctx.Windows() {
|
||||||
// https://b.corp.google.com/issues/120614316
|
// https://b.corp.google.com/issues/120614316
|
||||||
// mingw32 has cert-dcl16-c warning in NO_ERROR,
|
// mingw32 has cert-dcl16-c warning in NO_ERROR,
|
||||||
// which is used in many Android files.
|
// which is used in many Android files.
|
||||||
tidyChecks = tidyChecks + ",-cert-dcl16-c"
|
tidyChecks = tidyChecks + ",-cert-dcl16-c"
|
||||||
}
|
}
|
||||||
// https://b.corp.google.com/issues/153464409
|
|
||||||
// many local projects enable cert-* checks, which
|
|
||||||
// trigger bugprone-reserved-identifier.
|
|
||||||
tidyChecks = tidyChecks + ",-bugprone-reserved-identifier*,-cert-dcl51-cpp,-cert-dcl37-c"
|
|
||||||
// http://b/153757728
|
|
||||||
tidyChecks = tidyChecks + ",-readability-qualified-auto"
|
|
||||||
// http://b/155034563
|
|
||||||
tidyChecks = tidyChecks + ",-bugprone-signed-char-misuse"
|
|
||||||
// http://b/155034972
|
|
||||||
tidyChecks = tidyChecks + ",-bugprone-branch-clone"
|
|
||||||
// http://b/193716442
|
|
||||||
tidyChecks = tidyChecks + ",-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.
|
|
||||||
tidyChecks = tidyChecks + ",-bugprone-easily-swappable-parameters"
|
|
||||||
// http://b/216364337 - TODO: Follow-up after compiler update to
|
|
||||||
// disable or fix individual instances.
|
|
||||||
tidyChecks = tidyChecks + ",-cert-err33-c"
|
|
||||||
flags.TidyFlags = append(flags.TidyFlags, tidyChecks)
|
flags.TidyFlags = append(flags.TidyFlags, tidyChecks)
|
||||||
|
|
||||||
if ctx.Config().IsEnvTrue("WITH_TIDY") {
|
if ctx.Config().IsEnvTrue("WITH_TIDY") {
|
||||||
|
@@ -52,7 +52,7 @@ func TestTidyChecks(t *testing.T) {
|
|||||||
firstXyzChecks := "-checks='-*','xyz-*',"
|
firstXyzChecks := "-checks='-*','xyz-*',"
|
||||||
localXyzChecks := "'-*','xyz-*'"
|
localXyzChecks := "'-*','xyz-*'"
|
||||||
localAbcChecks := "'-abc*','xyz-*',mycheck"
|
localAbcChecks := "'-abc*','xyz-*',mycheck"
|
||||||
extraGlobalChecks := ",-bugprone-easily-swappable-parameters,"
|
extraGlobalChecks := ",${config.TidyGlobalNoChecks}"
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
libNumber int // 1,2,3,...
|
libNumber int // 1,2,3,...
|
||||||
checks []string // must have substrings in -checks
|
checks []string // must have substrings in -checks
|
||||||
|
Reference in New Issue
Block a user