[libcxx-commits] [PATCH] D60176: [libc++][libc++abi] Don't provide new/delete when built with ASan, HWASan or TSan

Petr Hosek via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Apr 3 15:47:52 PDT 2019


phosek updated this revision to Diff 193616.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60176/new/

https://reviews.llvm.org/D60176

Files:
  libcxx/src/new.cpp
  libcxxabi/src/stdlib_new_delete.cpp


Index: libcxxabi/src/stdlib_new_delete.cpp
===================================================================
--- libcxxabi/src/stdlib_new_delete.cpp
+++ libcxxabi/src/stdlib_new_delete.cpp
@@ -17,6 +17,12 @@
 #error The _THROW_BAD_ALLOC, _NOEXCEPT, and _LIBCXXABI_WEAK libc++ macros must \
        already be defined by libc++.
 #endif
+
+// Sanitizer runtimes provide their own definitions of new and delete operators.
+#if !__has_feature(address_sanitizer) && \
+    !__has_feature(hwaddress_sanitizer) && \
+    !__has_feature(thread_sanitizer)
+
 // Implement all new and delete operators as weak definitions
 // in this shared library, so that they can be overridden by programs
 // that define non-weak copies of the functions.
@@ -259,4 +265,5 @@
     ::operator delete[](ptr, alignment);
 }
 
+#endif // !address_sanitizer && !hwaddress_sanitizer && !thread_sanitizer
 #endif // !_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
Index: libcxx/src/new.cpp
===================================================================
--- libcxx/src/new.cpp
+++ libcxx/src/new.cpp
@@ -57,6 +57,11 @@
     !defined(_LIBCPP_ABI_VCRUNTIME) &&      \
     !defined(_LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS)
 
+// Sanitizer runtimes provide their own definitions of new and delete operators.
+#if !__has_feature(address_sanitizer) && \
+    !__has_feature(hwaddress_sanitizer) && \
+    !__has_feature(thread_sanitizer)
+
 // Implement all new and delete operators as weak definitions
 // in this shared library, so that they can be overridden by programs
 // that define non-weak copies of the functions.
@@ -298,4 +303,5 @@
 }
 
 #endif // !_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
+#endif // !address_sanitizer && !hwaddress_sanitizer && !thread_sanitizer
 #endif // !__GLIBCXX__ && !_LIBCPP_ABI_VCRUNTIME && !_LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60176.193616.patch
Type: text/x-patch
Size: 1837 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20190403/7c755c6a/attachment.bin>


More information about the libcxx-commits mailing list