[libcxx-commits] [libcxx] r364047 - Assume __is_final, __is_base_of, and friends.

Eric Fiselier via libcxx-commits libcxx-commits at lists.llvm.org
Fri Jun 21 06:56:13 PDT 2019


Author: ericwf
Date: Fri Jun 21 06:56:13 2019
New Revision: 364047

URL: http://llvm.org/viewvc/llvm-project?rev=364047&view=rev
Log:
Assume __is_final,  __is_base_of, and friends.

All the compilers we support provide these builtins. We don't
need to do a configuration dance anymore.

This patch also cleans up some dead or almost dead
C++11 feature detection macros.

Modified:
    libcxx/trunk/include/__config
    libcxx/trunk/include/future
    libcxx/trunk/include/type_traits

Modified: libcxx/trunk/include/__config
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=364047&r1=364046&r2=364047&view=diff
==============================================================================
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Fri Jun 21 06:56:13 2019
@@ -443,18 +443,6 @@ typedef __char32_t char32_t;
 #define _LIBCPP_HAS_NO_VARIADICS
 #endif
 
-#if !(__has_feature(cxx_generalized_initializers))
-#define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
-#endif
-
-#if __has_feature(is_base_of)
-#define _LIBCPP_HAS_IS_BASE_OF
-#endif
-
-#if __has_feature(is_final)
-#define _LIBCPP_HAS_IS_FINAL
-#endif
-
 // Objective-C++ features (opt-in)
 #if __has_feature(objc_arc)
 #define _LIBCPP_HAS_OBJC_ARC
@@ -464,10 +452,6 @@ typedef __char32_t char32_t;
 #define _LIBCPP_HAS_OBJC_ARC_WEAK
 #endif
 
-#if !(__has_feature(cxx_constexpr))
-#define _LIBCPP_HAS_NO_CONSTEXPR
-#endif
-
 #if !(__has_feature(cxx_relaxed_constexpr))
 #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
 #endif
@@ -480,14 +464,6 @@ typedef __char32_t char32_t;
 #define _LIBCPP_HAS_NO_NOEXCEPT
 #endif
 
-#if __has_feature(underlying_type)
-#define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T)
-#endif
-
-#if __has_feature(is_literal)
-#define _LIBCPP_IS_LITERAL(T) __is_literal(T)
-#endif
-
 #if !defined(_LIBCPP_HAS_NO_ASAN) && !__has_feature(address_sanitizer)
 #define _LIBCPP_HAS_NO_ASAN
 #endif
@@ -519,12 +495,6 @@ typedef __char32_t char32_t;
 
 #define _LIBCPP_NORETURN __attribute__((noreturn))
 
-#define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T)
-#define _LIBCPP_IS_LITERAL(T) __is_literal_type(T)
-#define _LIBCPP_HAS_IS_FINAL
-
-#define _LIBCPP_HAS_IS_BASE_OF
-
 #if !__EXCEPTIONS && !defined(_LIBCPP_NO_EXCEPTIONS)
 #define _LIBCPP_NO_EXCEPTIONS
 #endif
@@ -563,8 +533,6 @@ typedef __char32_t char32_t;
 #error "MSVC versions prior to Visual Studio 2015 are not supported"
 #endif
 
-#define _LIBCPP_HAS_IS_BASE_OF
-#define _LIBCPP_HAS_NO_CONSTEXPR
 #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
 #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
 #define _LIBCPP_HAS_NO_NOEXCEPT
@@ -589,10 +557,7 @@ typedef __char32_t char32_t;
 #define _ATTRIBUTE(x) __attribute__((x))
 #define _LIBCPP_NORETURN __attribute__((noreturn))
 
-#define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 #define _LIBCPP_HAS_NO_UNICODE_CHARS
-#define _LIBCPP_HAS_IS_BASE_OF
-#define _LIBCPP_HAS_IS_FINAL
 #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
 
 #if defined(_AIX)
@@ -836,7 +801,7 @@ typedef unsigned int   char32_t;
 # define decltype(...) __decltype(__VA_ARGS__)
 #endif  // _LIBCPP_CXX03_LANG
 
-#ifdef _LIBCPP_HAS_NO_CONSTEXPR
+#ifdef _LIBCPP_CXX03_LANG
 #  define _LIBCPP_CONSTEXPR
 #else
 #  define _LIBCPP_CONSTEXPR constexpr

