diff options
-rw-r--r-- | .clang-tidy | 4 | ||||
-rw-r--r-- | Android.bp | 21 | ||||
-rw-r--r-- | system/build/Android.bp | 1 | ||||
-rw-r--r-- | system/gd/Android.bp | 54 | ||||
-rw-r--r-- | system/gd/dumpsys/Android.bp | 3 |
5 files changed, 27 insertions, 56 deletions
diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000000..df0d649f1f --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,4 @@ +--- +CheckOptions: + - key: misc-include-cleaner.IgnoreHeaders + value: (fmt/.*|bits/pthread_types\.h) diff --git a/Android.bp b/Android.bp index 9fbf29d0df..7fbd19909a 100644 --- a/Android.bp +++ b/Android.bp @@ -75,6 +75,27 @@ cc_defaults { cpp_std: "c++20", } +// List of tidy checks that are enabled for cc targets. +// Note that the goal is not to enable all checks, many of them will +// appear as noise especially in the modernize-* range. +bluetooth_tidy_checks = [ + "-*", + "misc-*", + + // This check implements detection of local variables which could be declared + // as const but are not. + "-misc-const-correctness", +] + +// This default tidy checks that will be run against all the cc targets +// developed by the Bluetooth team. +cc_defaults { + name: "bluetooth_tidy", + tidy: true, + tidy_checks: bluetooth_tidy_checks, + tidy_checks_as_errors: bluetooth_tidy_checks, +} + java_defaults { name: "bluetooth_errorprone_rules", errorprone: { diff --git a/system/build/Android.bp b/system/build/Android.bp index fd6636b0c5..13f1ccccf5 100644 --- a/system/build/Android.bp +++ b/system/build/Android.bp @@ -11,6 +11,7 @@ cc_defaults { name: "fluoride_defaults", defaults: [ "bluetooth_cflags", + "bluetooth_tidy", ], cflags: [ "-DEXPORT_SYMBOL=__attribute__((visibility(\"default\")))", diff --git a/system/gd/Android.bp b/system/gd/Android.bp index 5f67289b2f..579aae7d44 100644 --- a/system/gd/Android.bp +++ b/system/gd/Android.bp @@ -12,9 +12,7 @@ cc_defaults { name: "gd_defaults", defaults: [ "bluetooth_cflags", - ], - tidy_checks: [ - "-performance-unnecessary-value-param", + "bluetooth_tidy", ], target: { android: { @@ -39,56 +37,6 @@ cc_defaults { header_libs: ["jni_headers"], } -cc_defaults { - name: "gd_clang_tidy", - tidy: true, - tidy_checks: [ - "-bugprone*", - "-cert-dcl21-cpp", // warning: overloaded returns a non-constant object instead of a constant object type - "-cert-dcl59-cpp", // warning: do not use unnamed namespaces in header files - "-cert-msc30-c", // warning: rand() has limited randomness; use C++11 random library instead - "-cert-msc50-cpp", // warning: rand() has limited randomness; use C++11 random library instead - "-cert-oop54-cpp", // warning: operator=() does not handle self-assignment properly - "-google*", - "-performance*", - "clang-analyzer-core.CallAndMessage", - "clang-analyzer-optin.cplusplus.UninitializedObject", - ], - tidy_checks_as_errors: [ - "clang-analyzer-core.CallAndMessage", - "clang-analyzer-optin.cplusplus.UninitializedObject", - "cppcoreguidelines-pro-type-member-init", - ], - tidy_flags: [ - "--header-filter=^.*packages/modules/Bluetooth/system/.*.h$", - - "--extra-arg-before=-Xclang", - "--extra-arg-before=-analyzer-config", - - "--extra-arg-before=-Xclang", - "--extra-arg-before=optin.cplusplus.UninitializedObject:Pedantic=true", - - "--extra-arg-before=-Xclang", - "--extra-arg-before=-analyzer-config", - - "--extra-arg-before=-Xclang", - "--extra-arg-before=optin.cplusplus.UninitializedObject:CheckPointeeInitialization=true", - - ], -} - -// Clang is targeted for android core libraries but other base libraries -// may not support clang tidy recommendations (e.g. MacOS) -cc_defaults { - name: "gd_clang_tidy_ignore_android", - tidy: true, - tidy_checks: [ - "-android-cloexec-accept", // warning: prefer accept4() to accept() because accept4() allows SOCK_CLOEXEC - "-android-cloexec-pipe2", // warning: 'pipe2' should use O_CLOEXEC where possible - "-android-cloexec-socket", // warning: 'pipe2' should use O_CLOEXEC where possible - ], -} - soong_config_module_type { name: "mgmt_cc_defaults", module_type: "cc_defaults", diff --git a/system/gd/dumpsys/Android.bp b/system/gd/dumpsys/Android.bp index 085c44b7f9..f26ef97f9b 100644 --- a/system/gd/dumpsys/Android.bp +++ b/system/gd/dumpsys/Android.bp @@ -155,7 +155,6 @@ cc_library { name: "libbluetooth-dumpsys", host_supported: true, defaults: [ - "gd_clang_tidy", "gd_defaults", ], generated_sources: [ @@ -171,7 +170,6 @@ cc_library { name: "libbluetooth-dumpsys-test", host_supported: true, defaults: [ - "gd_clang_tidy", "gd_defaults", ], generated_sources: [ @@ -183,7 +181,6 @@ cc_library { name: "libbluetooth-dumpsys-unittest", host_supported: true, defaults: [ - "gd_clang_tidy", "gd_defaults", ], generated_headers: [ |