[libcxx-commits] [libcxx] 2fcf99d - [libc++] Implement P0174R2 (Deprecating Vestigial Library Parts in C++17)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jun 20 23:22:45 PDT 2022


Author: Nikolas Klauser
Date: 2022-06-21T08:22:44+02:00
New Revision: 2fcf99d703464882fec88324be7b08f78e004a3f

URL: https://github.com/llvm/llvm-project/commit/2fcf99d703464882fec88324be7b08f78e004a3f
DIFF: https://github.com/llvm/llvm-project/commit/2fcf99d703464882fec88324be7b08f78e004a3f.diff

LOG: [libc++] Implement P0174R2 (Deprecating Vestigial Library Parts in C++17)

Reviewed By: ldionne, Mordante, #libc

Spies: jwakely, libcxx-commits

Differential Revision: https://reviews.llvm.org/D127387

Added: 
    libcxx/test/std/utilities/memory/temporary.buffer/depr.verify.cpp

Modified: 
    libcxx/docs/ReleaseNotes.rst
    libcxx/docs/Status/Cxx17Papers.csv
    libcxx/include/__algorithm/inplace_merge.h
    libcxx/include/__algorithm/stable_partition.h
    libcxx/include/__algorithm/stable_sort.h
    libcxx/include/__memory/allocator.h
    libcxx/include/__memory/temporary_buffer.h
    libcxx/test/libcxx/diagnostics/nodiscard_extensions.pass.cpp
    libcxx/test/libcxx/diagnostics/nodiscard_extensions.verify.cpp
    libcxx/test/std/utilities/memory/temporary.buffer/overaligned.pass.cpp
    libcxx/test/std/utilities/memory/temporary.buffer/temporary_buffer.pass.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/docs/ReleaseNotes.rst b/libcxx/docs/ReleaseNotes.rst
index 15d6d96afdafa..2ae3e97ada6b2 100644
--- a/libcxx/docs/ReleaseNotes.rst
+++ b/libcxx/docs/ReleaseNotes.rst
@@ -44,6 +44,8 @@ Implemented Papers
 - P0980R1 (Making ``std::string`` constexpr)
 - P2216R3 (std::format improvements)
 
+- Implemented P0174R2 (Deprecating Vestigial Library Parts in C++17)
+
 - Marked the following papers as "Complete" (note that some of those might have
   been implemented in a previous release but not marked as such):
 

diff  --git a/libcxx/docs/Status/Cxx17Papers.csv b/libcxx/docs/Status/Cxx17Papers.csv
index cd3646fae17be..72291fdb6a223 100644
--- a/libcxx/docs/Status/Cxx17Papers.csv
+++ b/libcxx/docs/Status/Cxx17Papers.csv
@@ -50,7 +50,7 @@
 "`p0088r3 <https://wg21.link/p0088r3>`__","LWG","Variant: a type-safe union for C++17","Oulu","|Complete|","4.0"
 "`p0137r1 <https://wg21.link/p0137r1>`__","CWG","Core Issue 1776: Replacement of class objects containing reference members","Oulu","|Complete|","6.0"
 "`p0163r0 <https://wg21.link/p0163r0>`__","LWG","shared_ptr::weak_type","Oulu","|Complete|","3.9"
-"`p0174r2 <https://wg21.link/p0174r2>`__","LWG","Deprecating Vestigial Library Parts in C++17","Oulu","|Partial|",""
+"`p0174r2 <https://wg21.link/p0174r2>`__","LWG","Deprecating Vestigial Library Parts in C++17","Oulu","|Complete|","15.0"
 "`p0175r1 <https://wg21.link/p0175r1>`__","LWG","Synopses for the C library","Oulu","",""
 "`p0180r2 <https://wg21.link/p0180r2>`__","LWG","Reserve a New Library Namespace for Future Standardization","Oulu","|Nothing To Do|","n/a"
 "`p0181r1 <https://wg21.link/p0181r1>`__","LWG","Ordered by Default","Oulu","*Removed in Kona*","n/a"

