[libcxx-commits] [libcxx] 9feac2c - [libc++] Improve deprecated diagnostic guards.

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Tue Mar 18 10:31:23 PDT 2025


Author: Mark de Wever
Date: 2025-03-18T18:30:48+01:00
New Revision: 9feac2cbd0d80927ce9a8b4c3e810d2b81802d55

URL: https://github.com/llvm/llvm-project/commit/9feac2cbd0d80927ce9a8b4c3e810d2b81802d55
DIFF: https://github.com/llvm/llvm-project/commit/9feac2cbd0d80927ce9a8b4c3e810d2b81802d55.diff

LOG: [libc++] Improve deprecated diagnostic guards.

Recent Clang-21 builds improved the deprecated diagnotics. This
uncovered missing guards in libc++ internally.

Note: This patch should be a separate commit and not merged.
For testing purposes they are combined.

Reviewed as part of #130497.

Added: 
    

Modified: 
    libcxx/include/__functional/binary_function.h
    libcxx/include/__functional/unary_function.h
    libcxx/include/__functional/weak_result_type.h
    libcxx/include/__memory/allocator_traits.h
    libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/types.pass.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/include/__functional/binary_function.h b/libcxx/include/__functional/binary_function.h
index bde8b03ef8281..727fff08f1854 100644
--- a/libcxx/include/__functional/binary_function.h
+++ b/libcxx/include/__functional/binary_function.h
@@ -39,11 +39,10 @@ struct __binary_function_keep_layout_base {
 };
 
 #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
-_LIBCPP_DIAGNOSTIC_PUSH
-_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations")
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 template <class _Arg1, class _Arg2, class _Result>
 using __binary_function _LIBCPP_NODEBUG = binary_function<_Arg1, _Arg2, _Result>;
-_LIBCPP_DIAGNOSTIC_POP
+_LIBCPP_SUPPRESS_DEPRECATED_POP
 #else
 template <class _Arg1, class _Arg2, class _Result>
 using __binary_function _LIBCPP_NODEBUG = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>;

diff  --git a/libcxx/include/__functional/unary_function.h b/libcxx/include/__functional/unary_function.h
index 769ffc9893a72..33fcbe82e4f33 100644
--- a/libcxx/include/__functional/unary_function.h
+++ b/libcxx/include/__functional/unary_function.h
@@ -36,11 +36,10 @@ struct __unary_function_keep_layout_base {
 };
 
 #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
-_LIBCPP_DIAGNOSTIC_PUSH
-_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations")
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 template <class _Arg, class _Result>
 using __unary_function _LIBCPP_NODEBUG = unary_function<_Arg, _Result>;
-_LIBCPP_DIAGNOSTIC_POP
+_LIBCPP_SUPPRESS_DEPRECATED_POP
 #else
 template <class _Arg, class _Result>
 using __unary_function _LIBCPP_NODEBUG = __unary_function_keep_layout_base<_Arg, _Result>;

diff  --git a/libcxx/include/__functional/weak_result_type.h b/libcxx/include/__functional/weak_result_type.h
index 233d86009a201..aa462e4d5c56f 100644
--- a/libcxx/include/__functional/weak_result_type.h
+++ b/libcxx/include/__functional/weak_result_type.h
@@ -77,6 +77,7 @@ struct __maybe_derive_from_unary_function // bool is true
 template <class _Tp>
 struct __maybe_derive_from_unary_function<_Tp, false> {};
 
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 template <class _Tp, bool = __derives_from_binary_function<_Tp>::value>
 struct __maybe_derive_from_binary_function // bool is true
     : public __derives_from_binary_function<_Tp>::type {};
@@ -99,6 +100,7 @@ struct __weak_result_type_imp<_Tp, false>
 
 template <class _Tp>
 struct __weak_result_type : public __weak_result_type_imp<_Tp> {};
+_LIBCPP_SUPPRESS_DEPRECATED_POP
 
 // 0 argument case
 

diff  --git a/libcxx/include/__memory/allocator_traits.h b/libcxx/include/__memory/allocator_traits.h
index 57b591e5b4b31..3180f5e3d542f 100644
--- a/libcxx/include/__memory/allocator_traits.h
+++ b/libcxx/include/__memory/allocator_traits.h
@@ -42,6 +42,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
   template <class _Tp>                                                                                                 \
   struct NAME<_Tp, __void_t<typename _Tp::PROPERTY > > : true_type {}
 
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 // __pointer
 template <class _Tp>
 using __pointer_member _LIBCPP_NODEBUG = typename _Tp::pointer;
@@ -63,6 +64,7 @@ struct __const_pointer<_Tp, _Ptr, _Alloc, false> {
   using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<const _Tp>;
 #endif
 };
+_LIBCPP_SUPPRESS_DEPRECATED_POP
 
 // __void_pointer
 _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_void_pointer, void_pointer);

diff  --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/types.pass.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/types.pass.cpp
index 45a3d7aa910de..2b4bc8b00de4f 100644
--- a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/types.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/types.pass.cpp
@@ -8,6 +8,8 @@
 
 // UNSUPPORTED: c++03
 
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
+//
 // <functional>
 
 // template<Returnable R, CopyConstructible... ArgTypes>


        


More information about the libcxx-commits mailing list