[llvm-branch-commits] [libcxx] 8d802f7 - [libc++] Keep unary_function and binary_function in C++17 for one more release

Louis Dionne via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sat Sep 24 07:22:00 PDT 2022


Author: Louis Dionne
Date: 2022-09-23T16:16:36-04:00
New Revision: 8d802f78fa8c91707ecea1ae4ab141ba835429bc

URL: https://github.com/llvm/llvm-project/commit/8d802f78fa8c91707ecea1ae4ab141ba835429bc
DIFF: https://github.com/llvm/llvm-project/commit/8d802f78fa8c91707ecea1ae4ab141ba835429bc.diff

LOG: [libc++] Keep unary_function and binary_function in C++17 for one more release

In LLVM 15, we added the deprecation markup for unary_function and
binary_function for >= C++11, and we also removed it for >= C++17.
While this is in accordance with the Standard, it's also a bit quick
for our users, since there was no release in which the classes were
marked as deprecated before their removal.

We noticed widespread breakage due to this, and after months of trying
to fix downstream failures, I am coming to the conclusion that users
will be better served if we give them one release where unary_function
is deprecated but still provided even in >= C++17.

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

Added: 
    

Modified: 
    libcxx/docs/ReleaseNotes.rst
    libcxx/include/__config
    libcxx/test/libcxx/depr/depr.func.adaptor.typedefs/typedefs.depr_in_cxx17.verify.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/docs/ReleaseNotes.rst b/libcxx/docs/ReleaseNotes.rst
index bbc6063e5fbfa..0409866f999aa 100644
--- a/libcxx/docs/ReleaseNotes.rst
+++ b/libcxx/docs/ReleaseNotes.rst
@@ -141,11 +141,11 @@ Deprecations and Removals
   or upgrade to C++11 or later. It is possible to re-enable ``std::function`` in C++03 by defining
   ``_LIBCPP_ENABLE_CXX03_FUNCTION``. This option will be removed in LLVM 16.
 
-- ``unary_function`` and ``binary_function`` are no longer available in C++17 and C++20.
-  They can be re-enabled by defining ``_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION``.
-  They are also marked as ``[[deprecated]]`` in C++11 and later. To disable deprecation warnings
-  you have to define ``_LIBCPP_DISABLE_DEPRECATION_WARNINGS``. Note that this disables
-  all deprecation warnings.
+- ``unary_function`` and ``binary_function`` are now marked as ``[[deprecated]]`` in C++11 and later.
+  Deprecation warnings can be disabled by defining ``_LIBCPP_DISABLE_DEPRECATION_WARNINGS``, however
+  this disables all deprecation warnings, not only those for ``unary_function`` and ``binary_function``.
+  Also note that starting in LLVM 16, ``unary_function`` and ``binary_function`` will be removed entirely
+  (not only deprecated) in C++17 and above, as mandated by the Standard.
 
 - The contents of ``<codecvt>``, ``wstring_convert`` and ``wbuffer_convert`` have been marked as deprecated.
   To disable deprecation warnings you have to define ``_LIBCPP_DISABLE_DEPRECATION_WARNINGS``. Note that this

diff  --git a/libcxx/include/__config b/libcxx/include/__config
index 2f80df35f909a..c3a402c1c54fa 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -1101,6 +1101,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
 #    define _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
 #  endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
 
+// Leave the deprecation notices in by default, but don't remove unary_function and
+// binary_function entirely just yet. That way, folks will have one release to act
+// on the deprecation warnings.
+#  ifndef _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
+#    define _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
+#  endif
+
 #  if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES)
 #    define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
 #    define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_VOID_SPECIALIZATION

diff  --git a/libcxx/test/libcxx/depr/depr.func.adaptor.typedefs/typedefs.depr_in_cxx17.verify.cpp b/libcxx/test/libcxx/depr/depr.func.adaptor.typedefs/typedefs.depr_in_cxx17.verify.cpp
index 422f405042208..65a0d2b9bfabd 100644
--- a/libcxx/test/libcxx/depr/depr.func.adaptor.typedefs/typedefs.depr_in_cxx17.verify.cpp
+++ b/libcxx/test/libcxx/depr/depr.func.adaptor.typedefs/typedefs.depr_in_cxx17.verify.cpp
@@ -19,6 +19,12 @@
 #include <utility>
 #include "test_macros.h"
 
+// This test is disabled in LLVM 15 because we enable the removed
+// unary_function and binary_function classes by default, which means
+// that we also don't produce deprecation warnings for using their members.
+
+// expected-no-diagnostics
+#if 0
 void test_functional()
 {
     {
@@ -123,3 +129,4 @@ void test_map()
         (void)c;
     }
 }
+#endif


        


More information about the llvm-branch-commits mailing list