Add flag to enable assertions in Clang

Add a flag CLANG_ENABLE_ASSERTIONS to enable assertions in Clang,
similar to LLVM_ENABLE_ASSERTIONS in llvm.

Cherry-pick https://android-review.googlesource.com/#/c/134490/ from
AOSP

Change-Id: Id2a63516a98e4724f2157a41c0bfd621ff48bec3
diff --git a/Android.mk b/Android.mk
index d5495b3..4120a7c 100644
--- a/Android.mk
+++ b/Android.mk
@@ -1,5 +1,6 @@
 LOCAL_PATH := $(call my-dir)
 CLANG_ROOT_PATH := $(LOCAL_PATH)
+CLANG_ENABLE_ASSERTION := false
 
 include $(CLEAR_VARS)
 
diff --git a/clang-device-build.mk b/clang-device-build.mk
index 0bd088e..28c7916 100644
--- a/clang-device-build.mk
+++ b/clang-device-build.mk
@@ -8,6 +8,13 @@
 	-Wno-sign-promo \
 	$(LOCAL_CPPFLAGS)
 
+ifeq ($(CLANG_ENABLE_ASSERTION),true)
+LOCAL_CFLAGS :=	\
+	$(LOCAL_CFLAGS) \
+	-D_DEBUG	\
+	-UNDEBUG
+endif
+
 # Make sure bionic is first so we can include system headers.
 LOCAL_C_INCLUDES :=	\
 	$(CLANG_ROOT_PATH)/include	\
diff --git a/clang-host-build.mk b/clang-host-build.mk
index 81e9b1e..3594cc4 100644
--- a/clang-host-build.mk
+++ b/clang-host-build.mk
@@ -8,6 +8,13 @@
 	-Wno-sign-promo \
 	$(LOCAL_CPPFLAGS)
 
+ifeq ($(CLANG_ENABLE_ASSERTION),true)
+LOCAL_CFLAGS :=	\
+	$(LOCAL_CFLAGS) \
+	-D_DEBUG	\
+	-UNDEBUG
+endif
+
 # Make sure bionic is first so we can include system headers.
 LOCAL_C_INCLUDES :=	\
 	$(CLANG_ROOT_PATH)/include	\