diff  --git a/libcxx/include/__algorithm/inplace_merge.h b/libcxx/include/__algorithm/inplace_merge.h
index ffc160cbe44b9..58919ddbae766 100644
--- a/libcxx/include/__algorithm/inplace_merge.h
+++ b/libcxx/include/__algorithm/inplace_merge.h
@@ -211,7 +211,10 @@ inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _
     
diff erence_type __len1 = _VSTD::distance(__first, __middle);
     
diff erence_type __len2 = _VSTD::distance(__middle, __last);
     
diff erence_type __buf_size = _VSTD::min(__len1, __len2);
+// TODO: Remove the use of std::get_temporary_buffer
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
     pair<value_type*, ptr
diff _t> __buf = _VSTD::get_temporary_buffer<value_type>(__buf_size);
+_LIBCPP_SUPPRESS_DEPRECATED_POP
     unique_ptr<value_type, __return_temporary_buffer> __h(__buf.first);
     typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
     return _VSTD::__inplace_merge<_Comp_ref>(__first, __middle, __last, __comp, __len1, __len2,

diff  --git a/libcxx/include/__algorithm/stable_partition.h b/libcxx/include/__algorithm/stable_partition.h
index a0f13606912ca..969ac7a6173e6 100644
--- a/libcxx/include/__algorithm/stable_partition.h
+++ b/libcxx/include/__algorithm/stable_partition.h
@@ -132,7 +132,10 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate
     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 = _VSTD::get_temporary_buffer<value_type>(__len);
+_LIBCPP_SUPPRESS_DEPRECATED_POP
         __h.reset(__p.first);
     }
     return _VSTD::__stable_partition<_Predicate&>(__first, __last, __pred, __len, __p, forward_iterator_tag());
@@ -278,7 +281,10 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last
     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 = _VSTD::get_temporary_buffer<value_type>(__len);
+_LIBCPP_SUPPRESS_DEPRECATED_POP
         __h.reset(__p.first);
     }
     return _VSTD::__stable_partition<_Predicate&>(__first, __last, __pred, __len, __p, bidirectional_iterator_tag());

diff  --git a/libcxx/include/__algorithm/stable_sort.h b/libcxx/include/__algorithm/stable_sort.h
index 33df6e8ba75f3..22b0a64db654a 100644
--- a/libcxx/include/__algorithm/stable_sort.h
+++ b/libcxx/include/__algorithm/stable_sort.h
@@ -210,7 +210,10 @@ stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compar
     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 = _VSTD::get_temporary_buffer<value_type>(__len);
+_LIBCPP_SUPPRESS_DEPRECATED_POP
         __h.reset(__buf.first);
     }
     typedef typename __comp_ref_type<_Compare>::type _Comp_ref;

diff  --git a/libcxx/include/__memory/allocator.h b/libcxx/include/__memory/allocator.h
index 118b95469f3eb..57ce23483df3a 100644
--- a/libcxx/include/__memory/allocator.h
+++ b/libcxx/include/__memory/allocator.h
@@ -28,6 +28,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 template <class _Tp> class allocator;
 
 #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_VOID_SPECIALIZATION)
