From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id DC636385801B; Tue, 30 Nov 2021 20:11:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DC636385801B MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r12-5636] libstdc++: Make Asan detection work for Clang [PR103453] X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: 36421e76a7150621f2a5c7060ddd3f80aa825a40 X-Git-Newrev: cca6090b13ab503bef1cfa327e2d107789d6bd30 Message-Id: <20211130201116.DC636385801B@sourceware.org> Date: Tue, 30 Nov 2021 20:11:16 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Nov 2021 20:11:17 -0000 https://gcc.gnu.org/g:cca6090b13ab503bef1cfa327e2d107789d6bd30 commit r12-5636-gcca6090b13ab503bef1cfa327e2d107789d6bd30 Author: Jonathan Wakely 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. 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 d7b56e3c9ef..b798d3fd448 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 77ee8b73979..7c52fef63de 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