summaryrefslogtreecommitdiff
path: root/libcxx/include/memory
AgeCommit message (Collapse)Author
2025-04-14[libc++] Implement P2897R7 aligned_accessor: An mdspan accessor expressing ↵Damien L-G
pointer over-alignment (#122603) Closes #118372
2025-02-10[libc++] Extract destroy algorithms into separate headers (#126449)Louis Dionne
This patch separates the destroy algorithms from the primitive construct_at and destroy_at operations, which are conceptually not algorithms. This makes it easier to start using these destroy algorithms from upcoming relocation facilities. As part of this, it also implements `std::destroy_at` for arrays without relying on the `std::destroy` algorithm, which is conceptually a higher-level facility.
2024-12-21[libc++][C++03] Use `__cxx03/` headers in C++03 mode (#109002)Nikolas Klauser
This patch implements the forwarding to frozen C++03 headers as discussed in https://discourse.llvm.org/t/rfc-freezing-c-03-headers-in-libc. In the RFC, we initially proposed selecting the right headers from the Clang driver, however consensus seemed to steer towards handling this in the library itself. This patch implements that direction. At a high level, the changes basically amount to making each public header look like this: ``` // inside <vector> #ifdef _LIBCPP_CXX03_LANG # include <__cxx03/vector> #else // normal <vector> content #endif ``` In most cases, public headers are simple umbrella headers so there isn't much code in the #else branch. In other cases, the #else branch contains the actual implementation of the header.
2024-12-10[libc++] Add #if 0 block to all the top-level headers (#119234)Nikolas Klauser
Including The frozen C++03 headers results in a lot of formatting changes in the main headers, so this splits these changes into a separate commit instead. This is part of https://discourse.llvm.org/t/rfc-freezing-c-03-headers-in-libc.
2024-09-16[libc++] Remove get_temporary_buffer and return_temporary_buffer (#100914)A. Jiang
Works towards P0619R4 / #99985. The use of `std::get_temporary_buffer` and `std::return_temporary_buffer` are replaced with `unique_ptr`-based RAII buffer holder. Escape hatches: - `_LIBCPP_ENABLE_CXX20_REMOVED_TEMPORARY_BUFFER` restores `std::get_temporary_buffer` and `std::return_temporary_buffer`. Drive-by changes: - In `<syncstream>`, states that `get_temporary_buffer` is now removed, because `<syncstream>` is added in C++20.
2024-07-21[libc++] Makes `unique_ptr operator*() noexcept. (#98047)Mark de Wever
This implements - LWG2762 unique_ptr operator*() should be noexcept. Differential Revision: https://reviews.llvm.org/D128214
2024-07-19[libc++][memory] P1132R8: `out_ptr` - a scalable output pointer abstraction ↵Hristo Hristov
(#73618) Differential Revision: https://reviews.llvm.org/D150525 Implements: - https://wg21.link/P1132R8 - `out_ptr` - a scalable output pointer abstraction - https://eel.is/c++draft/smartptr.adapt - 20.3.4 Smart pointer adaptors - https://wg21.link/LWG3734 - Inconsistency in `inout_ptr` and `out_ptr` for empty case - https://wg21.link/LWG3897- `inout_ptr` will not update raw pointer to 0 --------- Co-authored-by: Hristo Hristov <zingam@outlook.com>
2024-07-18[libc++] Include the rest of the detail headers by version in the umbrella ↵Nikolas Klauser
headers (#96032) This is a follow-up to #83740.
2024-06-07[libc++] Undeprecate shared_ptr atomic access APIs (#92920)Nico Weber
This patch reverts 9b832b72 (#87111): - [libc++] Deprecated `shared_ptr` Atomic Access APIs as per P0718R2 - [libc++] Implemented P2869R3: Remove Deprecated `shared_ptr` Atomic Access APIs from C++26 As explained in [1], the suggested replacement in P2869R3 is `__cpp_lib_atomic_shared_ptr`, which libc++ does not yet implement. Let's not deprecate the old way of doing things before the new way of doing things exists. [1]: https://github.com/llvm/llvm-project/pull/87111#issuecomment-2112740039
2024-04-14[libc++] Deprecated `shared_ptr` Atomic Access APIs as per P0718R2 & ↵Hristo Hristov
Implemented P2869R3: Remove Deprecated `shared_ptr` Atomic Access APIs from C++26 (#87111) Implements https://wg21.link/P2869R4 Implements deprecations as per https://wg21.link/P0718R2
2024-02-29[libc++] Clean up includes of <__assert> (#80091)Louis Dionne
Originally, we used __libcpp_verbose_abort to handle assertion failures. That function was declared from all public headers. Since we don't use that mechanism anymore, we don't need to declare __libcpp_verbose_abort from all public headers, and we can clean up a lot of unnecessary includes. This patch also moves the definition of the various assertion categories to the <__assert> header, since we now rely on regular IWYU for these assertion macros. rdar://105510916
2024-02-01[libc++][memory] P2652R2: Disallow Specialization of `allocator_traits` (#79978)Hristo Hristov
Implements P2652R2 <https://wg21.link/P2652R2>: - https://eel.is/c++draft/allocator.requirements.general - https://eel.is/c++draft/memory.syn - https://eel.is/c++draft/allocator.traits.general - https://eel.is/c++draft/allocator.traits.members - https://eel.is/c++draft/diff.cpp20.concepts - https://eel.is/c++draft/diff.cpp20.utilities --------- Co-authored-by: Zingam <zingam@outlook.com>
2024-01-20[libc++][memory] P2868R1: Removing deprecated typedef ↵Hristo Hristov
`std::allocator::is_always_equal` (#78562) Implements: - https://wg21.link/P2868R1 - https://wg21.link/LWG3170 --------- Co-authored-by: Zingam <zingam@outlook.com>
2023-12-30[libc++] Deprecates and removes shared_ptr::unqiue. (#76576)Mark de Wever
The status table incorrectly marks P0521R0 as nothing to do. This is not correct the function should be deprecated. During our latest monthly meeting we argreed to remove the _LIBCPP_ENABLE_CXXyy_REMOVED_FEATURES macros, therefore the new macro is not added to that global list. Implements - P0521R0 Proposed Resolution for CA 14 (shared_ptr use_count/unique) Implements parts of - P0619R4 Reviewing Deprecated Facilities of C++17 for C++20 --------- Co-authored-by: Nikolas Klauser <nikolasklauser@berlin.de>
2023-12-04[libc++][NFC] Add a few clang-format annotations (#74352)Louis Dionne
This is in preparation for clang-formatting the whole code base. These annotations are required either to avoid clang-format bugs or because the manually formatted code is significantly more readable than the clang-formatted alternative. All in all, it seems like very few annotations are required, which means that clang-format is doing a very good job in most cases.
2023-10-09[libc++] LWG 3821 uses_allocator_construction_args should have overload for ↵Hui
pair-like (#66939) This change addresses LWG 3821 and LWG 3677. - make `std::pair`'s constructor no longer takes `subrange` - `uses_allocator_construction_args` constraint changes w.r.t to `pair-like` types - `uses_allocator_construction_args` constraints checks `is-pair-like<remove_cv_t<T>>`
2023-06-12[libc++][spaceship] P1614R2: Removed global `operator!=` from `allocator`Hristo Hristov
Implements parts of P1614R2: - Removed global `operator!=` from `allocator` Reviewed By: #libc, Mordante Differential Revision: https://reviews.llvm.org/D152612
2023-04-21[libc++][PSTL] Remove current integrationNikolas Klauser
We decided to go a different route. To make the switch easier, rip out the old integration first and build on a clean base. Reviewed By: ldionne, #libc, #libc_abi Spies: arichardson, libcxx-commits Differential Revision: https://reviews.llvm.org/D148480
2023-04-09[libc++] Remove <cstdlib> includesNikolas Klauser
We changed the `abort` calls when trying to throw exceptions in `-fno-exceptions` mode to `__verbose_abort` calls, which removes the dependency in most files. Reviewed By: ldionne, #libc Spies: dim, emaste, mikhail.ramalho, smeenai, libcxx-commits Differential Revision: https://reviews.llvm.org/D146076
2023-03-10[libc++] Granularize <atomic> includesNikolas Klauser
Reviewed By: ldionne, Mordante, #libc Spies: arichardson, libcxx-commits Differential Revision: https://reviews.llvm.org/D144255
2023-01-23[libc++] implement P1020R1 P1973R1 make_unique[shared]_for_overwriteHui
Differential Revision: https://reviews.llvm.org/D140913
2022-11-05[libc++] Granularize <concept> includesNikolas Klauser
Reviewed By: ldionne, #libc Spies: libcxx-commits Differential Revision: https://reviews.llvm.org/D137283
2022-10-06[libc++] Implement P0591R4 (Utility functions to implement uses-allocator ↵Nikolas Klauser
construction) Reviewed By: ldionne, #libc, huixie90 Spies: huixie90, libcxx-commits, mgorny Differential Revision: https://reviews.llvm.org/D131898
2022-10-02Revert "[libc++] Implement P0591R4 (Utility functions to implement ↵Vitaly Buka
uses-allocator construction)" Breaks ubsan tests https://lab.llvm.org/buildbot/#/builders/85/builds/11131 This reverts commit 099384dcea49f5f4b0dc7e615c9845bf9baad4bc.
2022-10-01[libc++] Implement P0591R4 (Utility functions to implement uses-allocator ↵Nikolas Klauser
construction) Reviewed By: ldionne, #libc, huixie90 Spies: huixie90, libcxx-commits, mgorny Differential Revision: https://reviews.llvm.org/D131898
2022-09-27[libc++][NFC] Fix some standard-mandated includes commentsNikolas Klauser
Reviewed By: ldionne, #libc Spies: libcxx-commits Differential Revision: https://reviews.llvm.org/D134447
2022-09-05[libc++] Granularize the rest of memoryNikolas Klauser
Reviewed By: ldionne, #libc Spies: vitalybuka, paulkirth, libcxx-commits, mgorny Differential Revision: https://reviews.llvm.org/D132790
2022-09-03[libc++] Implement P2273R3 (`constexpr` `unique_ptr`)Igor Zhukov
Reviewed By: mordante, #libc Differential Revision: https://reviews.llvm.org/D131315
2022-09-03[NFC][libc++] Moves transitive includes location.Mark de Wever
As discussed in D132284 they will be moved to the end. Reviewed By: #libc, Mordante Differential Revision: https://reviews.llvm.org/D133212
2022-09-02Revert "[libc++] Granularize the rest of memory"Vitaly Buka
Breaks buildbots. This reverts commit 30adaa730c4768b5eb06719c808b2884fcf53cf3.
2022-09-02[libc++] Granularize the rest of memoryNikolas Klauser
Reviewed By: ldionne, #libc Spies: libcxx-commits, mgorny Differential Revision: https://reviews.llvm.org/D132790
2022-08-31[libc++] Reduces the number of transitive includes.Mark de Wever
This defines a new policy for removal of transitive includes. The goal of the policy it to make it relatively easy to remove headers when needed, but avoid breaking developers using and vendors shipping libc++. The method used is to guard transitive includes based on the C++ language version. For the upcoming C++23 we can remove headers when we want, but for other language versions we try to keep it to a minimum. In this code the transitive include of `<chrono>` is removed since D128577 introduces a header cycle between `<format>` and `<chrono>`. This cycle is indirectly required by the Standard. Our cycle dependency tool basically is a grep based tool, so it needs some hints to ignore cycles. With the input of our transitive include tests we can create a better tool. However that's out of the scope of this patch. Note the flag `_LIBCPP_REMOVE_TRANSITIVE_INCLUDES` remains unchanged. So users can still opt-out of transitives includes entirely. Reviewed By: #libc, ldionne, philnik Differential Revision: https://reviews.llvm.org/D132284
2022-08-19[libc++][NFC] Rename the constexpr macrosNikolas Klauser
This was discussed on Discord with the consensus that we should rename the macros. Reviewed By: ldionne, Mordante, var-const, avogelsgesang, jloser, #libc Spies: libcxx-commits Differential Revision: https://reviews.llvm.org/D131498
2022-08-06[libc++] Implement `operator<=>` for `unique_ptr`Adrian Vogelsgesang
Implements part of: - P1614R2 The Mothership has Landed Fixes LWG3426 Reviewed By: #libc, Mordante Differential Revision: https://reviews.llvm.org/D130838
2022-08-03[libc++] Implement `operator<=>` for `shared_ptr`Adrian Vogelsgesang
Implements part of: * P1614R2 The Mothership has Landed Fixes LWG3427 Reviewed By: #libc, Mordante Differential Revision: https://reviews.llvm.org/D130852
2022-07-27[libc++] Implement P1004R2 (constexpr std::vector)Nikolas Klauser
Reviewed By: #libc, ldionne Spies: mgorny, var-const, ormris, philnik, miscco, hiraditya, steven_wu, jkorous, ldionne, christof, libcxx-commits Differential Revision: https://reviews.llvm.org/D68365
2022-07-26[libc++] Use uninitialized algorithms for vectorNikolas Klauser
Reviewed By: ldionne, #libc Spies: huixie90, eaeltsin, joanahalili, bgraur, alexfh, hans, avogelsgesang, augusto2112, libcxx-commits, mgorny Differential Revision: https://reviews.llvm.org/D128146
2022-07-21Revert "[libc++] Use uninitialized algorithms for vector"Augusto Noronha
This reverts commit 23cf42e706fbc2a939ce1470da16599b42258aea.
2022-07-20[libc++] Use uninitialized algorithms for vectorNikolas Klauser
Reviewed By: ldionne, #libc Spies: libcxx-commits, mgorny Differential Revision: https://reviews.llvm.org/D128146
2022-07-08[libc++] Make parameter names consistent and enforce the naming style using ↵Nikolas Klauser
readability-identifier-naming Ensure that parameter names have the style `__lower_case` Reviewed By: ldionne, #libc Spies: aheejin, sstefan1, libcxx-commits, miyuki Differential Revision: https://reviews.llvm.org/D129051
2022-06-27[libc++] Re-add transitive includes that had been removed since LLVM 14Louis Dionne
This commit re-adds transitive includes that had been removed by 4cd04d1687f1, c36870c8e79c, a83f4b9cda57, 1458458b558d, 2e2f3158c604, and 489637e66dd3. This should cover almost all the includes that had been removed since LLVM 14 and that would contribute to breaking user code when releasing LLVM 15. It is possible to disable the inclusion of these headers by defining _LIBCPP_REMOVE_TRANSITIVE_INCLUDES. The intent is that vendors will enable that macro and start fixing downstream issues immediately. We can then remove the macro (and the transitive includes) by default in a future release. That way, we will break users only once by removing transitive includes in bulk instead of doing it bit by bit a every release, which is more disruptive for users. Note 1: The set of headers to re-add was found by re-generating the transitive include test on a checkout of release/14.x, which provided the list of all transitive includes we used to provide. Note 2: Several includes of <vector>, <optional>, <array> and <unordered_map> have been added in this commit. These transitive inclusions were added when we implemented boyer_moore_searcher in <functional>. Note 3: This is a best effort patch to try and resolve downstream breakage caused since branching LLVM 14. I wasn't able to perfectly mirror transitive includes in LLVM 14 for a few headers, so I added a release note explaining it. To summarize, adding boyer_moore_searcher created a bunch of circular dependencies, so we have to break backwards compatibility in a few cases. Differential Revision: https://reviews.llvm.org/D128661
2022-06-22[libc++] Complete the implementation of N4190Nikolas Klauser
Fixes #37402 Reviewed By: ldionne Spies: EricWF, avogelsgesang, libcxx-commits, arphaman Differential Revision: https://reviews.llvm.org/D124346
2022-06-17[libc++] Mark standard-mandated includes as suchNikolas Klauser
Reviewed By: ldionne, Mordante, #libc, saugustine Spies: saugustine, MaskRay, arichardson, mstorsjo, jloser, libcxx-commits, arphaman Differential Revision: https://reviews.llvm.org/D127953
2022-06-15[libc++] Removes unneeded <iterator> includes.Mark de Wever
Reviewed By: #libc, philnik Differential Revision: https://reviews.llvm.org/D127675
2022-06-10[libc++] Granularize <iterator> includesNikolas Klauser
Reviewed By: ldionne, #libc Spies: libcxx-commits, wenlei Differential Revision: https://reviews.llvm.org/D127445
2022-05-28[libc++] Remove unused __functional includesNikolas Klauser
Reviewed By: ldionne, #libc Spies: arichardson, smeenai, libcxx-commits, arphaman Differential Revision: https://reviews.llvm.org/D126098
2022-04-11[libc++] Implement P1007R3: std::assume_alignedLouis Dionne
This supersedes and incoroporates content from both D108906 and D54966, and also some original content. Co-Authored-by: Marshall Clow <mclow.lists@gmail.com> Co-Authored-by: Gonzalo Brito Gadeschi Differential Revision: https://reviews.llvm.org/D118938
2022-04-09[libc++] Implement P0401R6 (allocate_at_least)Nikolas Klauser
Reviewed By: ldionne, var-const, #libc Spies: mgorny, libcxx-commits, arichardson Differential Revision: https://reviews.llvm.org/D122877
2022-04-06[libc++] Support arrays in make_shared and allocate_shared (P0674R1)Louis Dionne
This patch implements P0674R1, i.e. support for arrays in std::make_shared and std::allocate_shared. Co-authored-by: Zoe Carver <z.zoelec2@gmail.com> Differential Revision: https://reviews.llvm.org/D62641
2022-03-30[libc++] Ensure that all public C++ headers include <__assert>Louis Dionne
This patch changes the requirement for getting the declaration of the assertion handler from including <__assert> to including any public C++ header of the library. Note that C compatibility headers are excluded because we don't implement all the C headers ourselves -- some of them are taken straight from the C library, like assert.h. It also adds a generated test to check it. Furthermore, this new generated test is designed in a way that will make it possible to replace almost all the existing test-generation scripts with this system in upcoming patches. Differential Revision: https://reviews.llvm.org/D122506