llvm-project/libcxx/test/std/utilities/memory
Louis Dionne 955dd7b7f3 [libc++] LWG2070: Use Allocator construction for objects created with allocate_shared
This patch updates `allocate_shared` to call `allocator_traits::construct`
when creating the object held inside the shared_pointer, and
`allocator_traits::destroy` when destroying it. This resolves
the part of P0674R1 that was originally filed as LWG2070.

This change is landed separately from the rest of P0674R1 because it is
incredibly tricky from an ABI perspective.

This is the reason why this change is so tricky is that we previously
used EBO in a compressed pair to store both the allocator and the object
type stored in the `shared_ptr`. However, starting in C++20, P0674
requires us to use Allocator construction for initializing the object type.
That requirement rules out the use of the EBO for the object type, since
using the EBO implies that the base will be initialized when the control
block is initialized (and hence we can't do it through Allocator construction).
Hence, supporting P0674 requires changing how we store the object type
inside the control block, which we do while being ABI compatible by using
some trickery with a properly aligned char buffer.

Fixes https://llvm.org/PR41900
Supersedes https://llvm.org/D62760

Differential Revision: https://reviews.llvm.org/D91201
2021-01-08 13:04:03 -05:00
..
allocator.tag [libc++] Remove the c++98 Lit feature from the test suite 2020-06-03 09:37:22 -04:00
allocator.traits [libc++] Mark a few more tests as unsupported on gcc-8/9. 2020-11-26 12:40:50 +01:00
allocator.uses [libc++] Remove useless nothing_to_do.pass.cpp tests 2020-04-03 13:48:34 -04:00
c.malloc Support tests in freestanding 2019-02-04 20:31:13 +00:00
default.allocator [libc++] Mark a few more tests as unsupported on gcc-8/9. 2020-11-26 12:40:50 +01:00
pointer.conversion [libc++] [LWG3374] Mark `to_address(const Ptr& p)` overload `constexpr`. 2020-12-06 15:26:26 +01:00
pointer.traits Add include for 'test_macros.h' to all the tests that were missing them. Thanks to Zoe for the (big, but simple) patch. NFC intended. 2019-05-31 18:35:30 +00:00
ptr.align Add include for 'test_macros.h' to all the tests that were missing them. Thanks to Zoe for the (big, but simple) patch. NFC intended. 2019-05-31 18:35:30 +00:00
specialized.algorithms [libc++] Mark a few more tests as unsupported on gcc-8/9. 2020-11-26 12:40:50 +01:00
storage.iterator Support tests in freestanding 2019-02-04 20:31:13 +00:00
temporary.buffer [libc++] Remove the c++98 Lit feature from the test suite 2020-06-03 09:37:22 -04:00
unique.ptr/unique.ptr.special [libc++] Add a libc++ configuration that does not support localization 2020-10-27 14:56:30 -04:00
util.dynamic.safety [libc++] Remove the c++98 Lit feature from the test suite 2020-06-03 09:37:22 -04:00
util.smartptr [libc++] LWG2070: Use Allocator construction for objects created with allocate_shared 2021-01-08 13:04:03 -05:00