[libcxx-commits] [libcxx] 2040fde - [libc++] Prefer __has_builtin for detecting compiler-provided type_traits
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jul 6 04:33:55 PDT 2022
Author: Nikolas Klauser
Date: 2022-07-06T13:33:50+02:00
New Revision: 2040fde9097ae7753531c9c58332a933cbaaa43c
URL: https://github.com/llvm/llvm-project/commit/2040fde9097ae7753531c9c58332a933cbaaa43c
DIFF: https://github.com/llvm/llvm-project/commit/2040fde9097ae7753531c9c58332a933cbaaa43c.diff
LOG: [libc++] Prefer __has_builtin for detecting compiler-provided type_traits
Both clang and GCC support using `__has_builtin` for detecting compiler-provided type_traits. Use it instead of `__has_keyword` or `__has_feature` to remove special-casing for GCC-provided builtins
Reviewed By: ldionne, #libc
Spies: libcxx-commits
Differential Revision: https://reviews.llvm.org/D129056
Added:
Modified:
libcxx/include/__type_traits/extent.h
libcxx/include/__type_traits/has_virtual_destructor.h
libcxx/include/__type_traits/is_array.h
libcxx/include/__type_traits/is_assignable.h
libcxx/include/__type_traits/is_compound.h
libcxx/include/__type_traits/is_const.h
libcxx/include/__type_traits/is_convertible.h
libcxx/include/__type_traits/is_destructible.h
libcxx/include/__type_traits/is_function.h
libcxx/include/__type_traits/is_fundamental.h
libcxx/include/__type_traits/is_integral.h
libcxx/include/__type_traits/is_member_function_pointer.h
libcxx/include/__type_traits/is_member_object_pointer.h
libcxx/include/__type_traits/is_member_pointer.h
libcxx/include/__type_traits/is_nothrow_assignable.h
libcxx/include/__type_traits/is_nothrow_constructible.h
libcxx/include/__type_traits/is_object.h
libcxx/include/__type_traits/is_pod.h
libcxx/include/__type_traits/is_pointer.h
libcxx/include/__type_traits/is_reference.h
libcxx/include/__type_traits/is_scalar.h
libcxx/include/__type_traits/is_signed.h
libcxx/include/__type_traits/is_standard_layout.h
libcxx/include/__type_traits/is_trivial.h
libcxx/include/__type_traits/is_trivially_destructible.h
libcxx/include/__type_traits/is_unsigned.h
libcxx/include/__type_traits/is_void.h
libcxx/include/__type_traits/is_volatile.h
Removed:
################################################################################
diff --git a/libcxx/include/__type_traits/extent.h b/libcxx/include/__type_traits/extent.h
index 935ec4937c0ae..0a4d84e05e23d 100644
--- a/libcxx/include/__type_traits/extent.h
+++ b/libcxx/include/__type_traits/extent.h
@@ -19,7 +19,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if __has_keyword(__array_extent)
+#if __has_builtin(__array_extent)
template<class _Tp, size_t _Dim = 0>
struct _LIBCPP_TEMPLATE_VIS extent
@@ -30,7 +30,7 @@ template <class _Tp, unsigned _Ip = 0>
inline constexpr size_t extent_v = __array_extent(_Tp, _Ip);
#endif
-#else // __has_keyword(__array_extent)
+#else // __has_builtin(__array_extent)
template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TEMPLATE_VIS extent
: public integral_constant<size_t, 0> {};
@@ -48,7 +48,7 @@ template <class _Tp, unsigned _Ip = 0>
inline constexpr size_t extent_v = extent<_Tp, _Ip>::value;
#endif
-#endif // __has_keyword(__array_extent)
+#endif // __has_builtin(__array_extent)
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/has_virtual_destructor.h b/libcxx/include/__type_traits/has_virtual_destructor.h
index 33574373632e8..1f0bd188b7174 100644
--- a/libcxx/include/__type_traits/has_virtual_destructor.h
+++ b/libcxx/include/__type_traits/has_virtual_destructor.h
@@ -18,7 +18,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if __has_feature(has_virtual_destructor) || defined(_LIBCPP_COMPILER_GCC)
+#if __has_builtin(__has_virtual_destructor)
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor
: public integral_constant<bool, __has_virtual_destructor(_Tp)> {};
diff --git a/libcxx/include/__type_traits/is_array.h b/libcxx/include/__type_traits/is_array.h
index 766d2a2030287..bc105908982c4 100644
--- a/libcxx/include/__type_traits/is_array.h
+++ b/libcxx/include/__type_traits/is_array.h
@@ -21,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
// TODO: Clang incorrectly reports that __is_array is true for T[0].
// Re-enable the branch once https://llvm.org/PR54705 is fixed.
-#if __has_keyword(__is_array) && 0
+#if __has_builtin(__is_array) && 0
template <class _Tp>
struct _LIBCPP_TEMPLATE_VIS is_array : _BoolConstant<__is_array(_Tp)> { };
@@ -45,7 +45,7 @@ template <class _Tp>
inline constexpr bool is_array_v = is_array<_Tp>::value;
#endif
-#endif // __has_keyword(__is_array)
+#endif // __has_builtin(__is_array)
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/is_assignable.h b/libcxx/include/__type_traits/is_assignable.h
index edc864cae0659..b8cb6df9df4a3 100644
--- a/libcxx/include/__type_traits/is_assignable.h
+++ b/libcxx/include/__type_traits/is_assignable.h
@@ -20,7 +20,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template<typename, typename _Tp> struct __select_2nd { typedef _LIBCPP_NODEBUG _Tp type; };
-#if __has_keyword(__is_assignable)
+#if __has_builtin(__is_assignable)
template<class _Tp, class _Up>
struct _LIBCPP_TEMPLATE_VIS is_assignable : _BoolConstant<__is_assignable(_Tp, _Up)> { };
@@ -30,7 +30,7 @@ template <class _Tp, class _Arg>
inline constexpr bool is_assignable_v = __is_assignable(_Tp, _Arg);
#endif
-#else // __has_keyword(__is_assignable)
+#else // __has_builtin(__is_assignable)
template <class _Tp, class _Arg>
typename __select_2nd<decltype((declval<_Tp>() = declval<_Arg>())), true_type>::type
@@ -59,7 +59,7 @@ template <class _Tp, class _Arg>
inline constexpr bool is_assignable_v = is_assignable<_Tp, _Arg>::value;
#endif
-#endif // __has_keyword(__is_assignable)
+#endif // __has_builtin(__is_assignable)
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/is_compound.h b/libcxx/include/__type_traits/is_compound.h
index 643edd78229a6..1395ed8d417fa 100644
--- a/libcxx/include/__type_traits/is_compound.h
+++ b/libcxx/include/__type_traits/is_compound.h
@@ -19,7 +19,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if __has_keyword(__is_compound)
+#if __has_builtin(__is_compound)
template<class _Tp>
struct _LIBCPP_TEMPLATE_VIS is_compound : _BoolConstant<__is_compound(_Tp)> { };
@@ -29,7 +29,7 @@ template <class _Tp>
inline constexpr bool is_compound_v = __is_compound(_Tp);
#endif
-#else // __has_keyword(__is_compound)
+#else // __has_builtin(__is_compound)
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_compound
: public integral_constant<bool, !is_fundamental<_Tp>::value> {};
@@ -39,7 +39,7 @@ template <class _Tp>
inline constexpr bool is_compound_v = is_compound<_Tp>::value;
#endif
-#endif // __has_keyword(__is_compound)
+#endif // __has_builtin(__is_compound)
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/is_const.h b/libcxx/include/__type_traits/is_const.h
index 5501832f560ba..42b892c58d509 100644
--- a/libcxx/include/__type_traits/is_const.h
+++ b/libcxx/include/__type_traits/is_const.h
@@ -18,7 +18,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if __has_keyword(__is_const)
+#if __has_builtin(__is_const)
template <class _Tp>
struct _LIBCPP_TEMPLATE_VIS is_const : _BoolConstant<__is_const(_Tp)> { };
@@ -38,7 +38,7 @@ template <class _Tp>
inline constexpr bool is_const_v = is_const<_Tp>::value;
#endif
-#endif // __has_keyword(__is_const)
+#endif // __has_builtin(__is_const)
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/is_convertible.h b/libcxx/include/__type_traits/is_convertible.h
index 884e808e2ae4d..b45b41caccdd8 100644
--- a/libcxx/include/__type_traits/is_convertible.h
+++ b/libcxx/include/__type_traits/is_convertible.h
@@ -24,12 +24,12 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if __has_feature(is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK)
+#if __has_builtin(__is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK)
template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible
: public integral_constant<bool, __is_convertible_to(_T1, _T2)> {};
-#else // __has_feature(is_convertible_to)
+#else // __has_builtin(__is_convertible_to)
namespace __is_convertible_imp
{
@@ -96,7 +96,7 @@ template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible
static const size_t __complete_check2 = __is_convertible_check<_T2>::__v;
};
-#endif // __has_feature(is_convertible_to)
+#endif // __has_builtin(__is_convertible_to)
#if _LIBCPP_STD_VER > 14
template <class _From, class _To>
diff --git a/libcxx/include/__type_traits/is_destructible.h b/libcxx/include/__type_traits/is_destructible.h
index 4894510078736..5e9ac5579fdd4 100644
--- a/libcxx/include/__type_traits/is_destructible.h
+++ b/libcxx/include/__type_traits/is_destructible.h
@@ -22,7 +22,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if __has_keyword(__is_destructible)
+#if __has_builtin(__is_destructible)
template<class _Tp>
struct _LIBCPP_TEMPLATE_VIS is_destructible : _BoolConstant<__is_destructible(_Tp)> { };
@@ -32,7 +32,7 @@ template <class _Tp>
inline constexpr bool is_destructible_v = __is_destructible(_Tp);
#endif
-#else // __has_keyword(__is_destructible)
+#else // __has_builtin(__is_destructible)
// if it's a reference, return true
// if it's a function, return false
@@ -95,7 +95,7 @@ template <class _Tp>
inline constexpr bool is_destructible_v = is_destructible<_Tp>::value;
#endif
-#endif // __has_keyword(__is_destructible)
+#endif // __has_builtin(__is_destructible)
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/is_function.h b/libcxx/include/__type_traits/is_function.h
index bce980c21b4e6..53f34b39eb9ab 100644
--- a/libcxx/include/__type_traits/is_function.h
+++ b/libcxx/include/__type_traits/is_function.h
@@ -20,7 +20,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if __has_keyword(__is_function)
+#if __has_builtin(__is_function)
template <class _Tp>
struct _LIBCPP_TEMPLATE_VIS is_function : integral_constant<bool, __is_function(_Tp)> {};
@@ -31,7 +31,7 @@ template <class _Tp>
struct _LIBCPP_TEMPLATE_VIS is_function
: public integral_constant<bool, !(is_reference<_Tp>::value || is_const<const _Tp>::value)> {};
-#endif // __has_keyword(__is_function)
+#endif // __has_builtin(__is_function)
#if _LIBCPP_STD_VER > 14
template <class _Tp>
diff --git a/libcxx/include/__type_traits/is_fundamental.h b/libcxx/include/__type_traits/is_fundamental.h
index aaa7063eef9b0..46f81a1035833 100644
--- a/libcxx/include/__type_traits/is_fundamental.h
+++ b/libcxx/include/__type_traits/is_fundamental.h
@@ -20,7 +20,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if __has_keyword(__is_fundamental)
+#if __has_builtin(__is_fundamental)
template<class _Tp>
struct _LIBCPP_TEMPLATE_VIS is_fundamental : _BoolConstant<__is_fundamental(_Tp)> { };
@@ -30,7 +30,7 @@ template <class _Tp>
inline constexpr bool is_fundamental_v = __is_fundamental(_Tp);
#endif
-#else // __has_keyword(__is_fundamental)
+#else // __has_builtin(__is_fundamental)
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_fundamental
: public integral_constant<bool, is_void<_Tp>::value ||
@@ -42,7 +42,7 @@ template <class _Tp>
inline constexpr bool is_fundamental_v = is_fundamental<_Tp>::value;
#endif
-#endif // __has_keyword(__is_fundamental)
+#endif // __has_builtin(__is_fundamental)
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/is_integral.h b/libcxx/include/__type_traits/is_integral.h
index 09378735d94e3..c1c573a75e0a0 100644
--- a/libcxx/include/__type_traits/is_integral.h
+++ b/libcxx/include/__type_traits/is_integral.h
@@ -45,7 +45,7 @@ template <> struct __libcpp_is_integral<__int128_t> { enum { va
template <> struct __libcpp_is_integral<__uint128_t> { enum { value = 1 }; };
#endif
-#if __has_keyword(__is_integral)
+#if __has_builtin(__is_integral)
template <class _Tp>
struct _LIBCPP_TEMPLATE_VIS is_integral : _BoolConstant<__is_integral(_Tp)> { };
@@ -65,7 +65,7 @@ template <class _Tp>
inline constexpr bool is_integral_v = is_integral<_Tp>::value;
#endif
-#endif // __has_keyword(__is_integral)
+#endif // __has_builtin(__is_integral)
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/is_member_function_pointer.h b/libcxx/include/__type_traits/is_member_function_pointer.h
index f18f3ebc5a3a6..2d2ff81e091a7 100644
--- a/libcxx/include/__type_traits/is_member_function_pointer.h
+++ b/libcxx/include/__type_traits/is_member_function_pointer.h
@@ -36,7 +36,7 @@ template <class _Tp, class _Up> struct __libcpp_is_member_pointer<_Tp _Up::*> {
};
};
-#if __has_keyword(__is_member_function_pointer)
+#if __has_builtin(__is_member_function_pointer)
template<class _Tp>
struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer
@@ -47,7 +47,7 @@ template <class _Tp>
inline constexpr bool is_member_function_pointer_v = __is_member_function_pointer(_Tp);
#endif
-#else // __has_keyword(__is_member_function_pointer)
+#else // __has_builtin(__is_member_function_pointer)
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer
: public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_func > {};
@@ -57,7 +57,7 @@ template <class _Tp>
inline constexpr bool is_member_function_pointer_v = is_member_function_pointer<_Tp>::value;
#endif
-#endif // __has_keyword(__is_member_function_pointer)
+#endif // __has_builtin(__is_member_function_pointer)
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/is_member_object_pointer.h b/libcxx/include/__type_traits/is_member_object_pointer.h
index 41f81d529388e..250a22c974406 100644
--- a/libcxx/include/__type_traits/is_member_object_pointer.h
+++ b/libcxx/include/__type_traits/is_member_object_pointer.h
@@ -18,7 +18,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if __has_keyword(__is_member_object_pointer)
+#if __has_builtin(__is_member_object_pointer)
template<class _Tp>
struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer
@@ -29,7 +29,7 @@ template <class _Tp>
inline constexpr bool is_member_object_pointer_v = __is_member_object_pointer(_Tp);
#endif
-#else // __has_keyword(__is_member_object_pointer)
+#else // __has_builtin(__is_member_object_pointer)
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer
: public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_obj > {};
@@ -39,7 +39,7 @@ template <class _Tp>
inline constexpr bool is_member_object_pointer_v = is_member_object_pointer<_Tp>::value;
#endif
-#endif // __has_keyword(__is_member_object_pointer)
+#endif // __has_builtin(__is_member_object_pointer)
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/is_member_pointer.h b/libcxx/include/__type_traits/is_member_pointer.h
index 76595dfdab7f0..448bcc23d55ed 100644
--- a/libcxx/include/__type_traits/is_member_pointer.h
+++ b/libcxx/include/__type_traits/is_member_pointer.h
@@ -18,7 +18,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if __has_keyword(__is_member_pointer)
+#if __has_builtin(__is_member_pointer)
template<class _Tp>
struct _LIBCPP_TEMPLATE_VIS is_member_pointer : _BoolConstant<__is_member_pointer(_Tp)> { };
@@ -28,7 +28,7 @@ template <class _Tp>
inline constexpr bool is_member_pointer_v = __is_member_pointer(_Tp);
#endif
-#else // __has_keyword(__is_member_pointer)
+#else // __has_builtin(__is_member_pointer)
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_pointer
: public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_member > {};
@@ -38,7 +38,7 @@ template <class _Tp>
inline constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value;
#endif
-#endif // __has_keyword(__is_member_pointer)
+#endif // __has_builtin(__is_member_pointer)
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/is_nothrow_assignable.h b/libcxx/include/__type_traits/is_nothrow_assignable.h
index 18e0e70a561d8..e3ce33ece8955 100644
--- a/libcxx/include/__type_traits/is_nothrow_assignable.h
+++ b/libcxx/include/__type_traits/is_nothrow_assignable.h
@@ -19,7 +19,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if __has_keyword(__is_nothrow_assignable)
+#if __has_builtin(__is_nothrow_assignable)
template <class _Tp, class _Arg>
struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
@@ -47,7 +47,7 @@ struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
{
};
-#endif // _LIBCPP_HAS_NO_NOEXCEPT
+#endif // __has_builtin(__is_nothrow_assignable)
#if _LIBCPP_STD_VER > 14
template <class _Tp, class _Arg>
diff --git a/libcxx/include/__type_traits/is_nothrow_constructible.h b/libcxx/include/__type_traits/is_nothrow_constructible.h
index 1f25d61baa63a..92d6e8343e03b 100644
--- a/libcxx/include/__type_traits/is_nothrow_constructible.h
+++ b/libcxx/include/__type_traits/is_nothrow_constructible.h
@@ -19,7 +19,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if __has_keyword(__is_nothrow_constructible)
+#if __has_builtin(__is_nothrow_constructible)
template <class _Tp, class... _Args>
struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
@@ -62,7 +62,7 @@ struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp[_Ns]>
{
};
-#endif // _LIBCPP_HAS_NO_NOEXCEPT
+#endif // __has_builtin(__is_nothrow_constructible)
#if _LIBCPP_STD_VER > 14
diff --git a/libcxx/include/__type_traits/is_object.h b/libcxx/include/__type_traits/is_object.h
index 0d8339d19492c..943f1a736cd5c 100644
--- a/libcxx/include/__type_traits/is_object.h
+++ b/libcxx/include/__type_traits/is_object.h
@@ -22,7 +22,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if __has_keyword(__is_object)
+#if __has_builtin(__is_object)
template<class _Tp>
struct _LIBCPP_TEMPLATE_VIS is_object : _BoolConstant<__is_object(_Tp)> { };
@@ -32,7 +32,7 @@ template <class _Tp>
inline constexpr bool is_object_v = __is_object(_Tp);
#endif
-#else // __has_keyword(__is_object)
+#else // __has_builtin(__is_object)
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_object
: public integral_constant<bool, is_scalar<_Tp>::value ||
@@ -45,7 +45,7 @@ template <class _Tp>
inline constexpr bool is_object_v = is_object<_Tp>::value;
#endif
-#endif // __has_keyword(__is_object)
+#endif // __has_builtin(__is_object)
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/is_pod.h b/libcxx/include/__type_traits/is_pod.h
index 4317182f89643..497060e005579 100644
--- a/libcxx/include/__type_traits/is_pod.h
+++ b/libcxx/include/__type_traits/is_pod.h
@@ -18,7 +18,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if __has_feature(is_pod) || defined(_LIBCPP_COMPILER_GCC)
+#if __has_builtin(__is_pod)
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod
: public integral_constant<bool, __is_pod(_Tp)> {};
@@ -31,7 +31,7 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod
is_trivially_copy_assignable<_Tp>::value &&
is_trivially_destructible<_Tp>::value> {};
-#endif
+#endif // __has_builtin(__is_pod)
#if _LIBCPP_STD_VER > 14
template <class _Tp>
diff --git a/libcxx/include/__type_traits/is_pointer.h b/libcxx/include/__type_traits/is_pointer.h
index 2139b03282e76..63c82ae4715cf 100644
--- a/libcxx/include/__type_traits/is_pointer.h
+++ b/libcxx/include/__type_traits/is_pointer.h
@@ -19,7 +19,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if __has_keyword(__is_pointer)
+#if __has_builtin(__is_pointer)
template<class _Tp>
struct _LIBCPP_TEMPLATE_VIS is_pointer : _BoolConstant<__is_pointer(_Tp)> { };
@@ -29,7 +29,7 @@ template <class _Tp>
inline constexpr bool is_pointer_v = __is_pointer(_Tp);
#endif
-#else // __has_keyword(__is_pointer)
+#else // __has_builtin(__is_pointer)
template <class _Tp> struct __libcpp_is_pointer : public false_type {};
template <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {};
@@ -50,7 +50,7 @@ template <class _Tp>
inline constexpr bool is_pointer_v = is_pointer<_Tp>::value;
#endif
-#endif // __has_keyword(__is_pointer)
+#endif // __has_builtin(__is_pointer)
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/is_reference.h b/libcxx/include/__type_traits/is_reference.h
index 8aa55c13ff83e..27ca2ddb5a72a 100644
--- a/libcxx/include/__type_traits/is_reference.h
+++ b/libcxx/include/__type_traits/is_reference.h
@@ -18,9 +18,9 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if __has_keyword(__is_lvalue_reference) && \
- __has_keyword(__is_rvalue_reference) && \
- __has_keyword(__is_reference)
+#if __has_builtin(__is_lvalue_reference) && \
+ __has_builtin(__is_rvalue_reference) && \
+ __has_builtin(__is_reference)
template<class _Tp>
struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : _BoolConstant<__is_lvalue_reference(_Tp)> { };
@@ -40,7 +40,7 @@ template <class _Tp>
inline constexpr bool is_rvalue_reference_v = __is_rvalue_reference(_Tp);
#endif
-#else // __has_keyword(__is_lvalue_reference) && etc...
+#else // __has_builtin(__is_lvalue_reference) && etc...
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : public false_type {};
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference<_Tp&> : public true_type {};
@@ -63,7 +63,7 @@ template <class _Tp>
inline constexpr bool is_rvalue_reference_v = is_rvalue_reference<_Tp>::value;
#endif
-#endif // __has_keyword(__is_lvalue_reference) && etc...
+#endif // __has_builtin(__is_lvalue_reference) && etc...
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/is_scalar.h b/libcxx/include/__type_traits/is_scalar.h
index 0ca34c7cf79bb..ee856dbbfec77 100644
--- a/libcxx/include/__type_traits/is_scalar.h
+++ b/libcxx/include/__type_traits/is_scalar.h
@@ -22,7 +22,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if __has_keyword(__is_scalar)
+#if __has_builtin(__is_scalar)
template<class _Tp>
struct _LIBCPP_TEMPLATE_VIS is_scalar : _BoolConstant<__is_scalar(_Tp)> { };
@@ -32,7 +32,7 @@ template <class _Tp>
inline constexpr bool is_scalar_v = __is_scalar(_Tp);
#endif
-#else // __has_keyword(__is_scalar)
+#else // __has_builtin(__is_scalar)
template <class _Tp> struct __is_block : false_type {};
#if defined(_LIBCPP_HAS_EXTENSION_BLOCKS)
@@ -54,7 +54,7 @@ template <class _Tp>
inline constexpr bool is_scalar_v = is_scalar<_Tp>::value;
#endif
-#endif // __has_keyword(__is_scalar)
+#endif // __has_builtin(__is_scalar)
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/is_signed.h b/libcxx/include/__type_traits/is_signed.h
index 241d6f551a4ba..e9722c9b21926 100644
--- a/libcxx/include/__type_traits/is_signed.h
+++ b/libcxx/include/__type_traits/is_signed.h
@@ -18,7 +18,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if __has_keyword(__is_signed)
+#if __has_builtin(__is_signed)
template<class _Tp>
struct _LIBCPP_TEMPLATE_VIS is_signed : _BoolConstant<__is_signed(_Tp)> { };
@@ -28,7 +28,7 @@ template <class _Tp>
inline constexpr bool is_signed_v = __is_signed(_Tp);
#endif
-#else // __has_keyword(__is_signed)
+#else // __has_builtin(__is_signed)
template <class _Tp, bool = is_integral<_Tp>::value>
struct __libcpp_is_signed_impl : public _BoolConstant<(_Tp(-1) < _Tp(0))> {};
@@ -48,7 +48,7 @@ template <class _Tp>
inline constexpr bool is_signed_v = is_signed<_Tp>::value;
#endif
-#endif // __has_keyword(__is_signed)
+#endif // __has_builtin(__is_signed)
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/is_standard_layout.h b/libcxx/include/__type_traits/is_standard_layout.h
index 375d08721e90b..0d8b5f480f0c5 100644
--- a/libcxx/include/__type_traits/is_standard_layout.h
+++ b/libcxx/include/__type_traits/is_standard_layout.h
@@ -19,7 +19,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_standard_layout
-#if __has_feature(is_standard_layout) || defined(_LIBCPP_COMPILER_GCC)
+#if __has_builtin(__is_standard_layout)
: public integral_constant<bool, __is_standard_layout(_Tp)>
#else
: integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
diff --git a/libcxx/include/__type_traits/is_trivial.h b/libcxx/include/__type_traits/is_trivial.h
index 011963c3d0e6d..73c2093d40820 100644
--- a/libcxx/include/__type_traits/is_trivial.h
+++ b/libcxx/include/__type_traits/is_trivial.h
@@ -19,7 +19,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivial
-#if __has_feature(is_trivial) || defined(_LIBCPP_COMPILER_GCC)
+#if __has_builtin(__is_trivial)
: public integral_constant<bool, __is_trivial(_Tp)>
#else
: integral_constant<bool, is_trivially_copyable<_Tp>::value &&
diff --git a/libcxx/include/__type_traits/is_trivially_destructible.h b/libcxx/include/__type_traits/is_trivially_destructible.h
index 81181cdf841d6..3376c3eeff43b 100644
--- a/libcxx/include/__type_traits/is_trivially_destructible.h
+++ b/libcxx/include/__type_traits/is_trivially_destructible.h
@@ -18,12 +18,12 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if __has_keyword(__is_trivially_destructible)
+#if __has_builtin(__is_trivially_destructible)
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
: public integral_constant<bool, __is_trivially_destructible(_Tp)> {};
-#elif __has_feature(has_trivial_destructor) || defined(_LIBCPP_COMPILER_GCC)
+#elif __has_builtin(__has_trivial_destructor)
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
: public integral_constant<bool, is_destructible<_Tp>::value && __has_trivial_destructor(_Tp)> {};
@@ -40,7 +40,7 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible<_Tp[]>
: public false_type {};
-#endif
+#endif // __has_builtin(__is_trivially_destructible)
#if _LIBCPP_STD_VER > 14
template <class _Tp>
diff --git a/libcxx/include/__type_traits/is_unsigned.h b/libcxx/include/__type_traits/is_unsigned.h
index bb279fdb729d3..17cd909d5478b 100644
--- a/libcxx/include/__type_traits/is_unsigned.h
+++ b/libcxx/include/__type_traits/is_unsigned.h
@@ -21,7 +21,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
// Before AppleClang 14, __is_unsigned returned true for enums with signed underlying type.
-#if __has_keyword(__is_unsigned) && !(defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1400)
+#if __has_builtin(__is_unsigned) && !(defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1400)
template<class _Tp>
struct _LIBCPP_TEMPLATE_VIS is_unsigned : _BoolConstant<__is_unsigned(_Tp)> { };
@@ -31,7 +31,7 @@ template <class _Tp>
inline constexpr bool is_unsigned_v = __is_unsigned(_Tp);
#endif
-#else // __has_keyword(__is_unsigned)
+#else // __has_builtin(__is_unsigned)
template <class _Tp, bool = is_integral<_Tp>::value>
struct __libcpp_is_unsigned_impl : public _BoolConstant<(_Tp(0) < _Tp(-1))> {};
@@ -51,7 +51,7 @@ template <class _Tp>
inline constexpr bool is_unsigned_v = is_unsigned<_Tp>::value;
#endif
-#endif // __has_keyword(__is_unsigned)
+#endif // __has_builtin(__is_unsigned)
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/is_void.h b/libcxx/include/__type_traits/is_void.h
index 29e68cc529dfa..4cebf18633b20 100644
--- a/libcxx/include/__type_traits/is_void.h
+++ b/libcxx/include/__type_traits/is_void.h
@@ -18,7 +18,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if __has_keyword(__is_void)
+#if __has_builtin(__is_void)
template <class _Tp>
struct _LIBCPP_TEMPLATE_VIS is_void : _BoolConstant<__is_void(_Tp)> { };
@@ -38,7 +38,7 @@ template <class _Tp>
inline constexpr bool is_void_v = is_void<_Tp>::value;
#endif
-#endif // __has_keyword(__is_void)
+#endif // __has_builtin(__is_void)
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/is_volatile.h b/libcxx/include/__type_traits/is_volatile.h
index 372703e7ced6a..fb922679d62bc 100644
--- a/libcxx/include/__type_traits/is_volatile.h
+++ b/libcxx/include/__type_traits/is_volatile.h
@@ -18,7 +18,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if __has_keyword(__is_volatile)
+#if __has_builtin(__is_volatile)
template <class _Tp>
struct _LIBCPP_TEMPLATE_VIS is_volatile : _BoolConstant<__is_volatile(_Tp)> { };
@@ -38,7 +38,7 @@ template <class _Tp>
inline constexpr bool is_volatile_v = is_volatile<_Tp>::value;
#endif
-#endif // __has_keyword(__is_volatile)
+#endif // __has_builtin(__is_volatile)
_LIBCPP_END_NAMESPACE_STD
More information about the libcxx-commits
mailing list