Modified: libcxx/trunk/include/future
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/future?rev=364047&r1=364046&r2=364047&view=diff
==============================================================================
--- libcxx/trunk/include/future (original)
+++ libcxx/trunk/include/future Fri Jun 21 06:56:13 2019
@@ -408,11 +408,7 @@ _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(launc
 
 #ifndef _LIBCPP_HAS_NO_STRONG_ENUMS
 
-#ifdef _LIBCPP_UNDERLYING_TYPE
 typedef underlying_type<launch>::type __launch_underlying_type;
-#else
-typedef int __launch_underlying_type;
-#endif
 
 inline _LIBCPP_INLINE_VISIBILITY
 _LIBCPP_CONSTEXPR

Modified: libcxx/trunk/include/type_traits
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=364047&r1=364046&r2=364047&view=diff
==============================================================================
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Fri Jun 21 06:56:13 2019
@@ -1424,15 +1424,10 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR boo
 
 // is_final
 
-#if defined(_LIBCPP_HAS_IS_FINAL)
 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
 __libcpp_is_final : public integral_constant<bool, __is_final(_Tp)> {};
-#else
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
-__libcpp_is_final : public false_type {};
-#endif
 
-#if defined(_LIBCPP_HAS_IS_FINAL) && _LIBCPP_STD_VER > 11
+#if _LIBCPP_STD_VER > 11
 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
 is_final : public integral_constant<bool, __is_final(_Tp)> {};
 #endif
@@ -1459,39 +1454,10 @@ _LIBCPP_INLINE_VAR constexpr bool is_agg
 
 // is_base_of
 
-#ifdef _LIBCPP_HAS_IS_BASE_OF
-
 template <class _Bp, class _Dp>
 struct _LIBCPP_TEMPLATE_VIS is_base_of
     : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
 
-#else  // _LIBCPP_HAS_IS_BASE_OF
-
-namespace __is_base_of_imp
-{
-template <class _Tp>
-struct _Dst
-{
-    _Dst(const volatile _Tp &);
-};
-template <class _Tp>
-struct _Src
-{
-    operator const volatile _Tp &();
-    template <class _Up> operator const _Dst<_Up> &();
-};
-template <size_t> struct __one { typedef char type; };
-template <class _Bp, class _Dp> typename __one<sizeof(_Dst<_Bp>(declval<_Src<_Dp> >()))>::type __test(int);
-template <class _Bp, class _Dp> __two __test(...);
-}
-
-template <class _Bp, class _Dp>
-struct _LIBCPP_TEMPLATE_VIS is_base_of
-    : public integral_constant<bool, is_class<_Bp>::value &&
-                                     sizeof(__is_base_of_imp::__test<_Bp, _Dp>(0)) == 2> {};
-
-#endif  // _LIBCPP_HAS_IS_BASE_OF
-
 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
 template <class _Bp, class _Dp>
 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_base_of_v
@@ -4182,12 +4148,7 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR boo
 // is_literal_type;
 
 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_literal_type
-#ifdef _LIBCPP_IS_LITERAL
-    : public integral_constant<bool, _LIBCPP_IS_LITERAL(_Tp)>
-#else
-    : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value ||
-                              is_reference<typename remove_all_extents<_Tp>::type>::value>
-#endif
+    : public integral_constant<bool, __is_literal_type(_Tp)>
     {};
 
 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
@@ -4724,30 +4685,16 @@ _LIBCPP_INLINE_VAR constexpr bool is_not
 
 #endif // _LIBCPP_STD_VER > 14
 
-#ifdef _LIBCPP_UNDERLYING_TYPE
-
 template <class _Tp>
 struct underlying_type
 {
-    typedef _LIBCPP_UNDERLYING_TYPE(_Tp) type;
+    typedef __underlying_type(_Tp) type;
 };
 
 #if _LIBCPP_STD_VER > 11
 template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type;
 #endif
 
-#else  // _LIBCPP_UNDERLYING_TYPE
-
-template <class _Tp, bool _Support = false>
-struct underlying_type
-{
-    static_assert(_Support, "The underyling_type trait requires compiler "
-                            "support. Either no such support exists or "
-                            "libc++ does not know how to use it.");
-};
-
-#endif // _LIBCPP_UNDERLYING_TYPE
-
 
 template <class _Tp, bool = is_enum<_Tp>::value>
 struct __sfinae_underlying_type




More information about the libcxx-commits mailing list