[PATCH] D21320: Alternative to D1332

Marshall Clow via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 13 21:15:26 PDT 2016


mclow.lists updated this revision to Diff 60651.
mclow.lists added a comment.

@EricWF pointed out that this didn't actually suppress the warning that we were trying to suppress.
All I can say is that it did several weeks ago when I wrote it. Apparently clang has gotten pickier.

Use tag dispatch to choose, rather than an if. Same functionality, though.


http://reviews.llvm.org/D21320

Files:
  include/memory

Index: include/memory
===================================================================
--- include/memory
+++ include/memory
@@ -2522,6 +2522,13 @@
 
 // default_delete
 
+template <class _Tp, bool __isArray> struct __do_default_delete;
+template <class _Tp> struct __do_default_delete<_Tp, true>
+{	void operator() (_Tp* __ptr) const _NOEXCEPT { delete [] __ptr; }};
+
+template <class _Tp> struct __do_default_delete<_Tp, false>
+{	void operator() (_Tp* __ptr) const _NOEXCEPT { delete __ptr; }};
+
 template <class _Tp>
 struct _LIBCPP_TYPE_VIS_ONLY default_delete
 {
@@ -2533,11 +2540,13 @@
     template <class _Up>
         _LIBCPP_INLINE_VISIBILITY default_delete(const default_delete<_Up>&,
              typename enable_if<is_convertible<_Up*, _Tp*>::value>::type* = 0) _NOEXCEPT {}
-    _LIBCPP_INLINE_VISIBILITY void operator() (_Tp* __ptr) const _NOEXCEPT
+
+    _LIBCPP_INLINE_VISIBILITY void
+    operator() (_Tp* __ptr) const _NOEXCEPT
         {
             static_assert(sizeof(_Tp) > 0, "default_delete can not delete incomplete type");
             static_assert(!is_void<_Tp>::value, "default_delete can not delete incomplete type");
-            delete __ptr;
+            __do_default_delete<_Tp, is_array<_Tp>::value>()(__ptr);
         }
 };
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21320.60651.patch
Type: text/x-patch
Size: 1272 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160614/ebc5b3f8/attachment.bin>


More information about the cfe-commits mailing list