Commit Graph

15 Commits

Author SHA1 Message Date
Louis Dionne 7f1963dc8e [libc++] Move pointer safety related utilities out of <memory>
Differential Revision: https://reviews.llvm.org/D100318
2021-04-13 08:21:46 -04:00
Louis Dionne 916fecb499 [libc++] Split std::shared_ptr & friends out of <memory>
Differential Revision: https://reviews.llvm.org/D100318
2021-04-13 08:21:44 -04:00
Louis Dionne 21d6636d83 [libc++] Split std::unique_ptr out of <memory>
Differential Revision: https://reviews.llvm.org/D100318
2021-04-13 08:21:40 -04:00
Louis Dionne 4f9b2469f3 [libc++] Split the memory-related algorithms out of <memory>
Differential Revision: https://reviews.llvm.org/D100318
2021-04-13 08:21:38 -04:00
Louis Dionne be54341cd2 [libc++] Split std::raw_storage_iterator out of <memory>
Differential Revision: https://reviews.llvm.org/D100318
2021-04-13 08:21:35 -04:00
Louis Dionne 9b0a3388eb [libc++] Split __compressed_pair out of <memory>
Differential Revision: https://reviews.llvm.org/D100318
2021-04-13 08:21:31 -04:00
Louis Dionne 6a1ac88fc1 [libc++] Split std::get_temporary_buffer out of <memory>
Differential Revision: https://reviews.llvm.org/D100216
2021-04-12 11:46:31 -04:00
Louis Dionne 0b439e4cc9 [libc++] Split std::allocator out of <memory>
Differential Revision: https://reviews.llvm.org/D100216
2021-04-12 11:46:29 -04:00
Louis Dionne 26beecfe47 [libc++] Split auto_ptr out of <memory>
Differential Revision: https://reviews.llvm.org/D100216
2021-04-12 11:46:25 -04:00
Louis Dionne b125392259 [libc++] NFC: Move unused include of <limits> to allocator_traits.h
The include should have been moved when I split allocator_traits.h out
of memory.
2021-04-09 15:31:55 -04:00
Arthur O'Dwyer d41c6d51cb [libc++] Rationalize our treatment of contiguous iterators and __unwrap_iter().
- Implement C++20's changes to `reverse_iterator`, so that it won't be
    accidentally counted as a contiguous iterator in C++20 mode.
- Implement C++20's changes to `move_iterator` as well.
- `move_iterator` should not be contiguous. This fixes a bug where
    we optimized `std::copy`-of-move-iterators in an observable way.
    Add a regression test for that bugfix.
- Add libcxx tests for `__is_cpp17_contiguous_iterator` of all relevant
    standard iterator types. Particularly check that vector::iterator
    is still considered contiguous in all C++ modes, even C++03.

After this patch, there continues to be no supported way to write your
own iterator type in C++17-and-earlier such that libc++ will consider it
"contiguous"; however, we now fully support the C++20 approach (in C++20
mode only). If you want user-defined contiguous iterators in C++17-and-earlier,
libc++'s position is "please upgrade to C++20."

Differential Revision: https://reviews.llvm.org/D94807
2021-02-03 16:28:38 -05:00
Louis Dionne 2cb4a96a99 [libc++] NFCI: Refactor allocator_traits
The implementation had a lot of boilerplate and was more complicated than
necessary. This NFC refactoring introduces a few macros to reduce code
duplication, and uses a consistent style and formatting for the whole file.

Differential Revision: https://reviews.llvm.org/D94544
2021-01-18 17:37:25 -05:00
Louis Dionne a00290ed10 [libc++] Fix allocate_shared when used with an explicitly convertible allocator
When the allocator is only explicitly convertible from other specializations
of itself, the new version of std::allocate_shared would not work because
it would try to do an implicit conversion. This patch fixes the problem
and adds a test so that we don't fall into the same trap in the future.
2020-12-15 11:50:06 -05:00
Louis Dionne 19d57b5c42 [libc++] Refactor allocate_shared to use an allocation guard
This commit is a step towards making it easier to add support for arrays
in allocate_shared. Adding support for arrays will require writing multiple
functions, and the current complexity of writing allocate_shared is
prohibitive for understanding.

Differential Revision: https://reviews.llvm.org/D93130
2020-12-14 17:10:05 -05:00
Louis Dionne 7ad49aec12 [libc++] Split allocator_traits and pointer_traits out of <memory>
In addition to making the code a lot easier to grasp by localizing many
helper functions to the only file where they are actually needed, this
will allow creating helper functions that depend on allocator_traits
outside of <memory>.

This is done as part of implementing array support in allocate_shared,
which requires non-trivial array initialization algorithms that would be
better to keep out of <memory> for sanity. It's also a first step towards
splitting up our monolithic headers into finer grained ones, which will
make it easier to reuse functionality across the library. For example,
it's just weird that we had to define `addressof` inside <type_traits>
to avoid circular dependencies -- instead it's better to implement those
in true helper headers.

Differential Revision: https://reviews.llvm.org/D93074
2020-12-14 16:13:57 -05:00