[libcxx] r229281 - Implement C++14's sized deallocation functions, since there are no longer implicitly defined by clang, as of r229241.
Richard Smith
richard at metafoo.co.uk
Sun Feb 15 18:04:25 PST 2015
On Sun, Feb 15, 2015 at 6:01 PM, Richard Smith <richard at metafoo.co.uk>
wrote:
> On Sat, Feb 14, 2015 at 9:18 PM, Larisse Voufo <lvoufo at google.com> wrote:
>
>> Author: lvoufo
>> Date: Sat Feb 14 23:18:55 2015
>> New Revision: 229281
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=229281&view=rev
>> Log:
>> Implement C++14's sized deallocation functions, since there are no longer
>> implicitly defined by clang, as of r229241.
>>
>> Modified:
>> libcxx/trunk/include/new
>> libcxx/trunk/src/new.cpp
>>
>> Modified: libcxx/trunk/include/new
>> URL:
>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/new?rev=229281&r1=229280&r2=229281&view=diff
>>
>> ==============================================================================
>> --- libcxx/trunk/include/new (original)
>> +++ libcxx/trunk/include/new Sat Feb 14 23:18:55 2015
>> @@ -50,12 +50,18 @@ new_handler get_new_handler() noexcept;
>> void* operator new(std::size_t size);
>> // replaceable
>> void* operator new(std::size_t size, const std::nothrow_t&) noexcept;
>> // replaceable
>> void operator delete(void* ptr) noexcept;
>> // replaceable
>> +void operator delete(void* ptr, std::size_t size) noexcept;
>> // replaceable, C++14
>> void operator delete(void* ptr, const std::nothrow_t&) noexcept;
>> // replaceable
>> +void operator delete(void* ptr, std::size_t size,
>> + const std::nothrow_t&) noexcept;
>> // replaceable, C++14
>>
>> void* operator new[](std::size_t size);
>> // replaceable
>> void* operator new[](std::size_t size, const std::nothrow_t&) noexcept;
>> // replaceable
>> void operator delete[](void* ptr) noexcept;
>> // replaceable
>> +void operator delete[](void* ptr, std::size_t size) noexcept;
>> // replaceable, C++14
>> void operator delete[](void* ptr, const std::nothrow_t&) noexcept;
>> // replaceable
>> +void operator delete[](void* ptr, std::size_t size,
>> + const std::nothrow_t&) noexcept;
>> // replaceable, C++14
>>
>> void* operator new (std::size_t size, void* ptr) noexcept;
>> void* operator new[](std::size_t size, void* ptr) noexcept;
>> @@ -133,7 +139,9 @@ _LIBCPP_NEW_DELETE_VIS void* operator ne
>> ;
>> _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, 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;
>>
>> _LIBCPP_NEW_DELETE_VIS void* operator new[](std::size_t __sz)
>> #if !__has_feature(cxx_noexcept)
>> @@ -142,7 +150,9 @@ _LIBCPP_NEW_DELETE_VIS void* operator ne
>> ;
>> _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, 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;
>>
>> 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;}
>>
>
> These new declarations should be wrapped in a version check; we should
> only declare them in <new> if we're in C++14 or later.
>
>
>> Modified: libcxx/trunk/src/new.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/new.cpp?rev=229281&r1=229280&r2=229281&view=diff
>>
>> ==============================================================================
>> --- libcxx/trunk/src/new.cpp (original)
>> +++ libcxx/trunk/src/new.cpp Sat Feb 14 23:18:55 2015
>> @@ -126,6 +126,13 @@ operator delete(void* ptr) _NOEXCEPT
>>
>> _LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
>> void
>> +operator delete(void* ptr, size_t) _NOEXCEPT
>> +{
>> + ::operator delete(ptr);
>> +}
>> +
>> +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
>> +void
>> operator delete(void* ptr, const std::nothrow_t&) _NOEXCEPT
>> {
>> ::operator delete(ptr);
>> @@ -133,9 +140,23 @@ operator delete(void* ptr, const std::no
>>
>> _LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
>> void
>> +operator delete(void* ptr, size_t, const std::nothrow_t&) _NOEXCEPT
>> +{
>> + ::operator delete(ptr);
>>
>
The default behavior for this function is required to be a call to
::operator delete(ptr, std::nothrow).
> +}
>> +
>> +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
>> +void
>> operator delete[] (void* ptr) _NOEXCEPT
>> {
>> - ::operator delete (ptr);
>> + ::operator delete(ptr);
>> +}
>> +
>> +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
>> +void
>> +operator delete[] (void* ptr, size_t) _NOEXCEPT
>> +{
>> + ::operator delete[](ptr);
>> }
>>
>> _LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
>> @@ -144,6 +165,13 @@ operator delete[] (void* ptr, const std:
>> {
>> ::operator delete[](ptr);
>> }
>> +
>> +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
>> +void
>> +operator delete[] (void* ptr, size_t, const std::nothrow_t&) _NOEXCEPT
>> +{
>> + ::operator delete[](ptr);
>>
>
And similarly here.
> +}
>>
>> #endif // !__GLIBCXX__
>
>
Can you add some tests for the added functions?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150215/3391db16/attachment.html>
More information about the cfe-commits
mailing list