Patch from Albert J. Wong to make type_traits take advantage of gcc intrinsics in 4.7 and later. No functionality change when using clang.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@211755 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Marshall Clow 2014-06-26 01:07:56 +00:00
parent 44ead61237
commit 81aa3a745c
2 changed files with 16 additions and 7 deletions

View File

@ -339,7 +339,11 @@ typedef __char32_t char32_t;
#endif #endif
#if __has_feature(underlying_type) #if __has_feature(underlying_type)
# define _LIBCXX_UNDERLYING_TYPE(T) __underlying_type(T) # define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T)
#endif
#if __has_feature(is_literal)
# define _LIBCPP_IS_LITERAL(T) __is_literal(T)
#endif #endif
// Inline namespaces are available in Clang regardless of C++ dialect. // Inline namespaces are available in Clang regardless of C++ dialect.
@ -363,6 +367,11 @@ namespace std {
#define _LIBCPP_NORETURN __attribute__((noreturn)) #define _LIBCPP_NORETURN __attribute__((noreturn))
#if _GNUC_VER >= 407
#define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T)
#define _LIBCPP_IS_LITERAL(T) __is_literal_type(T)
#endif
#if !__EXCEPTIONS #if !__EXCEPTIONS
#define _LIBCPP_NO_EXCEPTIONS #define _LIBCPP_NO_EXCEPTIONS
#endif #endif

View File

@ -2971,8 +2971,8 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pod
// is_literal_type; // is_literal_type;
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_literal_type template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_literal_type
#if __has_feature(is_literal) #ifdef _LIBCPP_IS_LITERAL
: public integral_constant<bool, __is_literal(_Tp)> : public integral_constant<bool, _LIBCPP_IS_LITERAL(_Tp)>
#else #else
: integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value || : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value ||
is_reference<typename remove_all_extents<_Tp>::type>::value> is_reference<typename remove_all_extents<_Tp>::type>::value>
@ -3363,19 +3363,19 @@ struct __is_nothrow_swappable
#endif // __has_feature(cxx_noexcept) #endif // __has_feature(cxx_noexcept)
#ifdef _LIBCXX_UNDERLYING_TYPE #ifdef _LIBCPP_UNDERLYING_TYPE
template <class _Tp> template <class _Tp>
struct underlying_type struct underlying_type
{ {
typedef _LIBCXX_UNDERLYING_TYPE(_Tp) type; typedef _LIBCPP_UNDERLYING_TYPE(_Tp) type;
}; };
#if _LIBCPP_STD_VER > 11 #if _LIBCPP_STD_VER > 11
template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type; template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type;
#endif #endif
#else // _LIBCXX_UNDERLYING_TYPE #else // _LIBCPP_UNDERLYING_TYPE
template <class _Tp, bool _Support = false> template <class _Tp, bool _Support = false>
struct underlying_type struct underlying_type
@ -3385,7 +3385,7 @@ struct underlying_type
"libc++ does not know how to use it."); "libc++ does not know how to use it.");
}; };
#endif // _LIBCXX_UNDERLYING_TYPE #endif // _LIBCPP_UNDERLYING_TYPE
#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE #ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE