Skip to content

Commit 6ad26e5

Browse files
committed
[libc++] Revert "Use GCC type traits builtins for remove_cv and remove_cvref (llvm#81386)"
This reverts commit 5535716. This is only being reverted from the LLVM 19 branch as a convenience to avoid breaking some IDEs which were not ready for that change. Fixes llvm#99464
1 parent 7f1cd78 commit 6ad26e5

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

libcxx/include/__type_traits/remove_cv.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,32 @@
1010
#define _LIBCPP___TYPE_TRAITS_REMOVE_CV_H
1111

1212
#include <__config>
13+
#include <__type_traits/remove_const.h>
14+
#include <__type_traits/remove_volatile.h>
1315

1416
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1517
# pragma GCC system_header
1618
#endif
1719

1820
_LIBCPP_BEGIN_NAMESPACE_STD
1921

22+
#if __has_builtin(__remove_cv) && !defined(_LIBCPP_COMPILER_GCC)
2023
template <class _Tp>
2124
struct remove_cv {
2225
using type _LIBCPP_NODEBUG = __remove_cv(_Tp);
2326
};
2427

25-
#if defined(_LIBCPP_COMPILER_GCC)
2628
template <class _Tp>
27-
using __remove_cv_t = typename remove_cv<_Tp>::type;
29+
using __remove_cv_t = __remove_cv(_Tp);
2830
#else
2931
template <class _Tp>
30-
using __remove_cv_t = __remove_cv(_Tp);
31-
#endif
32+
struct _LIBCPP_TEMPLATE_VIS remove_cv {
33+
typedef __remove_volatile_t<__remove_const_t<_Tp> > type;
34+
};
35+
36+
template <class _Tp>
37+
using __remove_cv_t = __remove_volatile_t<__remove_const_t<_Tp> >;
38+
#endif // __has_builtin(__remove_cv)
3239

3340
#if _LIBCPP_STD_VER >= 14
3441
template <class _Tp>

libcxx/include/__type_traits/remove_cvref.h

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,21 @@
2020

2121
_LIBCPP_BEGIN_NAMESPACE_STD
2222

23-
#if defined(_LIBCPP_COMPILER_GCC)
23+
#if __has_builtin(__remove_cvref) && !defined(_LIBCPP_COMPILER_GCC)
2424
template <class _Tp>
25-
struct __remove_cvref_gcc {
26-
using type = __remove_cvref(_Tp);
27-
};
28-
29-
template <class _Tp>
30-
using __remove_cvref_t _LIBCPP_NODEBUG = typename __remove_cvref_gcc<_Tp>::type;
25+
using __remove_cvref_t _LIBCPP_NODEBUG = __remove_cvref(_Tp);
3126
#else
3227
template <class _Tp>
33-
using __remove_cvref_t _LIBCPP_NODEBUG = __remove_cvref(_Tp);
28+
using __remove_cvref_t _LIBCPP_NODEBUG = __remove_cv_t<__libcpp_remove_reference_t<_Tp> >;
3429
#endif // __has_builtin(__remove_cvref)
3530

3631
template <class _Tp, class _Up>
37-
using __is_same_uncvref = _IsSame<__remove_cvref_t<_Tp>, __remove_cvref_t<_Up> >;
32+
struct __is_same_uncvref : _IsSame<__remove_cvref_t<_Tp>, __remove_cvref_t<_Up> > {};
3833

3934
#if _LIBCPP_STD_VER >= 20
4035
template <class _Tp>
4136
struct remove_cvref {
42-
using type _LIBCPP_NODEBUG = __remove_cvref(_Tp);
37+
using type _LIBCPP_NODEBUG = __remove_cvref_t<_Tp>;
4338
};
4439

4540
template <class _Tp>

0 commit comments

Comments
 (0)