This is an archive of the discontinued LLVM Phabricator instance.

Add support for "fancy" pointers to shared_ptr. Fixes PR20616
ClosedPublic

Authored by EricWF on Aug 11 2014, 5:47 PM.

Details

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.

Diff Detail

Event Timeline

EricWF updated this revision to Diff 12373.Aug 11 2014, 5:47 PM
EricWF retitled this revision from to Add support for "fancy" pointers to shared_ptr. Fixes PR20616.
EricWF updated this object.
EricWF edited the test plan for this revision. (Show Details)
EricWF added reviewers: mclow.lists, danalbert.
EricWF set the repository for this revision to rL LLVM.
EricWF updated this object.
EricWF added a subscriber: Unknown Object (MLST).
EricWF updated this revision to Diff 12539.Aug 14 2014, 9:35 PM

Implemented feedback from bug report. Use allocator traits to get the pointer type, not the allocator itself.

mclow.lists accepted this revision.Oct 22 2014, 9:09 PM
mclow.lists edited edge metadata.

This looks good to me. Thanks for doing this.

This revision is now accepted and ready to land.Oct 22 2014, 9:09 PM
mclow.lists added inline comments.Oct 22 2014, 9:13 PM
test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared_no_variadics.pass.cpp
115

This fails on C++03. Please add a space between the two closing angle brackets.

EricWF updated this revision to Diff 15299.Oct 22 2014, 9:21 PM
EricWF edited edge metadata.

Fix C++03 test.

EricWF closed this revision.Oct 22 2014, 9:22 PM

It looks like this has been committed. Can we close this revision (and mark PR20616 as fixed)?