[gcc r10-10378] libstdc++: Make Asan detection work for Clang [PR103453]
Jonathan Wakely
redi@gcc.gnu.org
Wed Jan 5 22:06:48 GMT 2022
https://gcc.gnu.org/g:37fec1c1b0c942d861dd51b31d099084826a485b
commit r10-10378-g37fec1c1b0c942d861dd51b31d099084826a485b
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Tue Nov 30 13:14:38 2021 +0000
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.
(cherry picked from commit cca6090b13ab503bef1cfa327e2d107789d6bd30)
Diff:
---
libstdc++-v3/config/allocator/malloc_allocator_base.h | 10 ++++++++--
libstdc++-v3/config/allocator/new_allocator_base.h | 10 ++++++++--
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 dbe7c761548..692e9d1124b 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 ea5425545e0..8e64b05a664 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
More information about the Libstdc++-cvs
mailing list