From fac192648140a81c078fba79d4a17ac098e8935d Mon Sep 17 00:00:00 2001 From: Chih-Hung Hsieh Date: Mon, 8 Aug 2016 15:01:59 -0700 Subject: [PATCH] Simplify DEFAULT_LOCAL_TIDY_CHECKS. * Now each local directory path is matched against multiple patterns and only the last matched one will be used, or the DEFAULT_GLOBAL_TIDY_CHECKS is used. Bug: http://b/27779618 Change-Id: I786e6cacd8a680a034b4bc09f561f658177d9b17 Test: build with WITH_TIDY=1. --- core/clang/tidy.mk | 50 +++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/core/clang/tidy.mk b/core/clang/tidy.mk index d50b43d49e..860257fac7 100644 --- a/core/clang/tidy.mk +++ b/core/clang/tidy.mk @@ -19,30 +19,30 @@ # and misc-macro-parentheses, but not google-readability* # or google-runtime-references. DEFAULT_GLOBAL_TIDY_CHECKS := \ - -*,google*,performance*,misc-macro-parentheses \ - ,-google-readability*,-google-runtime-references + $(subst $(space),, \ + -*,google*,performance*,misc-macro-parentheses \ + ,-google-readability*,-google-runtime-references \ + ) + +# There are too many clang-tidy warnings in external and vendor projects. +# Enable only some google checks for these projects. +DEFAULT_EXTERNAL_VENDOR_TIDY_CHECKS := \ + $(subst $(space),, \ + -*,google*,-google-build-using-namespace \ + ,-google-readability*,-google-runtime-references \ + ,-google-explicit-constructor,-google-runtime-int \ + ) -# Disable style rules usually not followed by external projects. # Every word in DEFAULT_LOCAL_TIDY_CHECKS list has the following format: -# :, -# The tidy-check-patterns of all matching local_path_prefixes will be used. -# For example, external/google* projects will have: -# ,-google-build-using-namespace,-google-explicit-constructor -# ,-google-runtime-int,-misc-macro-parentheses, -# ,google-runtime-int,misc-macro-parentheses -# where google-runtime-int and misc-macro-parentheses are enabled at the end. +# :, +# The last matched local_path_prefix should be the most specific to be used. DEFAULT_LOCAL_TIDY_CHECKS := \ - external/:,-google-build-using-namespace \ - external/:,-google-explicit-constructor,-google-runtime-int \ - external/:,-misc-macro-parentheses \ - external/google:,google-runtime-int,misc-macro-parentheses \ - external/webrtc/:,google-runtime-int \ - hardware/qcom:,-google-build-using-namespace \ - hardware/qcom:,-google-explicit-constructor,-google-runtime-int \ - vendor/lge:,-google-build-using-namespace,-misc-macro-parentheses \ - vendor/lge:,-google-explicit-constructor,-google-runtime-int \ - vendor/widevine:,-google-build-using-namespace,-misc-macro-parentheses \ - vendor/widevine:,-google-explicit-constructor,-google-runtime-int \ + external/:$(DEFAULT_EXTERNAL_VENDOR_TIDY_CHECKS) \ + external/google:$(DEFAULT_GLOBAL_TIDY_CHECKS) \ + external/webrtc:$(DEFAULT_GLOBAL_TIDY_CHECKS) \ + hardware/qcom:$(DEFAULT_EXTERNAL_VENDOR_TIDY_CHECKS) \ + vendor/:$(DEFAULT_EXTERNAL_VENDOR_TIDY_CHECKS) \ + vendor/google:$(DEFAULT_GLOBAL_TIDY_CHECKS) \ # Returns 2nd word of $(1) if $(2) has prefix of the 1st word of $(1). define find_default_local_tidy_check2 @@ -54,11 +54,11 @@ define find_default_local_tidy_check $(call find_default_local_tidy_check2,$(subst :,$(space),$(1)),$(2)) endef -# Returns concatenated tidy check patterns from the -# DEFAULT_GLOBAL_TIDY_CHECKS and all matched patterns -# in DEFAULT_LOCAL_TIDY_CHECKS based on given directory path $(1). +# Returns the default tidy check list for local project path $(1). +# Match $(1) with all patterns in DEFAULT_LOCAL_TIDY_CHECKS and use the last +# most specific pattern. define default_global_tidy_checks -$(subst $(space),, \ +$(lastword \ $(DEFAULT_GLOBAL_TIDY_CHECKS) \ $(foreach pattern,$(DEFAULT_LOCAL_TIDY_CHECKS), \ $(call find_default_local_tidy_check,$(pattern),$(1)) \