Merge "RootCanal: Enable ASan and UBSan and clang-tidy on root-canal"
diff --git a/gd/Android.bp b/gd/Android.bp
index 6fb243f..a1becc5 100644
--- a/gd/Android.bp
+++ b/gd/Android.bp
@@ -71,6 +71,35 @@
     },
 }
 
+cc_defaults {
+    name: "gd_clang_tidy",
+    tidy: true,
+    tidy_checks: [
+        "cppcoreguidelines-pro-type-member-init",
+        "clang-analyzer-core.CallAndMessage",
+        "clang-analyzer-optin.cplusplus.UninitializedObject",
+        "-google*",
+        "-performance*",
+        "-bugprone*",
+    ],
+    tidy_checks_as_errors: [
+        "cppcoreguidelines-pro-type-member-init",
+        "clang-analyzer-core.CallAndMessage",
+        "clang-analyzer-optin.cplusplus.UninitializedObject",
+    ],
+    tidy_flags: [
+        "--header-filter=^.*system/bt/.*.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",
+    ],
+}
+
 cc_library {
     name: "libbluetooth_gd",
     defaults: [
diff --git a/vendor_libs/test_vendor_lib/Android.bp b/vendor_libs/test_vendor_lib/Android.bp
index 5f551e6..d3b85f9 100644
--- a/vendor_libs/test_vendor_lib/Android.bp
+++ b/vendor_libs/test_vendor_lib/Android.bp
@@ -2,7 +2,10 @@
 // ========================================================
 cc_library_static {
     name: "libbt-rootcanal",
-    defaults: ["libchrome_support_defaults"],
+    defaults: [
+        "libchrome_support_defaults",
+        "gd_clang_tidy",
+    ],
     host_supported: true,
     proprietary: true,
     srcs: [
@@ -108,6 +111,7 @@
     name: "root-canal",
     defaults: [
         "libchrome_support_defaults",
+        "gd_clang_tidy",
     ],
     srcs: [
         "desktop/root_canal_main.cc",
@@ -134,6 +138,10 @@
         "libbt-rootcanal-types",
         "libbt-rootcanal",
     ],
+    sanitize: {
+        address: true,
+        all_undefined: true,
+    },
 }
 
 genrule {