+// These specializations shouldn't be marked _LIBCPP_DEPRECATED_IN_CXX17.
+// Specializing allocator<void> is deprecated, but not using it.
 template <>
 class _LIBCPP_TEMPLATE_VIS allocator<void>
 {

diff  --git a/libcxx/include/__memory/temporary_buffer.h b/libcxx/include/__memory/temporary_buffer.h
index 2c6e333eba081..9822bd30c826e 100644
--- a/libcxx/include/__memory/temporary_buffer.h
+++ b/libcxx/include/__memory/temporary_buffer.h
@@ -22,7 +22,7 @@
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 template <class _Tp>
-_LIBCPP_NODISCARD_EXT _LIBCPP_NO_CFI
+_LIBCPP_NODISCARD_EXT _LIBCPP_NO_CFI _LIBCPP_DEPRECATED_IN_CXX17
 pair<_Tp*, ptr
diff _t>
 get_temporary_buffer(ptr
diff _t __n) _NOEXCEPT
 {
@@ -67,7 +67,7 @@ get_temporary_buffer(ptr
diff _t __n) _NOEXCEPT
 }
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_IN_CXX17
 void return_temporary_buffer(_Tp* __p) _NOEXCEPT
 {
   _VSTD::__libcpp_deallocate_unsized((void*)__p, _LIBCPP_ALIGNOF(_Tp));
@@ -75,8 +75,10 @@ void return_temporary_buffer(_Tp* __p) _NOEXCEPT
 
 struct __return_temporary_buffer
 {
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
     template <class _Tp>
     _LIBCPP_INLINE_VISIBILITY void operator()(_Tp* __p) const {_VSTD::return_temporary_buffer(__p);}
+_LIBCPP_SUPPRESS_DEPRECATED_POP
 };
 
 _LIBCPP_END_NAMESPACE_STD

diff  --git a/libcxx/test/libcxx/diagnostics/nodiscard_extensions.pass.cpp b/libcxx/test/libcxx/diagnostics/nodiscard_extensions.pass.cpp
index ea8c989a99840..b602a88a137a4 100644
--- a/libcxx/test/libcxx/diagnostics/nodiscard_extensions.pass.cpp
+++ b/libcxx/test/libcxx/diagnostics/nodiscard_extensions.pass.cpp
@@ -20,6 +20,8 @@
 // trigger -Wunused-value warnings.
 // ADDITIONAL_COMPILE_FLAGS: -fno-builtin
 
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
+
 #include <algorithm>
 #include <bit> // bit_cast
 #include <cstddef> // to_integer

diff  --git a/libcxx/test/libcxx/diagnostics/nodiscard_extensions.verify.cpp b/libcxx/test/libcxx/diagnostics/nodiscard_extensions.verify.cpp
index 54b396a5519b7..a3464e74b2872 100644
--- a/libcxx/test/libcxx/diagnostics/nodiscard_extensions.verify.cpp
+++ b/libcxx/test/libcxx/diagnostics/nodiscard_extensions.verify.cpp
@@ -16,6 +16,7 @@
 // be listed in `UsingLibcxx.rst` in the documentation for the extension.
 
 // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_NODISCARD
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
 
 #include <algorithm>
 #include <bit> // bit_cast

diff  --git a/libcxx/test/std/utilities/memory/temporary.buffer/depr.verify.cpp b/libcxx/test/std/utilities/memory/temporary.buffer/depr.verify.cpp
new file mode 100644
index 0000000000000..040c22378c3ab
--- /dev/null
+++ b/libcxx/test/std/utilities/memory/temporary.buffer/depr.verify.cpp
@@ -0,0 +1,18 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: c++17
+
+// Ensure allocator<void> is deprecated
+
+#include <memory>
+
+void test() {
+  auto a = std::get_temporary_buffer<int>(1); // expected-warning {{'get_temporary_buffer<int>' is deprecated}}
+  std::return_temporary_buffer(a.first); // expected-warning {{'return_temporary_buffer<int>' is deprecated}}
+}

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 a4911a5a445e3..08aab53a83157 100644
--- a/libcxx/test/std/utilities/memory/temporary.buffer/overaligned.pass.cpp
+++ b/libcxx/test/std/utilities/memory/temporary.buffer/overaligned.pass.cpp
@@ -13,6 +13,7 @@
 // we won't pass prior to c++17.
 // UNSUPPORTED: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11|12}}
 
+// 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 af798186f2499..7a0f89412ce67 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,8 @@
 
 // <memory>
 
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
+
 // template <class T>
 //   pair<T*, ptr
diff _t>
 //   get_temporary_buffer(ptr
diff _t n);


        


More information about the libcxx-commits mailing list