diff --git a/libcxx/include/__config b/libcxx/include/__config --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -24,16 +24,6 @@ #ifdef __cplusplus -#ifdef __GNUC__ -# define _GNUC_VER (__GNUC__ * 100 + __GNUC_MINOR__) -// The _GNUC_VER_NEW macro better represents the new GCC versioning scheme -// introduced in GCC 5.0. -# define _GNUC_VER_NEW (_GNUC_VER * 10 + __GNUC_PATCHLEVEL__) -#else -# define _GNUC_VER 0 -# define _GNUC_VER_NEW 0 -#endif - #define _LIBCPP_VERSION 14000 #ifndef _LIBCPP_ABI_VERSION @@ -509,22 +499,8 @@ #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow"))) #endif -#if __has_builtin(__builtin_launder) -#define _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER -#endif - -#if __has_builtin(__builtin_constant_p) -#define _LIBCPP_COMPILER_HAS_BUILTIN_CONSTANT_P -#endif - #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) -// Literal operators ""d and ""y are supported starting with LLVM Clang 8 and AppleClang 10.0.1 -#if (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 800) || \ - (defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1001) -#define _LIBCPP_HAS_NO_CXX20_CHRONO_LITERALS -#endif - #define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__ #elif defined(_LIBCPP_COMPILER_GCC) @@ -547,11 +523,6 @@ #define _LIBCPP_HAS_NO_ASAN #endif -#if _GNUC_VER >= 700 -#define _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER -#define _LIBCPP_COMPILER_HAS_BUILTIN_CONSTANT_P -#endif - #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) #define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__ @@ -1275,7 +1246,7 @@ # define _LIBCPP_FALLTHROUGH() [[fallthrough]] #elif __has_cpp_attribute(clang::fallthrough) # define _LIBCPP_FALLTHROUGH() [[clang::fallthrough]] -#elif __has_attribute(fallthrough) || _GNUC_VER >= 700 +#elif __has_attribute(__fallthrough__) # define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__)) #else # define _LIBCPP_FALLTHROUGH() ((void)0) @@ -1386,12 +1357,6 @@ # define _LIBCPP_FOPEN_CLOEXEC_MODE #endif -#ifdef _LIBCPP_COMPILER_HAS_BUILTIN_CONSTANT_P -#define _LIBCPP_BUILTIN_CONSTANT_P(x) __builtin_constant_p(x) -#else -#define _LIBCPP_BUILTIN_CONSTANT_P(x) false -#endif - // Support for _FILE_OFFSET_BITS=64 landed gradually in Android, so the full set // of functions used in cstdio may not be available for low API levels when // using 64-bit file offsets on LP32. diff --git a/libcxx/include/atomic b/libcxx/include/atomic --- a/libcxx/include/atomic +++ b/libcxx/include/atomic @@ -1496,11 +1496,8 @@ typename _Base = __cxx_atomic_base_impl<_Tp> > #endif //_LIBCPP_ATOMIC_ONLY_USE_BUILTINS struct __cxx_atomic_impl : public _Base { - -#if _GNUC_VER >= 501 static_assert(is_trivially_copyable<_Tp>::value, "std::atomic requires that 'Tp' be a trivially copyable type"); -#endif _LIBCPP_INLINE_VISIBILITY __cxx_atomic_impl() _NOEXCEPT _LIBCPP_DEFAULT _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR explicit __cxx_atomic_impl(_Tp value) _NOEXCEPT diff --git a/libcxx/include/chrono b/libcxx/include/chrono --- a/libcxx/include/chrono +++ b/libcxx/include/chrono @@ -2907,7 +2907,7 @@ return chrono::duration (__ns); } -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_CHRONO_LITERALS) +#if _LIBCPP_STD_VER > 17 constexpr chrono::day operator ""d(unsigned long long __d) noexcept { return chrono::day(static_cast(__d)); diff --git a/libcxx/include/new b/libcxx/include/new --- a/libcxx/include/new +++ b/libcxx/include/new @@ -337,11 +337,7 @@ { static_assert (!(is_function<_Tp>::value), "can't launder functions" ); static_assert (!(is_same::type>::value), "can't launder cv-void" ); -#ifdef _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER return __builtin_launder(__p); -#else - return __p; -#endif } #if _LIBCPP_STD_VER > 14 diff --git a/libcxx/include/string b/libcxx/include/string --- a/libcxx/include/string +++ b/libcxx/include/string @@ -2373,7 +2373,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s, size_type __n) { _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::assign received nullptr"); - return (_LIBCPP_BUILTIN_CONSTANT_P(__n) && __n < __min_cap) + return (__builtin_constant_p(__n) && __n < __min_cap) ? __assign_short(__s, __n) : __assign_external(__s, __n); } @@ -2578,7 +2578,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s) { _LIBCPP_ASSERT(__s != nullptr, "string::assign received nullptr"); - return _LIBCPP_BUILTIN_CONSTANT_P(*__s) + return __builtin_constant_p(*__s) ? (traits_type::length(__s) < __min_cap ? __assign_short(__s, traits_type::length(__s)) : __assign_external(__s, traits_type::length(__s))) diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits --- a/libcxx/include/type_traits +++ b/libcxx/include/type_traits @@ -3049,135 +3049,10 @@ // template struct is_constructible; -#if defined(_LIBCPP_COMPILER_GCC) && _GNUC_VER_NEW >= 10000 -# define _LIBCPP_GCC_SUPPORTS_IS_CONSTRUCTIBLE -#endif - -#if !defined(_LIBCPP_CXX03_LANG) && !__has_feature(is_constructible) && !defined(_LIBCPP_GCC_SUPPORTS_IS_CONSTRUCTIBLE) - -template -struct __libcpp_is_constructible; - -template -struct __is_invalid_base_to_derived_cast { - static_assert(is_reference<_To>::value, "Wrong specialization"); - using _RawFrom = __uncvref_t<_From>; - using _RawTo = __uncvref_t<_To>; - static const bool value = _And< - _IsNotSame<_RawFrom, _RawTo>, - is_base_of<_RawFrom, _RawTo>, - _Not<__libcpp_is_constructible<_RawTo, _From>> - >::value; -}; - -template -struct __is_invalid_lvalue_to_rvalue_cast : false_type { - static_assert(is_reference<_To>::value, "Wrong specialization"); -}; - -template -struct __is_invalid_lvalue_to_rvalue_cast<_ToRef&&, _FromRef&> { - using _RawFrom = __uncvref_t<_FromRef>; - using _RawTo = __uncvref_t<_ToRef>; - static const bool value = _And< - _Not>, - _Or< - _IsSame<_RawFrom, _RawTo>, - is_base_of<_RawTo, _RawFrom>> - >::value; -}; - -struct __is_constructible_helper -{ - template - static void __eat(_To); - - // This overload is needed to work around a Clang bug that disallows - // static_cast(e) for non-reference-compatible types. - // Example: static_cast(declval()); - // NOTE: The static_cast implementation below is required to support - // classes with explicit conversion operators. - template (declval<_From>()))> - static true_type __test_cast(int); - - template (declval<_From>()))> - static integral_constant::value && - !__is_invalid_lvalue_to_rvalue_cast<_To, _From>::value - > __test_cast(long); - - template - static false_type __test_cast(...); - - template ()...))> - static true_type __test_nary(int); - template - static false_type __test_nary(...); - - template ()))> - static is_destructible<_Tp> __test_unary(int); - template - static false_type __test_unary(...); -}; - -template ::value> -struct __is_default_constructible - : decltype(__is_constructible_helper::__test_nary<_Tp>(0)) -{}; - -template -struct __is_default_constructible<_Tp, true> : false_type {}; - -template -struct __is_default_constructible<_Tp[], false> : false_type {}; - -template -struct __is_default_constructible<_Tp[_Nx], false> - : __is_default_constructible::type> {}; - -template -struct __libcpp_is_constructible -{ - static_assert(sizeof...(_Args) > 1, "Wrong specialization"); - typedef decltype(__is_constructible_helper::__test_nary<_Tp, _Args...>(0)) - type; -}; - -template -struct __libcpp_is_constructible<_Tp> : __is_default_constructible<_Tp> {}; - -template -struct __libcpp_is_constructible<_Tp, _A0> - : public decltype(__is_constructible_helper::__test_unary<_Tp, _A0>(0)) -{}; - -template -struct __libcpp_is_constructible<_Tp&, _A0> - : public decltype(__is_constructible_helper:: - __test_cast<_Tp&, _A0>(0)) -{}; - -template -struct __libcpp_is_constructible<_Tp&&, _A0> - : public decltype(__is_constructible_helper:: - __test_cast<_Tp&&, _A0>(0)) -{}; - -#endif - -#if __has_feature(is_constructible) || defined(_LIBCPP_GCC_SUPPORTS_IS_CONSTRUCTIBLE) template struct _LIBCPP_TEMPLATE_VIS is_constructible : public integral_constant - {}; -#else -template -struct _LIBCPP_TEMPLATE_VIS is_constructible - : public __libcpp_is_constructible<_Tp, _Args...>::type {}; -#endif +{ }; #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) template @@ -3250,53 +3125,12 @@ // is_trivially_constructible -#if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501 - template struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible : integral_constant { }; -#else // !__has_feature(is_trivially_constructible) - -template -struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible - : false_type -{ -}; - -template -struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp> -#if __has_feature(has_trivial_constructor) || defined(_LIBCPP_COMPILER_GCC) - : integral_constant -#else - : integral_constant::value> -#endif -{ -}; - -template -struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&&> - : integral_constant::value> -{ -}; - -template -struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, const _Tp&> - : integral_constant::value> -{ -}; - -template -struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&> - : integral_constant::value> -{ -}; - -#endif // !__has_feature(is_trivially_constructible) - - #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) template _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_constructible_v @@ -3341,37 +3175,10 @@ // is_trivially_assignable -#if __has_feature(is_trivially_assignable) || _GNUC_VER >= 501 - template struct is_trivially_assignable : integral_constant -{ -}; - -#else // !__has_feature(is_trivially_assignable) - -template -struct is_trivially_assignable - : public false_type {}; - -template -struct is_trivially_assignable<_Tp&, _Tp> - : integral_constant::value> {}; - -template -struct is_trivially_assignable<_Tp&, _Tp&> - : integral_constant::value> {}; - -template -struct is_trivially_assignable<_Tp&, const _Tp&> - : integral_constant::value> {}; - -template -struct is_trivially_assignable<_Tp&, _Tp&&> - : integral_constant::value> {}; - -#endif // !__has_feature(is_trivially_assignable) +{ }; #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) template diff --git a/libcxx/include/variant b/libcxx/include/variant --- a/libcxx/include/variant +++ b/libcxx/include/variant @@ -233,10 +233,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -// TODO: GCC 5 lies about its support for C++17 (it says it supports it but it -// really doesn't). That breaks variant, which uses some C++17 features. -// Remove this once we drop support for GCC 5. -#if _LIBCPP_STD_VER > 14 && !(defined(_LIBCPP_COMPILER_GCC) && _GNUC_VER_NEW < 6000) +#if _LIBCPP_STD_VER > 14 // Light N-dimensional array of function pointers. Used in place of std::array to avoid // adding a dependency. diff --git a/libcxx/src/include/atomic_support.h b/libcxx/src/include/atomic_support.h --- a/libcxx/src/include/atomic_support.h +++ b/libcxx/src/include/atomic_support.h @@ -24,7 +24,7 @@ && defined(__ATOMIC_ACQ_REL) \ && defined(__ATOMIC_SEQ_CST) # define _LIBCPP_HAS_ATOMIC_BUILTINS -#elif !defined(__clang__) && defined(_GNUC_VER) && _GNUC_VER >= 407 +#elif defined(_LIBCPP_COMPILER_GCC) # define _LIBCPP_HAS_ATOMIC_BUILTINS #endif diff --git a/libcxx/src/locale.cpp b/libcxx/src/locale.cpp --- a/libcxx/src/locale.cpp +++ b/libcxx/src/locale.cpp @@ -261,13 +261,6 @@ #endif // _LIBCPP_NO_EXCEPTIONS } -// NOTE avoid the `base class should be explicitly initialized in the -// copy constructor` warning emitted by GCC -#if defined(__clang__) || _GNUC_VER >= 406 -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wextra" -#endif - locale::__imp::__imp(const __imp& other) : facets_(max(N, other.facets_.size())), name_(other.name_) @@ -278,10 +271,6 @@ facets_[i]->__add_shared(); } -#if defined(__clang__) || _GNUC_VER >= 406 -#pragma GCC diagnostic pop -#endif - locale::__imp::__imp(const __imp& other, const string& name, locale::category c) : facets_(N), name_("*") diff --git a/libcxxabi/src/include/atomic_support.h b/libcxxabi/src/include/atomic_support.h --- a/libcxxabi/src/include/atomic_support.h +++ b/libcxxabi/src/include/atomic_support.h @@ -28,7 +28,7 @@ && defined(__ATOMIC_ACQ_REL) \ && defined(__ATOMIC_SEQ_CST) # define _LIBCXXABI_HAS_ATOMIC_BUILTINS -#elif !defined(__clang__) && defined(_GNUC_VER) && _GNUC_VER >= 407 +#elif defined(_LIBCPP_COMPILER_GCC) # define _LIBCXXABI_HAS_ATOMIC_BUILTINS #endif