From 0a33f65cc8c7da78917ad3f24064ca2ad4c4dbfd Mon Sep 17 00:00:00 2001 From: Chih-Hung Hsieh Date: Tue, 6 Sep 2016 20:06:28 -0700 Subject: [PATCH] Define DEFAULT_TIDY_HEADER_DIRS. Let clang-tidy report warnings in header files in the system and current directories but not the external and vendor directories. Test: build with WITH_TIDY=1 Change-Id: I1723b8eb95948961fb7164a19989e0a926e5bf8a --- core/binary.mk | 2 +- core/clang/tidy.mk | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/core/binary.mk b/core/binary.mk index fb3189074..ad0bbcc05 100644 --- a/core/binary.mk +++ b/core/binary.mk @@ -1649,7 +1649,7 @@ ifneq (,$(filter 1 true,$(my_tidy_enabled))) endif # If tidy flags are not specified, default to check all header files. ifeq ($(my_tidy_flags),) - my_tidy_flags := -header-filter=.* + my_tidy_flags := $(call default_tidy_header_filter,$(LOCAL_PATH)) endif endif endif diff --git a/core/clang/tidy.mk b/core/clang/tidy.mk index 3df0299a3..7ec937826 100644 --- a/core/clang/tidy.mk +++ b/core/clang/tidy.mk @@ -73,3 +73,25 @@ $(lastword \ ) \ ) endef + +# Give warnings to header files only in selected directories. +# Do not give warnings to external or vendor header files, +# which contain too many warnings. +DEFAULT_TIDY_HEADER_DIRS := \ + art/ \ + |bionic/ \ + |bootable/ \ + |build/ \ + |cts/ \ + |dalvik/ \ + |developers/ \ + |development/ \ + |frameworks/ \ + |libcore/ \ + |libnativehelper/ \ + |system/ + +# Default filter contains current directory $1 and DEFAULT_TIDY_HEADER_DIRS. +define default_tidy_header_filter + -header-filter="($(subst $(space),,$1|$(DEFAULT_TIDY_HEADER_DIRS)))" +endef