aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2021-11-30 13:14:38 +0000
committerJonathan Wakely <jwakely@redhat.com>2021-11-30 20:10:19 +0000
commitcca6090b13ab503bef1cfa327e2d107789d6bd30 (patch)
tree305a334b664a37dd1cb6a0870150ff7b778e17f3
parent36421e76a7150621f2a5c7060ddd3f80aa825a40 (diff)
downloadgcc-cca6090b13ab503bef1cfa327e2d107789d6bd30.zip
gcc-cca6090b13ab503bef1cfa327e2d107789d6bd30.tar.gz
gcc-cca6090b13ab503bef1cfa327e2d107789d6bd30.tar.bz2
libstdc++: Make Asan detection work for Clang [PR103453]
Clang doesn't define __SANITIZE_ADDRESS__ so use its __has_feature check to detect Asan instead. libstdc++-v3/ChangeLog: PR libstdc++/103453 * config/allocator/malloc_allocator_base.h (_GLIBCXX_SANITIZE_STD_ALLOCATOR): Define for Clang. * config/allocator/new_allocator_base.h (_GLIBCXX_SANITIZE_STD_ALLOCATOR): Likewise.
-rw-r--r--libstdc++-v3/config/allocator/malloc_allocator_base.h10
-rw-r--r--libstdc++-v3/config/allocator/new_allocator_base.h10
2 files changed, 16 insertions, 4 deletions
diff --git a/libstdc++-v3/config/allocator/malloc_allocator_base.h b/libstdc++-v3/config/allocator/malloc_allocator_base.h
index d7b56e3..b798d3f 100644
--- a/libstdc++-v3/config/allocator/malloc_allocator_base.h
+++ b/libstdc++-v3/config/allocator/malloc_allocator_base.h
@@ -52,8 +52,14 @@ namespace std
# define __allocator_base __gnu_cxx::malloc_allocator
#endif
-#if defined(__SANITIZE_ADDRESS__) && !defined(_GLIBCXX_SANITIZE_STD_ALLOCATOR)
-# define _GLIBCXX_SANITIZE_STD_ALLOCATOR 1
+#ifndef _GLIBCXX_SANITIZE_STD_ALLOCATOR
+# if defined(__SANITIZE_ADDRESS__)
+# define _GLIBCXX_SANITIZE_STD_ALLOCATOR 1
+# elif defined __has_feature
+# if __has_feature(address_sanitizer)
+# define _GLIBCXX_SANITIZE_STD_ALLOCATOR 1
+# endif
+# endif
#endif
#endif
diff --git a/libstdc++-v3/config/allocator/new_allocator_base.h b/libstdc++-v3/config/allocator/new_allocator_base.h
index 77ee8b7..7c52fef 100644
--- a/libstdc++-v3/config/allocator/new_allocator_base.h
+++ b/libstdc++-v3/config/allocator/new_allocator_base.h
@@ -52,8 +52,14 @@ namespace std
# define __allocator_base __gnu_cxx::new_allocator
#endif
-#if defined(__SANITIZE_ADDRESS__) && !defined(_GLIBCXX_SANITIZE_STD_ALLOCATOR)
-# define _GLIBCXX_SANITIZE_STD_ALLOCATOR 1
+#ifndef _GLIBCXX_SANITIZE_STD_ALLOCATOR
+# if defined(__SANITIZE_ADDRESS__)
+# define _GLIBCXX_SANITIZE_STD_ALLOCATOR 1
+# elif defined __has_feature
+# if __has_feature(address_sanitizer)
+# define _GLIBCXX_SANITIZE_STD_ALLOCATOR 1
+# endif
+# endif
#endif
#endif