Go to file
Eric Fiselier 4e7d53664d Add support for "fancy" pointers to shared_ptr. Fixes PR20616
Summary:
This patch add support for "fancy pointers/allocators" as well as fixing support for shared_pointer and "minimal" allocators.

Fancy pointers are class types that meet the NullablePointer requirements. In our case they are created by fancy allocators. `support/min_allocator.h` is an archetype for these types.

There are three types of changes made in this patch:
1. `_Alloc::template rebind<T>::other` -> `__allocator_traits_rebind<_Alloc, T>::type`. This change was made because allocators don't need a rebind template. `__allocator_traits_rebind` is used instead of `allocator_traits::rebind` because use of `allocator_traits::rebind` requires a workaround for when template aliases are unavailable.
2. `a.deallocate(this, 1)` -> `a.deallocate(pointer_traits<self>::pointer_to(*this), 1)`. This change change is made because fancy pointers aren't always constructible from raw pointers. 
3. `p.get()` -> `addressof(*p.get())`. Fancy pointers aren't actually a pointer. When we need a "real" pointer we take the address of dereferencing the fancy pointer. This should give us the actual raw pointer.

Test Plan: Tests were added using `support/min_allocator.h` to each affected shared_ptr overload and creation function. These tests can only be executed in C++11 or greater since min_allocator is only available then. A extra test was added for the non-variadic versions of allocate_shared. 

Reviewers: danalbert, mclow.lists

Reviewed By: mclow.lists

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D4859

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@220469 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-23 04:12:28 +00:00
cmake [libcxx] Redo adding support for building and testing with an ABI library not along linker paths 2014-10-19 00:42:41 +00:00
include Add support for "fancy" pointers to shared_ptr. Fixes PR20616 2014-10-23 04:12:28 +00:00
lib [libcxx] Redo adding support for building and testing with an ABI library not along linker paths 2014-10-19 00:42:41 +00:00
src Address some post-commit review comments on r217261 2014-09-05 20:28:44 +00:00
test Add support for "fancy" pointers to shared_ptr. Fixes PR20616 2014-10-23 04:12:28 +00:00
www Remove dead buildbot link 2014-10-21 02:46:31 +00:00
.arcconfig Update Arcanist config to point to reviews.llvm.org 2014-06-10 18:29:36 +00:00
CMakeLists.txt [libcxx] Add support for building and testing with an ABI library not along linker paths 2014-10-18 01:15:17 +00:00
CREDITS.TXT Add self to credits 2014-08-21 04:21:43 +00:00
LICENSE.TXT Update the copyright credits -- Happy new year 2014! 2014-01-01 08:27:31 +00:00
Makefile Exclude .svn (and other "dot" directories) when installing headers. 2014-03-13 16:13:54 +00:00