Skip to content

[libc++] Work around new GCC 15 type_traits builtins that can't be used as Clang's can #137871

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 13, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions libcxx/include/__type_traits/add_lvalue_reference.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,18 @@ _LIBCPP_BEGIN_NAMESPACE_STD

#if __has_builtin(__add_lvalue_reference)

# if defined(_LIBCPP_COMPILER_GCC)
template <class _Tp>
struct __add_lvalue_reference_gcc {
using type = __add_lvalue_reference(_Tp);
};

template <class _Tp>
using __add_lvalue_reference_t _LIBCPP_NODEBUG = typename __add_lvalue_reference_gcc<_Tp>::type;
# else
template <class _Tp>
using __add_lvalue_reference_t _LIBCPP_NODEBUG = __add_lvalue_reference(_Tp);
# endif // defined(_LIBCPP_COMPILER_GCC)

#else

Expand Down
10 changes: 10 additions & 0 deletions libcxx/include/__type_traits/add_pointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,18 @@ _LIBCPP_BEGIN_NAMESPACE_STD

#if !defined(_LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS) && __has_builtin(__add_pointer)

# if defined(_LIBCPP_COMPILER_GCC)
template <class _Tp>
struct __add_pointer_gcc {
using type = __add_pointer(_Tp);
};

template <class _Tp>
using __add_pointer_t _LIBCPP_NODEBUG = typename __add_pointer_gcc<_Tp>::type;
# else
template <class _Tp>
using __add_pointer_t _LIBCPP_NODEBUG = __add_pointer(_Tp);
# endif // defined(_LIBCPP_COMPILER_GCC)

#else
template <class _Tp, bool = __is_referenceable_v<_Tp> || is_void<_Tp>::value>
Expand Down
10 changes: 10 additions & 0 deletions libcxx/include/__type_traits/add_rvalue_reference.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,18 @@ _LIBCPP_BEGIN_NAMESPACE_STD

#if __has_builtin(__add_rvalue_reference)

# if defined(_LIBCPP_COMPILER_GCC)
template <class _Tp>
struct __add_rvalue_reference_gcc {
using type = __add_rvalue_reference(_Tp);
};

template <class _Tp>
using __add_rvalue_reference_t _LIBCPP_NODEBUG = typename __add_rvalue_reference_gcc<_Tp>::type;
# else
template <class _Tp>
using __add_rvalue_reference_t _LIBCPP_NODEBUG = __add_rvalue_reference(_Tp);
# endif // defined(_LIBCPP_COMPILER_GCC)

#else

Expand Down
10 changes: 10 additions & 0 deletions libcxx/include/__type_traits/decay.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,18 @@
_LIBCPP_BEGIN_NAMESPACE_STD

#if __has_builtin(__decay)
# if defined(_LIBCPP_COMPILER_GCC)
template <class _Tp>
struct __decay_gcc {
using type = __decay(_Tp);
};

template <class _Tp>
using __decay_t _LIBCPP_NODEBUG = typename __decay_gcc<_Tp>::type;
# else
template <class _Tp>
using __decay_t _LIBCPP_NODEBUG = __decay(_Tp);
# endif // defined(_LIBCPP_COMPILER_GCC)

template <class _Tp>
struct _LIBCPP_NO_SPECIALIZATIONS decay {
Expand Down
6 changes: 6 additions & 0 deletions libcxx/include/__type_traits/remove_all_extents.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ struct _LIBCPP_NO_SPECIALIZATIONS remove_all_extents {
using type _LIBCPP_NODEBUG = __remove_all_extents(_Tp);
};

# if defined(_LIBCPP_COMPILER_GCC)
template <class _Tp>
using __remove_all_extents_t = typename remove_all_extents<_Tp>::type;
# else
template <class _Tp>
using __remove_all_extents_t _LIBCPP_NODEBUG = __remove_all_extents(_Tp);
# endif // defined(_LIBCPP_COMPILER_GCC)

#else
template <class _Tp>
struct remove_all_extents {
Expand Down
6 changes: 6 additions & 0 deletions libcxx/include/__type_traits/remove_extent.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ struct _LIBCPP_NO_SPECIALIZATIONS remove_extent {
using type _LIBCPP_NODEBUG = __remove_extent(_Tp);
};

# if defined(_LIBCPP_COMPILER_GCC)
template <class _Tp>
using __remove_extent_t = typename remove_extent<_Tp>::type;
# else
template <class _Tp>
using __remove_extent_t _LIBCPP_NODEBUG = __remove_extent(_Tp);
# endif // defined(_LIBCPP_COMPILER_GCC)

#else
template <class _Tp>
struct remove_extent {
Expand Down
Loading