From 0afab989794f84335e9a8e1821ded8afb440d1b4 Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Tue, 3 Jan 2017 00:16:18 +0000 Subject: [PATCH] Fix new/delete exception specifications to match libc++ after r290845 llvm-svn: 290847 --- libcxxabi/src/cxa_new_delete.cpp | 57 ++++++++------------------------ 1 file changed, 13 insertions(+), 44 deletions(-) diff --git a/libcxxabi/src/cxa_new_delete.cpp b/libcxxabi/src/cxa_new_delete.cpp index 7a2c864c3115..7609d7637f5a 100644 --- a/libcxxabi/src/cxa_new_delete.cpp +++ b/libcxxabi/src/cxa_new_delete.cpp @@ -14,6 +14,11 @@ #include #include +#if !defined(_THROW_BAD_ALLOC) || !defined(_NOEXCEPT) +#error _THROW_BAD_ALLOC and _NOEXCEPT libc++ macros must already be defined \ + by libc++. +#endif + /* [new.delete.single] @@ -33,10 +38,7 @@ */ __attribute__((__weak__, __visibility__("default"))) void * -operator new(std::size_t size) -#if !__has_feature(cxx_noexcept) - throw(std::bad_alloc) -#endif +operator new(std::size_t size) _THROW_BAD_ALLOC { if (size == 0) size = 1; @@ -70,12 +72,7 @@ that call. Otherwise, returns a null pointer. */ __attribute__((__weak__, __visibility__("default"))) void* -operator new(size_t size, const std::nothrow_t&) -#if __has_feature(cxx_noexcept) - noexcept -#else - throw() -#endif +operator new(size_t size, const std::nothrow_t&) _NOEXCEPT { void* p = 0; #ifndef _LIBCXXABI_NO_EXCEPTIONS @@ -99,10 +96,7 @@ Returns operator new(size). */ __attribute__((__weak__, __visibility__("default"))) void* -operator new[](size_t size) -#if !__has_feature(cxx_noexcept) - throw(std::bad_alloc) -#endif +operator new[](size_t size) _THROW_BAD_ALLOC { return ::operator new(size); } @@ -115,12 +109,7 @@ of that call. Otherwise, returns a null pointer. */ __attribute__((__weak__, __visibility__("default"))) void* -operator new[](size_t size, const std::nothrow_t&) -#if __has_feature(cxx_noexcept) - noexcept -#else - throw() -#endif +operator new[](size_t size, const std::nothrow_t&) _NOEXCEPT { void* p = 0; #ifndef _LIBCXXABI_NO_EXCEPTIONS @@ -145,12 +134,7 @@ earlier call to operator new. */ __attribute__((__weak__, __visibility__("default"))) void -operator delete(void* ptr) -#if __has_feature(cxx_noexcept) - noexcept -#else - throw() -#endif +operator delete(void* ptr) _NOEXCEPT { if (ptr) std::free(ptr); @@ -163,12 +147,7 @@ calls operator delete(ptr) */ __attribute__((__weak__, __visibility__("default"))) void -operator delete(void* ptr, const std::nothrow_t&) -#if __has_feature(cxx_noexcept) - noexcept -#else - throw() -#endif +operator delete(void* ptr, const std::nothrow_t&) _NOEXCEPT { ::operator delete(ptr); } @@ -180,12 +159,7 @@ Calls operator delete(ptr) */ __attribute__((__weak__, __visibility__("default"))) void -operator delete[] (void* ptr) -#if __has_feature(cxx_noexcept) - noexcept -#else - throw() -#endif +operator delete[] (void* ptr) _NOEXCEPT { ::operator delete(ptr); } @@ -197,12 +171,7 @@ calls operator delete[](ptr) */ __attribute__((__weak__, __visibility__("default"))) void -operator delete[] (void* ptr, const std::nothrow_t&) -#if __has_feature(cxx_noexcept) - noexcept -#else - throw() -#endif +operator delete[] (void* ptr, const std::nothrow_t&) _NOEXCEPT { ::operator delete[](ptr); }