From 518d150040a7830d5dbd23076fe2a2ded1093536 Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Thu, 28 Jun 2012 16:47:34 +0000 Subject: [PATCH] mark operator new(std::nothrow) as noalias (aka __attribute__((malloc)) git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@159359 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/__config | 6 ++++++ include/new | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/__config b/include/__config index 369417c4..3df583fd 100644 --- a/include/__config +++ b/include/__config @@ -391,6 +391,12 @@ template struct __static_assert_check {}; #define _LIBCPP_CONSTEXPR constexpr #endif +#ifdef __GNUC__ +#define _NOALIAS __attribute__((malloc)) +#else +#define _NOALIAS +#endif + #ifndef __has_feature #define __has_feature(__x) 0 #endif diff --git a/include/new b/include/new index 5bcbad0c..ae0951a7 100644 --- a/include/new +++ b/include/new @@ -96,7 +96,7 @@ _LIBCPP_VISIBLE void* operator new(std::size_t __sz) throw(std::bad_alloc) #endif ; -_LIBCPP_VISIBLE void* operator new(std::size_t __sz, const std::nothrow_t&) _NOEXCEPT; +_LIBCPP_VISIBLE void* operator new(std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _NOALIAS; _LIBCPP_VISIBLE void operator delete(void* __p) _NOEXCEPT; _LIBCPP_VISIBLE void operator delete(void* __p, const std::nothrow_t&) _NOEXCEPT; @@ -105,7 +105,7 @@ _LIBCPP_VISIBLE void* operator new[](std::size_t __sz) throw(std::bad_alloc) #endif ; -_LIBCPP_VISIBLE void* operator new[](std::size_t __sz, const std::nothrow_t&) _NOEXCEPT; +_LIBCPP_VISIBLE void* operator new[](std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _NOALIAS; _LIBCPP_VISIBLE void operator delete[](void* __p) _NOEXCEPT; _LIBCPP_VISIBLE void operator delete[](void* __p, const std::nothrow_t&) _NOEXCEPT;