Add clang-tidy.sh to filter out troublesome flags.

* Some flags are accepted by clang but not clang-tidy.
  They could cause the diagnostic-unused-command-line-argument warning.
  Flag -flto messed up the -I flags.
* Add clang-diagnostic-unused-command-line-argument to
  default clang-tidy checks.
* Move CLANG_TIDY_UNKNOWN_CFLAGS to build/make/core/clang/tidy.mk.

Bug: 111850071
Bug: 111885396
Test: build with WITH_TIDY=1
Change-Id: Iabeeb27715acf83ef6aafe3e77206b9a01a0d889
This commit is contained in:
Chih-Hung Hsieh
2018-08-15 11:28:38 -07:00
parent 158f2d9eaf
commit a7aa958e6e
4 changed files with 43 additions and 15 deletions

View File

@@ -19,18 +19,6 @@ import (
"strings"
)
// clang-tidy doesn't recognize every flag that clang does. This is unlikely to
// be a complete list, but we can populate this with the ones we know to avoid
// issues with clang-diagnostic-unused-command-line-argument.
// b/111885396: -flto affected header include directory;
// -fsanitize and -fwhole-program-vtables need -flto.
var ClangTidyUnknownCflags = sorted([]string{
"-Wa,%",
"-flto",
"-fsanitize=%",
"-fwhole-program-vtables",
})
func init() {
// Most Android source files are not clang-tidy clean yet.
// Global tidy checks include only google*, performance*,
@@ -42,6 +30,7 @@ func init() {
}
return strings.Join([]string{
"-*",
"clang-diagnostic-unused-command-line-argument",
"google*",
"misc-macro-parentheses",
"performance*",
@@ -58,6 +47,7 @@ func init() {
}
return strings.Join([]string{
"-*",
"clang-diagnostic-unused-command-line-argument",
"google*",
"-google-build-using-namespace",
"-google-default-arguments",