[libcxx-commits] [libcxx] 94e7c0b - [libc++] Remove get_temporary_buffer and return_temporary_buffer (#100914)
via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Sep 16 08:53:11 PDT 2024
Author: A. Jiang
Date: 2024-09-16T11:53:05-04:00
New Revision: 94e7c0b051c79fd56205f115771980f2e7812306
URL: https://github.com/llvm/llvm-project/commit/94e7c0b051c79fd56205f115771980f2e7812306
DIFF: https://github.com/llvm/llvm-project/commit/94e7c0b051c79fd56205f115771980f2e7812306.diff
LOG: [libc++] Remove get_temporary_buffer and return_temporary_buffer (#100914)
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.
Added:
libcxx/include/__memory/unique_temporary_buffer.h
Modified:
libcxx/docs/ReleaseNotes/20.rst
libcxx/docs/Status/Cxx20Papers.csv
libcxx/docs/UserDocumentation.rst
libcxx/include/CMakeLists.txt
libcxx/include/__algorithm/inplace_merge.h
libcxx/include/__algorithm/stable_partition.h
libcxx/include/__algorithm/stable_sort.h
libcxx/include/__memory/temporary_buffer.h
libcxx/include/memory
libcxx/include/module.modulemap
libcxx/include/syncstream
libcxx/test/libcxx/diagnostics/memory.nodiscard.verify.cpp
libcxx/test/std/algorithms/alg.modifying.operations/alg.partitions/stable_partition.pass.cpp
libcxx/test/std/utilities/memory/temporary.buffer/overaligned.pass.cpp
libcxx/test/std/utilities/memory/temporary.buffer/temporary_buffer.pass.cpp
libcxx/utils/libcxx/test/modules.py
llvm/utils/gn/secondary/libcxx/include/BUILD.gn
Removed:
################################################################################
diff --git a/libcxx/docs/ReleaseNotes/20.rst b/libcxx/docs/ReleaseNotes/20.rst
index f3aa92b1ab97af..1a41eb8fa58098 100644
--- a/libcxx/docs/ReleaseNotes/20.rst
+++ b/libcxx/docs/ReleaseNotes/20.rst
@@ -49,6 +49,9 @@ Improvements and New Features
- The ``lexicographical_compare`` and ``ranges::lexicographical_compare`` algorithms have been optimized for trivially
equality comparable types, resulting in a performance improvement of up to 40x.
+- The ``_LIBCPP_ENABLE_CXX20_REMOVED_TEMPORARY_BUFFER`` macro has been added to make ``std::get_temporary_buffer`` and
+ ``std::return_temporary_buffer`` available.
+
- The ``_LIBCPP_ENABLE_CXX20_REMOVED_UNCAUGHT_EXCEPTION`` macro has been added to make ``std::uncaught_exception``
available in C++20 and later modes.
diff --git a/libcxx/docs/Status/Cxx20Papers.csv b/libcxx/docs/Status/Cxx20Papers.csv
index d449c9d39c3b32..4a4d75b21fd408 100644
--- a/libcxx/docs/Status/Cxx20Papers.csv
+++ b/libcxx/docs/Status/Cxx20Papers.csv
@@ -34,7 +34,7 @@
"`P0528R3 <https://wg21.link/P0528R3>`__","The Curious Case of Padding Bits, Featuring Atomic Compare-and-Exchange","2018-06 (Rapperswil)","","",""
"`P0542R5 <https://wg21.link/P0542R5>`__","Support for contract based programming in C++","2018-06 (Rapperswil)","|Nothing To Do|","n/a","Pulled at the 2019-07 meeting in Cologne"
"`P0556R3 <https://wg21.link/P0556R3>`__","Integral power-of-2 operations","2018-06 (Rapperswil)","|Complete|","9.0",""
-"`P0619R4 <https://wg21.link/P0619R4>`__","Reviewing Deprecated Facilities of C++17 for C++20","2018-06 (Rapperswil)","|Partial|","","Only sections D.7, D.8, D.9, D.10, D.11 and D.13 are implemented. Sections D.4 and D.12 remain undone."
+"`P0619R4 <https://wg21.link/P0619R4>`__","Reviewing Deprecated Facilities of C++17 for C++20","2018-06 (Rapperswil)","|Partial|","","Only sections D.7, D.8, D.9, D.10, D.11, D.12, and D.13 are implemented. Section D.4 remains undone."
"`P0646R1 <https://wg21.link/P0646R1>`__","Improving the Return Value of Erase-Like Algorithms","2018-06 (Rapperswil)","|Complete|","10.0",""
"`P0722R3 <https://wg21.link/P0722R3>`__","Efficient sized delete for variable sized classes","2018-06 (Rapperswil)","|Complete|","9.0",""
"`P0758R1 <https://wg21.link/P0758R1>`__","Implicit conversion traits and utility functions","2018-06 (Rapperswil)","|Complete|","",""
diff --git a/libcxx/docs/UserDocumentation.rst b/libcxx/docs/UserDocumentation.rst
index 3651e52ed77a75..6659fa54f49df5 100644
--- a/libcxx/docs/UserDocumentation.rst
+++ b/libcxx/docs/UserDocumentation.rst
@@ -181,6 +181,9 @@ C++20 Specific Configuration Macros
**_LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR**:
This macro is used to re-enable `raw_storage_iterator`.
+**_LIBCPP_ENABLE_CXX20_REMOVED_TEMPORARY_BUFFER**:
+ This macro is used to re-enable `get_temporary_buffer` and `return_temporary_buffer`.
+
**_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS**:
This macro is used to re-enable `is_literal_type`, `is_literal_type_v`,
`result_of` and `result_of_t`.
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 23d9aa0adddce8..8c61009167ddce 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -556,6 +556,7 @@ set(files
__memory/temporary_buffer.h
__memory/uninitialized_algorithms.h
__memory/unique_ptr.h
+ __memory/unique_temporary_buffer.h
__memory/uses_allocator.h
__memory/uses_allocator_construction.h
__memory/voidify.h
diff --git a/libcxx/include/__algorithm/inplace_merge.h b/libcxx/include/__algorithm/inplace_merge.h
index a6bcc66a2fa47a..2133f440d2fea6 100644
--- a/libcxx/include/__algorithm/inplace_merge.h
+++ b/libcxx/include/__algorithm/inplace_merge.h
@@ -24,8 +24,8 @@
#include <__iterator/iterator_traits.h>
#include <__iterator/reverse_iterator.h>
#include <__memory/destruct_n.h>
-#include <__memory/temporary_buffer.h>
#include <__memory/unique_ptr.h>
+#include <__memory/unique_temporary_buffer.h>
#include <__utility/pair.h>
#include <new>
@@ -208,16 +208,19 @@ _LIBCPP_HIDE_FROM_ABI void __inplace_merge(
_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, _Compare&& __comp) {
typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
typedef typename iterator_traits<_BidirectionalIterator>::
diff erence_type
diff erence_type;
-
diff erence_type __len1 = _IterOps<_AlgPolicy>::distance(__first, __middle);
-
diff erence_type __len2 = _IterOps<_AlgPolicy>::distance(__middle, __last);
-
diff erence_type __buf_size = std::min(__len1, __len2);
- // TODO: Remove the use of std::get_temporary_buffer
- _LIBCPP_SUPPRESS_DEPRECATED_PUSH
- pair<value_type*, ptr
diff _t> __buf = std::get_temporary_buffer<value_type>(__buf_size);
- _LIBCPP_SUPPRESS_DEPRECATED_POP
- unique_ptr<value_type, __return_temporary_buffer> __h(__buf.first);
+
diff erence_type __len1 = _IterOps<_AlgPolicy>::distance(__first, __middle);
+
diff erence_type __len2 = _IterOps<_AlgPolicy>::distance(__middle, __last);
+
diff erence_type __buf_size = std::min(__len1, __len2);
+ __unique_temporary_buffer<value_type> __unique_buf = std::__allocate_unique_temporary_buffer<value_type>(__buf_size);
return std::__inplace_merge<_AlgPolicy>(
- std::move(__first), std::move(__middle), std::move(__last), __comp, __len1, __len2, __buf.first, __buf.second);
+ std::move(__first),
+ std::move(__middle),
+ std::move(__last),
+ __comp,
+ __len1,
+ __len2,
+ __unique_buf.get(),
+ __unique_buf.get_deleter().__count_);
}
template <class _BidirectionalIterator, class _Compare>
diff --git a/libcxx/include/__algorithm/stable_partition.h b/libcxx/include/__algorithm/stable_partition.h
index 8bb1eaf2d22495..bf86201dbb6a61 100644
--- a/libcxx/include/__algorithm/stable_partition.h
+++ b/libcxx/include/__algorithm/stable_partition.h
@@ -16,8 +16,8 @@
#include <__iterator/distance.h>
#include <__iterator/iterator_traits.h>
#include <__memory/destruct_n.h>
-#include <__memory/temporary_buffer.h>
#include <__memory/unique_ptr.h>
+#include <__memory/unique_temporary_buffer.h>
#include <__utility/move.h>
#include <__utility/pair.h>
#include <new>
@@ -132,14 +132,12 @@ __stable_partition_impl(_ForwardIterator __first, _ForwardIterator __last, _Pred
// We now have a reduced range [__first, __last)
// *__first is known to be false
diff erence_type __len = _IterOps<_AlgPolicy>::distance(__first, __last);
+ __unique_temporary_buffer<value_type> __unique_buf;
pair<value_type*, ptr
diff _t> __p(0, 0);
- unique_ptr<value_type, __return_temporary_buffer> __h;
if (__len >= __alloc_limit) {
- // TODO: Remove the use of std::get_temporary_buffer
- _LIBCPP_SUPPRESS_DEPRECATED_PUSH
- __p = std::get_temporary_buffer<value_type>(__len);
- _LIBCPP_SUPPRESS_DEPRECATED_POP
- __h.reset(__p.first);
+ __unique_buf = std::__allocate_unique_temporary_buffer<value_type>(__len);
+ __p.first = __unique_buf.get();
+ __p.second = __unique_buf.get_deleter().__count_;
}
return std::__stable_partition_impl<_AlgPolicy, _Predicate&>(
std::move(__first), std::move(__last), __pred, __len, __p, forward_iterator_tag());
@@ -272,14 +270,12 @@ _LIBCPP_HIDE_FROM_ABI _BidirectionalIterator __stable_partition_impl(
// *__last is known to be true
// __len >= 2
diff erence_type __len = _IterOps<_AlgPolicy>::distance(__first, __last) + 1;
+ __unique_temporary_buffer<value_type> __unique_buf;
pair<value_type*, ptr
diff _t> __p(0, 0);
- unique_ptr<value_type, __return_temporary_buffer> __h;
if (__len >= __alloc_limit) {
- // TODO: Remove the use of std::get_temporary_buffer
- _LIBCPP_SUPPRESS_DEPRECATED_PUSH
- __p = std::get_temporary_buffer<value_type>(__len);
- _LIBCPP_SUPPRESS_DEPRECATED_POP
- __h.reset(__p.first);
+ __unique_buf = std::__allocate_unique_temporary_buffer<value_type>(__len);
+ __p.first = __unique_buf.get();
+ __p.second = __unique_buf.get_deleter().__count_;
}
return std::__stable_partition_impl<_AlgPolicy, _Predicate&>(
std::move(__first), std::move(__last), __pred, __len, __p, bidirectional_iterator_tag());
diff --git a/libcxx/include/__algorithm/stable_sort.h b/libcxx/include/__algorithm/stable_sort.h
index 726e7e16b3564a..ec556aad82e8d8 100644
--- a/libcxx/include/__algorithm/stable_sort.h
+++ b/libcxx/include/__algorithm/stable_sort.h
@@ -18,8 +18,8 @@
#include <__debug_utils/strict_weak_ordering_check.h>
#include <__iterator/iterator_traits.h>
#include <__memory/destruct_n.h>
-#include <__memory/temporary_buffer.h>
#include <__memory/unique_ptr.h>
+#include <__memory/unique_temporary_buffer.h>
#include <__type_traits/is_trivially_assignable.h>
#include <__utility/move.h>
#include <__utility/pair.h>
@@ -241,14 +241,12 @@ __stable_sort_impl(_RandomAccessIterator __first, _RandomAccessIterator __last,
using
diff erence_type = typename iterator_traits<_RandomAccessIterator>::
diff erence_type;
diff erence_type __len = __last - __first;
+ __unique_temporary_buffer<value_type> __unique_buf;
pair<value_type*, ptr
diff _t> __buf(0, 0);
- unique_ptr<value_type, __return_temporary_buffer> __h;
if (__len > static_cast<
diff erence_type>(__stable_sort_switch<value_type>::value)) {
- // TODO: Remove the use of std::get_temporary_buffer
- _LIBCPP_SUPPRESS_DEPRECATED_PUSH
- __buf = std::get_temporary_buffer<value_type>(__len);
- _LIBCPP_SUPPRESS_DEPRECATED_POP
- __h.reset(__buf.first);
+ __unique_buf = std::__allocate_unique_temporary_buffer<value_type>(__len);
+ __buf.first = __unique_buf.get();
+ __buf.second = __unique_buf.get_deleter().__count_;
}
std::__stable_sort<_AlgPolicy, __comp_ref_type<_Compare> >(__first, __last, __comp, __len, __buf.first, __buf.second);
diff --git a/libcxx/include/__memory/temporary_buffer.h b/libcxx/include/__memory/temporary_buffer.h
index 633c9dcf65c5df..219e03f99bc01d 100644
--- a/libcxx/include/__memory/temporary_buffer.h
+++ b/libcxx/include/__memory/temporary_buffer.h
@@ -11,6 +11,7 @@
#define _LIBCPP___MEMORY_TEMPORARY_BUFFER_H
#include <__config>
+#include <__memory/unique_temporary_buffer.h>
#include <__utility/pair.h>
#include <cstddef>
#include <new>
@@ -19,57 +20,27 @@
# pragma GCC system_header
#endif
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TEMPORARY_BUFFER)
+
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp>
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI _LIBCPP_DEPRECATED_IN_CXX17 pair<_Tp*, ptr
diff _t>
get_temporary_buffer(ptr
diff _t __n) _NOEXCEPT {
- pair<_Tp*, ptr
diff _t> __r(0, 0);
- const ptr
diff _t __m =
- (~ptr
diff _t(0) ^ ptr
diff _t(ptr
diff _t(1) << (sizeof(ptr
diff _t) * __CHAR_BIT__ - 1))) / sizeof(_Tp);
- if (__n > __m)
- __n = __m;
- while (__n > 0) {
-#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION)
- if (__is_overaligned_for_new(_LIBCPP_ALIGNOF(_Tp))) {
- align_val_t __al = align_val_t(_LIBCPP_ALIGNOF(_Tp));
- __r.first = static_cast<_Tp*>(::operator new(__n * sizeof(_Tp), __al, nothrow));
- } else {
- __r.first = static_cast<_Tp*>(::operator new(__n * sizeof(_Tp), nothrow));
- }
-#else
- if (__is_overaligned_for_new(_LIBCPP_ALIGNOF(_Tp))) {
- // Since aligned operator new is unavailable, return an empty
- // buffer rather than one with invalid alignment.
- return __r;
- }
-
- __r.first = static_cast<_Tp*>(::operator new(__n * sizeof(_Tp), nothrow));
-#endif
-
- if (__r.first) {
- __r.second = __n;
- break;
- }
- __n /= 2;
- }
- return __r;
+ __unique_temporary_buffer<_Tp> __unique_buf = std::__allocate_unique_temporary_buffer<_Tp>(__n);
+ pair<_Tp*, ptr
diff _t> __result(__unique_buf.get(), __unique_buf.get_deleter().__count_);
+ __unique_buf.release();
+ return __result;
}
template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_IN_CXX17 void return_temporary_buffer(_Tp* __p) _NOEXCEPT {
- std::__libcpp_deallocate_unsized((void*)__p, _LIBCPP_ALIGNOF(_Tp));
+ __unique_temporary_buffer<_Tp> __unique_buf(__p);
+ (void)__unique_buf;
}
-struct __return_temporary_buffer {
- _LIBCPP_SUPPRESS_DEPRECATED_PUSH
- template <class _Tp>
- _LIBCPP_HIDE_FROM_ABI void operator()(_Tp* __p) const {
- std::return_temporary_buffer(__p);
- }
- _LIBCPP_SUPPRESS_DEPRECATED_POP
-};
-
_LIBCPP_END_NAMESPACE_STD
+#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TEMPORARY_BUFFER)
+
#endif // _LIBCPP___MEMORY_TEMPORARY_BUFFER_H
diff --git a/libcxx/include/__memory/unique_temporary_buffer.h b/libcxx/include/__memory/unique_temporary_buffer.h
new file mode 100644
index 00000000000000..b9e2a47332682f
--- /dev/null
+++ b/libcxx/include/__memory/unique_temporary_buffer.h
@@ -0,0 +1,92 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___MEMORY_UNIQUE_TEMPORARY_BUFFER_H
+#define _LIBCPP___MEMORY_UNIQUE_TEMPORARY_BUFFER_H
+
+#include <__assert>
+#include <__config>
+
+#include <__memory/allocator.h>
+#include <__memory/unique_ptr.h>
+#include <__type_traits/is_constant_evaluated.h>
+#include <cstddef>
+#include <new>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp>
+struct __temporary_buffer_deleter {
+ ptr
diff _t __count_; // ignored in non-constant evaluation
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __temporary_buffer_deleter() _NOEXCEPT : __count_(0) {}
+ _LIBCPP_HIDE_FROM_ABI
+ _LIBCPP_CONSTEXPR explicit __temporary_buffer_deleter(ptr
diff _t __count) _NOEXCEPT : __count_(__count) {}
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator()(_Tp* __ptr) _NOEXCEPT {
+ if (__libcpp_is_constant_evaluated()) {
+ allocator<_Tp>().deallocate(__ptr, __count_);
+ return;
+ }
+
+ std::__libcpp_deallocate_unsized((void*)__ptr, _LIBCPP_ALIGNOF(_Tp));
+ }
+};
+
+template <class _Tp>
+using __unique_temporary_buffer = unique_ptr<_Tp, __temporary_buffer_deleter<_Tp> >;
+
+template <class _Tp>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __unique_temporary_buffer<_Tp>
+__allocate_unique_temporary_buffer(ptr
diff _t __count) {
+ using __deleter_type = __temporary_buffer_deleter<_Tp>;
+ using __unique_buffer_type = __unique_temporary_buffer<_Tp>;
+
+ if (__libcpp_is_constant_evaluated()) {
+ return __unique_buffer_type(allocator<_Tp>().allocate(__count), __deleter_type(__count));
+ }
+
+ _Tp* __ptr = nullptr;
+ const ptr
diff _t __max_count =
+ (~ptr
diff _t(0) ^ ptr
diff _t(ptr
diff _t(1) << (sizeof(ptr
diff _t) * __CHAR_BIT__ - 1))) / sizeof(_Tp);
+ if (__count > __max_count)
+ __count = __max_count;
+ while (__count > 0) {
+#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION)
+ if (__is_overaligned_for_new(_LIBCPP_ALIGNOF(_Tp))) {
+ align_val_t __al = align_val_t(_LIBCPP_ALIGNOF(_Tp));
+ __ptr = static_cast<_Tp*>(::operator new(__count * sizeof(_Tp), __al, nothrow));
+ } else {
+ __ptr = static_cast<_Tp*>(::operator new(__count * sizeof(_Tp), nothrow));
+ }
+#else
+ if (__is_overaligned_for_new(_LIBCPP_ALIGNOF(_Tp))) {
+ // Since aligned operator new is unavailable, constructs an empty buffer rather than one with invalid alignment.
+ return __unique_buffer_type();
+ }
+
+ __ptr = static_cast<_Tp*>(::operator new(__count * sizeof(_Tp), nothrow));
+#endif
+
+ if (__ptr) {
+ break;
+ }
+ __count /= 2;
+ }
+
+ return __unique_buffer_type(__ptr, __deleter_type(__count));
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___MEMORY_UNIQUE_TEMPORARY_BUFFER_H
diff --git a/libcxx/include/memory b/libcxx/include/memory
index b940a32c3ebe6c..db3386cca48009 100644
--- a/libcxx/include/memory
+++ b/libcxx/include/memory
@@ -182,8 +182,8 @@ public:
raw_storage_iterator operator++(int);
};
-template <class T> pair<T*,ptr
diff _t> get_temporary_buffer(ptr
diff _t n) noexcept;
-template <class T> void return_temporary_buffer(T* p) noexcept;
+template <class T> pair<T*,ptr
diff _t> get_temporary_buffer(ptr
diff _t n) noexcept; // deprecated in C++17, removed in C++20
+template <class T> void return_temporary_buffer(T* p) noexcept; // deprecated in C++17, removed in C++20
template <class T> T* addressof(T& r) noexcept;
template <class T> T* addressof(const T&& r) noexcept = delete;
diff --git a/libcxx/include/module.modulemap b/libcxx/include/module.modulemap
index cc419122ed2a64..c1181a3622513f 100644
--- a/libcxx/include/module.modulemap
+++ b/libcxx/include/module.modulemap
@@ -1542,6 +1542,11 @@ module std_private_memory_unique_ptr [system] {
export std_private_type_traits_is_pointer
export std_private_type_traits_type_identity
}
+module std_private_memory_unique_temporary_buffer [system] {
+ header "__memory/unique_temporary_buffer.h"
+ export std_private_memory_unique_ptr
+ export std_private_type_traits_is_constant_evaluated
+}
module std_private_memory_uses_allocator [system] { header "__memory/uses_allocator.h" }
module std_private_memory_uses_allocator_construction [system] { header "__memory/uses_allocator_construction.h" }
module std_private_memory_voidify [system] { header "__memory/voidify.h" }
diff --git a/libcxx/include/syncstream b/libcxx/include/syncstream
index fe9aa07fcdaa8c..a2e1c7edadc5de 100644
--- a/libcxx/include/syncstream
+++ b/libcxx/include/syncstream
@@ -364,7 +364,7 @@ private:
// TODO Use a more generic buffer.
// That buffer should be light with almost no additional headers. Then
// it can be use here, the __retarget_buffer, and place that use
- // the now deprecated get_temporary_buffer
+ // the now removed get_temporary_buffer
basic_string<_CharT, _Traits, _Allocator> __str_;
bool __emit_on_sync_{false};
diff --git a/libcxx/test/libcxx/diagnostics/memory.nodiscard.verify.cpp b/libcxx/test/libcxx/diagnostics/memory.nodiscard.verify.cpp
index 646569e3d573ab..6410c84e926aad 100644
--- a/libcxx/test/libcxx/diagnostics/memory.nodiscard.verify.cpp
+++ b/libcxx/test/libcxx/diagnostics/memory.nodiscard.verify.cpp
@@ -10,6 +10,7 @@
// check that <memory> functions are marked [[nodiscard]]
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX20_REMOVED_TEMPORARY_BUFFER
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
// clang-format off
diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.partitions/stable_partition.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.partitions/stable_partition.pass.cpp
index 85d12d08c96750..44027543aaf16e 100644
--- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.partitions/stable_partition.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.partitions/stable_partition.pass.cpp
@@ -282,9 +282,9 @@ test()
assert(array[9] == P(0, 2));
}
#if TEST_STD_VER >= 11 && !defined(TEST_HAS_NO_EXCEPTIONS)
- // TODO: Re-enable this test once we're no longer using get_temporary_buffer().
+ // TODO: Re-enable this test once we get recursive inlining fixed.
// For now it trips up GCC due to the use of always_inline.
-#if 0
+# if 0
{ // check that the algorithm still works when no memory is available
std::vector<int> vec(150, 3);
vec[5] = 6;
@@ -300,7 +300,7 @@ test()
assert(std::is_partitioned(vec.begin(), vec.end(), [](int i) { return i < 5; }));
getGlobalMemCounter()->reset();
}
-#endif
+# endif
#endif // TEST_STD_VER >= 11 && !defined(TEST_HAS_NO_EXCEPTIONS)
}
diff --git a/libcxx/test/std/utilities/memory/temporary.buffer/overaligned.pass.cpp b/libcxx/test/std/utilities/memory/temporary.buffer/overaligned.pass.cpp
index 8499478d1fb384..4c66370fac9221 100644
--- a/libcxx/test/std/utilities/memory/temporary.buffer/overaligned.pass.cpp
+++ b/libcxx/test/std/utilities/memory/temporary.buffer/overaligned.pass.cpp
@@ -8,6 +8,7 @@
// UNSUPPORTED: c++03
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX20_REMOVED_TEMPORARY_BUFFER
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
// <memory>
diff --git a/libcxx/test/std/utilities/memory/temporary.buffer/temporary_buffer.pass.cpp b/libcxx/test/std/utilities/memory/temporary.buffer/temporary_buffer.pass.cpp
index 6c0fbf2568fff6..5f7fc4571906cc 100644
--- a/libcxx/test/std/utilities/memory/temporary.buffer/temporary_buffer.pass.cpp
+++ b/libcxx/test/std/utilities/memory/temporary.buffer/temporary_buffer.pass.cpp
@@ -8,6 +8,7 @@
// <memory>
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX20_REMOVED_TEMPORARY_BUFFER
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
// template <class T>
diff --git a/libcxx/utils/libcxx/test/modules.py b/libcxx/utils/libcxx/test/modules.py
index 91933d4f425bd8..4824ca3cb2707a 100644
--- a/libcxx/utils/libcxx/test/modules.py
+++ b/libcxx/utils/libcxx/test/modules.py
@@ -52,13 +52,6 @@
"std::operator==",
]
-# TODO MODULES remove zombie names
-# https://libcxx.llvm.org/Status/Cxx20.html#note-p0619
-SkipDeclarations["memory"] = [
- "std::return_temporary_buffer",
- "std::get_temporary_buffer",
-]
-
# include/__type_traits/is_swappable.h
SkipDeclarations["type_traits"] = [
"std::swap",
diff --git a/llvm/utils/gn/secondary/libcxx/include/BUILD.gn b/llvm/utils/gn/secondary/libcxx/include/BUILD.gn
index a6d12040074cbd..91d547da201f2b 100644
--- a/llvm/utils/gn/secondary/libcxx/include/BUILD.gn
+++ b/llvm/utils/gn/secondary/libcxx/include/BUILD.gn
@@ -628,6 +628,7 @@ if (current_toolchain == default_toolchain) {
"__memory/temporary_buffer.h",
"__memory/uninitialized_algorithms.h",
"__memory/unique_ptr.h",
+ "__memory/unique_temporary_buffer.h",
"__memory/uses_allocator.h",
"__memory/uses_allocator_construction.h",
"__memory/voidify.h",
More information about the libcxx-commits
mailing list