be0c12
From 39b10c9e7e4ad80adc0e8c43f7d1917edee515dd Mon Sep 17 00:00:00 2001
be0c12
From: Evgeny Vereshchagin <evvers@ya.ru>
be0c12
Date: Sun, 2 Dec 2018 08:28:24 +0100
be0c12
Subject: [PATCH] util-lib: introduce HAS_FEATURE_ADDRESS_SANITIZER
be0c12
be0c12
https://clang.llvm.org/docs/AddressSanitizer.html#conditional-compilation-with-has-feature-address-sanitizer
be0c12
(cherry picked from commit 289acab951c5937fdf6d3a2666f411fd66dd20e5)
be0c12
be0c12
Related: #2017033
be0c12
---
be0c12
 src/basic/macro.h | 11 +++++++++++
be0c12
 1 file changed, 11 insertions(+)
be0c12
be0c12
diff --git a/src/basic/macro.h b/src/basic/macro.h
be0c12
index 0fe6a62aa8..62f2359633 100644
be0c12
--- a/src/basic/macro.h
be0c12
+++ b/src/basic/macro.h
be0c12
@@ -55,6 +55,17 @@
be0c12
 #  endif
be0c12
 #endif
be0c12
 
be0c12
+#if !defined(HAS_FEATURE_ADDRESS_SANITIZER)
be0c12
+#  if defined(__has_feature)
be0c12
+#    if __has_feature(address_sanitizer)
be0c12
+#      define HAS_FEATURE_ADDRESS_SANITIZER 1
be0c12
+#    endif
be0c12
+#  endif
be0c12
+#  if !defined(HAS_FEATURE_ADDRESS_SANITIZER)
be0c12
+#    define HAS_FEATURE_ADDRESS_SANITIZER 0
be0c12
+#  endif
be0c12
+#endif
be0c12
+
be0c12
 /* Temporarily disable some warnings */
be0c12
 #define DISABLE_WARNING_DECLARATION_AFTER_STATEMENT                     \
be0c12
         _Pragma("GCC diagnostic push");                                 \