]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Make Asan detection work for Clang [PR103453]
authorJonathan Wakely <jwakely@redhat.com>
Tue, 30 Nov 2021 13:14:38 +0000 (13:14 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Wed, 5 Jan 2022 18:08:19 +0000 (18:08 +0000)
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)

libstdc++-v3/config/allocator/malloc_allocator_base.h
libstdc++-v3/config/allocator/new_allocator_base.h

index dbe7c761548be9ff7131c0cbdd29b5f63a2dfd6a..692e9d1124b8ad271674d24e5e1e89394d648997 100644 (file)
@@ -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
index ea5425545e098e8e07debdb4d0cff94c5411d339..8e64b05a66456fd32d986315e4512850711f4e88 100644 (file)
@@ -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