git: f7bcd8d8c933 - main - libcxx-compat: revert llvmorg-21-init-17684-gae9990ed9651:
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 25 Apr 2026 14:20:02 UTC
The branch main has been updated by dim:
URL: https://cgit.FreeBSD.org/src/commit/?id=f7bcd8d8c9336b97569265e5ad36b73b30357beb
commit f7bcd8d8c9336b97569265e5ad36b73b30357beb
Author: Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2026-01-02 20:25:42 +0000
Commit: Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2026-04-25 14:14:11 +0000
libcxx-compat: revert llvmorg-21-init-17684-gae9990ed9651:
[libc++] Remove dead code from <type_traits> (#143854)
Since we've upgraded to GCC 15 now, we can remove a bunch of dead code
from `<type_traits>`.
This is part of making libc++ 21 build with GCC 14.
PR: 292067
MFC after: 1 month
---
.../libcxx/include/__type_traits/add_pointer.h | 14 +-----
.../libcxx/include/__type_traits/add_reference.h | 55 ++++++++++++++++------
.../libcxx/include/__type_traits/decay.h | 44 ++++++++++++++---
.../has_unique_object_representation.h | 8 +++-
.../libcxx/include/__type_traits/is_array.h | 24 +++++++++-
.../libcxx/include/__type_traits/is_const.h | 20 +++++++-
.../libcxx/include/__type_traits/is_pointer.h | 33 +++++++++++++
.../libcxx/include/__type_traits/is_volatile.h | 20 +++++++-
.../include/__type_traits/remove_all_extents.h | 21 +++++++--
.../libcxx/include/__type_traits/remove_extent.h | 21 +++++++--
10 files changed, 213 insertions(+), 47 deletions(-)
diff --git a/contrib/llvm-project/libcxx/include/__type_traits/add_pointer.h b/contrib/llvm-project/libcxx/include/__type_traits/add_pointer.h
index f595000520ec..f37f9cf5a93c 100644
--- a/contrib/llvm-project/libcxx/include/__type_traits/add_pointer.h
+++ b/contrib/llvm-project/libcxx/include/__type_traits/add_pointer.h
@@ -22,18 +22,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if !defined(_LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS) && __has_builtin(__add_pointer) && !defined(_LIBCPP_COMPILER_GCC)
-template <class _Tp>
-struct _LIBCPP_NO_SPECIALIZATIONS add_pointer {
- using type _LIBCPP_NODEBUG = __add_pointer(_Tp);
-};
-
-# ifdef _LIBCPP_COMPILER_GCC
-template <class _Tp>
-using __add_pointer_t _LIBCPP_NODEBUG = typename add_pointer<_Tp>::type;
-# else
template <class _Tp>
using __add_pointer_t _LIBCPP_NODEBUG = __add_pointer(_Tp);
-# endif
#else
template <class _Tp, bool = __is_referenceable_v<_Tp> || is_void<_Tp>::value>
@@ -48,13 +38,13 @@ struct __add_pointer_impl<_Tp, false> {
template <class _Tp>
using __add_pointer_t = typename __add_pointer_impl<_Tp>::type;
+#endif // !defined(_LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS) && __has_builtin(__add_pointer)
+
template <class _Tp>
struct _LIBCPP_NO_SPECIALIZATIONS add_pointer {
using type _LIBCPP_NODEBUG = __add_pointer_t<_Tp>;
};
-#endif // !defined(_LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS)
-
#if _LIBCPP_STD_VER >= 14
template <class _Tp>
using add_pointer_t = __add_pointer_t<_Tp>;
diff --git a/contrib/llvm-project/libcxx/include/__type_traits/add_reference.h b/contrib/llvm-project/libcxx/include/__type_traits/add_reference.h
index c6f5d63d26de..98f26f457daf 100644
--- a/contrib/llvm-project/libcxx/include/__type_traits/add_reference.h
+++ b/contrib/llvm-project/libcxx/include/__type_traits/add_reference.h
@@ -10,6 +10,7 @@
#define _LIBCPP___TYPE_TRAITS_ADD_REFERENCE_H
#include <__config>
+#include <__type_traits/is_referenceable.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -17,36 +18,62 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+#if __has_builtin(__add_lvalue_reference) && !defined(_LIBCPP_COMPILER_GCC)
+
template <class _Tp>
-struct _LIBCPP_NO_SPECIALIZATIONS add_lvalue_reference {
- using type _LIBCPP_NODEBUG = __add_lvalue_reference(_Tp);
+using __add_lvalue_reference_t _LIBCPP_NODEBUG = __add_lvalue_reference(_Tp);
+
+#else
+
+template <class _Tp, bool = __is_referenceable_v<_Tp>>
+struct __add_lvalue_reference_impl {
+ using type _LIBCPP_NODEBUG = _Tp;
+};
+template <class _Tp >
+struct __add_lvalue_reference_impl<_Tp, true> {
+ using type _LIBCPP_NODEBUG = _Tp&;
};
-#ifdef _LIBCPP_COMPILER_GCC
template <class _Tp>
-using __add_lvalue_reference_t _LIBCPP_NODEBUG = typename add_lvalue_reference<_Tp>::type;
-#else
+using __add_lvalue_reference_t = typename __add_lvalue_reference_impl<_Tp>::type;
+
+#endif // __has_builtin(__add_lvalue_reference)
+
template <class _Tp>
-using __add_lvalue_reference_t _LIBCPP_NODEBUG = __add_lvalue_reference(_Tp);
-#endif
+struct _LIBCPP_NO_SPECIALIZATIONS add_lvalue_reference {
+ using type _LIBCPP_NODEBUG = __add_lvalue_reference_t<_Tp>;
+};
#if _LIBCPP_STD_VER >= 14
template <class _Tp>
using add_lvalue_reference_t = __add_lvalue_reference_t<_Tp>;
#endif
+#if __has_builtin(__add_rvalue_reference) && !defined(_LIBCPP_COMPILER_GCC)
+
template <class _Tp>
-struct _LIBCPP_NO_SPECIALIZATIONS add_rvalue_reference {
- using type _LIBCPP_NODEBUG = __add_rvalue_reference(_Tp);
+using __add_rvalue_reference_t _LIBCPP_NODEBUG = __add_rvalue_reference(_Tp);
+
+#else
+
+template <class _Tp, bool = __is_referenceable_v<_Tp> >
+struct __add_rvalue_reference_impl {
+ using type _LIBCPP_NODEBUG = _Tp;
+};
+template <class _Tp >
+struct __add_rvalue_reference_impl<_Tp, true> {
+ using type _LIBCPP_NODEBUG = _Tp&&;
};
-#ifdef _LIBCPP_COMPILER_GCC
template <class _Tp>
-using __add_rvalue_reference_t _LIBCPP_NODEBUG = typename add_rvalue_reference<_Tp>::type;
-#else
+using __add_rvalue_reference_t = typename __add_rvalue_reference_impl<_Tp>::type;
+
+#endif // __has_builtin(__add_rvalue_reference)
+
template <class _Tp>
-using __add_rvalue_reference_t _LIBCPP_NODEBUG = __add_rvalue_reference(_Tp);
-#endif
+struct _LIBCPP_NO_SPECIALIZATIONS add_rvalue_reference {
+ using type _LIBCPP_NODEBUG = __add_rvalue_reference_t<_Tp>;
+};
#if _LIBCPP_STD_VER >= 14
template <class _Tp>
diff --git a/contrib/llvm-project/libcxx/include/__type_traits/decay.h b/contrib/llvm-project/libcxx/include/__type_traits/decay.h
index 661fba53dfaa..1e663fdcd0ed 100644
--- a/contrib/llvm-project/libcxx/include/__type_traits/decay.h
+++ b/contrib/llvm-project/libcxx/include/__type_traits/decay.h
@@ -10,6 +10,14 @@
#define _LIBCPP___TYPE_TRAITS_DECAY_H
#include <__config>
+#include <__type_traits/add_pointer.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/is_array.h>
+#include <__type_traits/is_function.h>
+#include <__type_traits/is_referenceable.h>
+#include <__type_traits/remove_cv.h>
+#include <__type_traits/remove_extent.h>
+#include <__type_traits/remove_reference.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -17,18 +25,42 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+#if __has_builtin(__decay) && !defined(_LIBCPP_COMPILER_GCC)
+template <class _Tp>
+using __decay_t _LIBCPP_NODEBUG = __decay(_Tp);
+
template <class _Tp>
struct _LIBCPP_NO_SPECIALIZATIONS decay {
- using type _LIBCPP_NODEBUG = __decay(_Tp);
+ using type _LIBCPP_NODEBUG = __decay_t<_Tp>;
};
-#ifdef _LIBCPP_COMPILER_GCC
-template <class _Tp>
-using __decay_t _LIBCPP_NODEBUG = typename decay<_Tp>::type;
#else
+template <class _Up, bool>
+struct __decay {
+ using type _LIBCPP_NODEBUG = __remove_cv_t<_Up>;
+};
+
+template <class _Up>
+struct __decay<_Up, true> {
+public:
+ using type _LIBCPP_NODEBUG =
+ __conditional_t<is_array<_Up>::value,
+ __add_pointer_t<__remove_extent_t<_Up> >,
+ __conditional_t<is_function<_Up>::value, typename add_pointer<_Up>::type, __remove_cv_t<_Up> > >;
+};
+
template <class _Tp>
-using __decay_t _LIBCPP_NODEBUG = __decay(_Tp);
-#endif
+struct decay {
+private:
+ using _Up _LIBCPP_NODEBUG = __libcpp_remove_reference_t<_Tp>;
+
+public:
+ using type _LIBCPP_NODEBUG = typename __decay<_Up, __is_referenceable_v<_Up> >::type;
+};
+
+template <class _Tp>
+using __decay_t = typename decay<_Tp>::type;
+#endif // __has_builtin(__decay)
#if _LIBCPP_STD_VER >= 14
template <class _Tp>
diff --git a/contrib/llvm-project/libcxx/include/__type_traits/has_unique_object_representation.h b/contrib/llvm-project/libcxx/include/__type_traits/has_unique_object_representation.h
index af9abfe81d41..ba81be6aa19b 100644
--- a/contrib/llvm-project/libcxx/include/__type_traits/has_unique_object_representation.h
+++ b/contrib/llvm-project/libcxx/include/__type_traits/has_unique_object_representation.h
@@ -11,6 +11,7 @@
#include <__config>
#include <__type_traits/integral_constant.h>
+#include <__type_traits/remove_all_extents.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -22,7 +23,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp>
struct _LIBCPP_NO_SPECIALIZATIONS has_unique_object_representations
- : integral_constant<bool, __has_unique_object_representations(_Tp)> {};
+ // TODO: We work around a Clang and GCC bug in __has_unique_object_representations by using remove_all_extents
+ // even though it should not be necessary. This was reported to the compilers:
+ // - Clang: https://github.com/llvm/llvm-project/issues/95311
+ // - GCC: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115476
+ // remove_all_extents_t can be removed once all the compilers we support have fixed this bug.
+ : public integral_constant<bool, __has_unique_object_representations(remove_all_extents_t<_Tp>)> {};
template <class _Tp>
_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool has_unique_object_representations_v =
diff --git a/contrib/llvm-project/libcxx/include/__type_traits/is_array.h b/contrib/llvm-project/libcxx/include/__type_traits/is_array.h
index e734d1a3043e..1d94370378c6 100644
--- a/contrib/llvm-project/libcxx/include/__type_traits/is_array.h
+++ b/contrib/llvm-project/libcxx/include/__type_traits/is_array.h
@@ -10,6 +10,7 @@
#define _LIBCPP___TYPE_TRAITS_IS_ARRAY_H
#include <__config>
+#include <__cstddef/size_t.h>
#include <__type_traits/integral_constant.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -18,13 +19,32 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+#if __has_builtin(__is_array) && \
+ (!defined(_LIBCPP_COMPILER_CLANG_BASED) || (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 1900))
+
template <class _Tp>
struct _LIBCPP_NO_SPECIALIZATIONS is_array : _BoolConstant<__is_array(_Tp)> {};
-#if _LIBCPP_STD_VER >= 17
+# if _LIBCPP_STD_VER >= 17
template <class _Tp>
_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_array_v = __is_array(_Tp);
-#endif
+# endif
+
+#else
+
+template <class _Tp>
+struct is_array : public false_type {};
+template <class _Tp>
+struct is_array<_Tp[]> : public true_type {};
+template <class _Tp, size_t _Np>
+struct is_array<_Tp[_Np]> : public true_type {};
+
+# if _LIBCPP_STD_VER >= 17
+template <class _Tp>
+inline constexpr bool is_array_v = is_array<_Tp>::value;
+# endif
+
+#endif // __has_builtin(__is_array)
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/llvm-project/libcxx/include/__type_traits/is_const.h b/contrib/llvm-project/libcxx/include/__type_traits/is_const.h
index 85cc32bff1ea..4ec354d7f9bf 100644
--- a/contrib/llvm-project/libcxx/include/__type_traits/is_const.h
+++ b/contrib/llvm-project/libcxx/include/__type_traits/is_const.h
@@ -18,13 +18,29 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+#if __has_builtin(__is_const)
+
template <class _Tp>
struct _LIBCPP_NO_SPECIALIZATIONS is_const : _BoolConstant<__is_const(_Tp)> {};
-#if _LIBCPP_STD_VER >= 17
+# if _LIBCPP_STD_VER >= 17
template <class _Tp>
_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_const_v = __is_const(_Tp);
-#endif
+# endif
+
+#else
+
+template <class _Tp>
+struct is_const : public false_type {};
+template <class _Tp>
+struct is_const<_Tp const> : public true_type {};
+
+# if _LIBCPP_STD_VER >= 17
+template <class _Tp>
+inline constexpr bool is_const_v = is_const<_Tp>::value;
+# endif
+
+#endif // __has_builtin(__is_const)
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/llvm-project/libcxx/include/__type_traits/is_pointer.h b/contrib/llvm-project/libcxx/include/__type_traits/is_pointer.h
index 1c3a93d1256c..3c58656e0e61 100644
--- a/contrib/llvm-project/libcxx/include/__type_traits/is_pointer.h
+++ b/contrib/llvm-project/libcxx/include/__type_traits/is_pointer.h
@@ -11,6 +11,7 @@
#include <__config>
#include <__type_traits/integral_constant.h>
+#include <__type_traits/remove_cv.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -18,6 +19,8 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+#if __has_builtin(__is_pointer)
+
template <class _Tp>
struct _LIBCPP_NO_SPECIALIZATIONS is_pointer : _BoolConstant<__is_pointer(_Tp)> {};
@@ -26,6 +29,36 @@ template <class _Tp>
_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_pointer_v = __is_pointer(_Tp);
# endif
+#else // __has_builtin(__is_pointer)
+
+template <class _Tp>
+struct __libcpp_is_pointer : false_type {};
+template <class _Tp>
+struct __libcpp_is_pointer<_Tp*> : true_type {};
+
+template <class _Tp>
+struct __libcpp_remove_objc_qualifiers {
+ typedef _Tp type;
+};
+# if __has_feature(objc_arc)
+// clang-format off
+template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __strong> { typedef _Tp type; };
+template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __weak> { typedef _Tp type; };
+template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __autoreleasing> { typedef _Tp type; };
+template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __unsafe_unretained> { typedef _Tp type; };
+// clang-format on
+# endif
+
+template <class _Tp>
+struct is_pointer : __libcpp_is_pointer<typename __libcpp_remove_objc_qualifiers<__remove_cv_t<_Tp> >::type> {};
+
+# if _LIBCPP_STD_VER >= 17
+template <class _Tp>
+inline constexpr bool is_pointer_v = is_pointer<_Tp>::value;
+# endif
+
+#endif // __has_builtin(__is_pointer)
+
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___TYPE_TRAITS_IS_POINTER_H
diff --git a/contrib/llvm-project/libcxx/include/__type_traits/is_volatile.h b/contrib/llvm-project/libcxx/include/__type_traits/is_volatile.h
index c654ebba9299..22e9c297c800 100644
--- a/contrib/llvm-project/libcxx/include/__type_traits/is_volatile.h
+++ b/contrib/llvm-project/libcxx/include/__type_traits/is_volatile.h
@@ -18,13 +18,29 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+#if __has_builtin(__is_volatile)
+
template <class _Tp>
struct _LIBCPP_NO_SPECIALIZATIONS is_volatile : _BoolConstant<__is_volatile(_Tp)> {};
-#if _LIBCPP_STD_VER >= 17
+# if _LIBCPP_STD_VER >= 17
template <class _Tp>
_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_volatile_v = __is_volatile(_Tp);
-#endif
+# endif
+
+#else
+
+template <class _Tp>
+struct is_volatile : public false_type {};
+template <class _Tp>
+struct is_volatile<_Tp volatile> : public true_type {};
+
+# if _LIBCPP_STD_VER >= 17
+template <class _Tp>
+inline constexpr bool is_volatile_v = is_volatile<_Tp>::value;
+# endif
+
+#endif // __has_builtin(__is_volatile)
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/llvm-project/libcxx/include/__type_traits/remove_all_extents.h b/contrib/llvm-project/libcxx/include/__type_traits/remove_all_extents.h
index 2663628ee634..2c7aea2bfd18 100644
--- a/contrib/llvm-project/libcxx/include/__type_traits/remove_all_extents.h
+++ b/contrib/llvm-project/libcxx/include/__type_traits/remove_all_extents.h
@@ -10,6 +10,7 @@
#define _LIBCPP___TYPE_TRAITS_REMOVE_ALL_EXTENTS_H
#include <__config>
+#include <__cstddef/size_t.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -23,13 +24,25 @@ struct _LIBCPP_NO_SPECIALIZATIONS remove_all_extents {
using type _LIBCPP_NODEBUG = __remove_all_extents(_Tp);
};
-#ifdef _LIBCPP_COMPILER_GCC
template <class _Tp>
-using __remove_all_extents_t _LIBCPP_NODEBUG = typename remove_all_extents<_Tp>::type;
+using __remove_all_extents_t _LIBCPP_NODEBUG = __remove_all_extents(_Tp);
#else
template <class _Tp>
-using __remove_all_extents_t _LIBCPP_NODEBUG = __remove_all_extents(_Tp);
-#endif
+struct remove_all_extents {
+ typedef _Tp type;
+};
+template <class _Tp>
+struct remove_all_extents<_Tp[]> {
+ typedef typename remove_all_extents<_Tp>::type type;
+};
+template <class _Tp, size_t _Np>
+struct remove_all_extents<_Tp[_Np]> {
+ typedef typename remove_all_extents<_Tp>::type type;
+};
+
+template <class _Tp>
+using __remove_all_extents_t = typename remove_all_extents<_Tp>::type;
+#endif // __has_builtin(__remove_all_extents)
#if _LIBCPP_STD_VER >= 14
template <class _Tp>
diff --git a/contrib/llvm-project/libcxx/include/__type_traits/remove_extent.h b/contrib/llvm-project/libcxx/include/__type_traits/remove_extent.h
index 4c43c4d85165..7745af14bdb1 100644
--- a/contrib/llvm-project/libcxx/include/__type_traits/remove_extent.h
+++ b/contrib/llvm-project/libcxx/include/__type_traits/remove_extent.h
@@ -10,6 +10,7 @@
#define _LIBCPP___TYPE_TRAITS_REMOVE_EXTENT_H
#include <__config>
+#include <__cstddef/size_t.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -23,13 +24,25 @@ struct _LIBCPP_NO_SPECIALIZATIONS remove_extent {
using type _LIBCPP_NODEBUG = __remove_extent(_Tp);
};
-#ifdef _LIBCPP_COMPILER_GCC
template <class _Tp>
-using __remove_extent_t _LIBCPP_NODEBUG = typename remove_extent<_Tp>::type;
+using __remove_extent_t _LIBCPP_NODEBUG = __remove_extent(_Tp);
#else
template <class _Tp>
-using __remove_extent_t _LIBCPP_NODEBUG = __remove_extent(_Tp);
-#endif
+struct remove_extent {
+ typedef _Tp type;
+};
+template <class _Tp>
+struct remove_extent<_Tp[]> {
+ typedef _Tp type;
+};
+template <class _Tp, size_t _Np>
+struct remove_extent<_Tp[_Np]> {
+ typedef _Tp type;
+};
+
+template <class _Tp>
+using __remove_extent_t = typename remove_extent<_Tp>::type;
+#endif // __has_builtin(__remove_extent)
#if _LIBCPP_STD_VER >= 14
template <class _Tp>