[PATCH] Fix some problems with sized deletion in libc++

Marshall Clow mclow.lists at gmail.com
Tue Feb 17 07:46:35 PST 2015


Hi lvoufo, rsmith,

The sized deletion routines were recently added to libc++ (r229281). There are some problems with the current implementation.  This fixes some of those problems, but there are others extant:

1) How we're going to support vendors who ship new dylibs infrequently; compatibility with existing dylibs.  This is especially important if clang is going to implicitly generate calls to these routines.

2) The original commit had no tests.

http://reviews.llvm.org/D7699

Files:
  include/new
  src/new.cpp

Index: include/new
===================================================================
--- include/new
+++ include/new
@@ -139,9 +139,11 @@
 ;
 _LIBCPP_NEW_DELETE_VIS void* operator new(std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
 _LIBCPP_NEW_DELETE_VIS void  operator delete(void* __p) _NOEXCEPT;
+_LIBCPP_NEW_DELETE_VIS void  operator delete(void* __p, const std::nothrow_t&) _NOEXCEPT;
+#ifdef _LIBCPP_BUILDING_NEW || _LIBCPP_STD_VER >= 14
 _LIBCPP_NEW_DELETE_VIS void  operator delete(void* __p, std::size_t __sz) _NOEXCEPT;
-_LIBCPP_NEW_DELETE_VIS void  operator delete(void* __p, const std::nothrow_t&) _NOEXCEPT;
 _LIBCPP_NEW_DELETE_VIS void  operator delete(void* __p, std::size_t __sz, const std::nothrow_t&) _NOEXCEPT;
+#endif
 
 _LIBCPP_NEW_DELETE_VIS void* operator new[](std::size_t __sz)
 #if !__has_feature(cxx_noexcept)
@@ -150,9 +152,11 @@
 ;
 _LIBCPP_NEW_DELETE_VIS void* operator new[](std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
 _LIBCPP_NEW_DELETE_VIS void  operator delete[](void* __p) _NOEXCEPT;
+_LIBCPP_NEW_DELETE_VIS void  operator delete[](void* __p, const std::nothrow_t&) _NOEXCEPT;
+#ifdef _LIBCPP_BUILDING_NEW || _LIBCPP_STD_VER >= 14
 _LIBCPP_NEW_DELETE_VIS void  operator delete[](void* __p, std::size_t __sz) _NOEXCEPT;
-_LIBCPP_NEW_DELETE_VIS void  operator delete[](void* __p, const std::nothrow_t&) _NOEXCEPT;
 _LIBCPP_NEW_DELETE_VIS void  operator delete[](void* __p, std::size_t __sz, const std::nothrow_t&) _NOEXCEPT;
+#endif
 
 inline _LIBCPP_INLINE_VISIBILITY void* operator new  (std::size_t, void* __p) _NOEXCEPT {return __p;}
 inline _LIBCPP_INLINE_VISIBILITY void* operator new[](std::size_t, void* __p) _NOEXCEPT {return __p;}
Index: src/new.cpp
===================================================================
--- src/new.cpp
+++ src/new.cpp
@@ -140,9 +140,9 @@
 
 _LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
 void
-operator delete(void* ptr, size_t, const std::nothrow_t&) _NOEXCEPT
+operator delete(void* ptr, size_t, const std::nothrow_t& nt) _NOEXCEPT
 {
-    ::operator delete(ptr);
+    ::operator delete(ptr, nt);
 }
 
 _LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
@@ -168,9 +168,9 @@
 
 _LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
 void
-operator delete[] (void* ptr, size_t, const std::nothrow_t&) _NOEXCEPT
+operator delete[] (void* ptr, size_t, const std::nothrow_t& nt) _NOEXCEPT
 {
-    ::operator delete[](ptr);
+    ::operator delete[](ptr, nt);
 }
 
 #endif // !__GLIBCXX__

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7699.20084.patch
Type: text/x-patch
Size: 2450 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150217/e5a41042/attachment.bin>


More information about the cfe-commits mailing list