From 1c3e8a6ff8d8b6c054141503c7318d69319d8d41 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sun, 8 May 2022 16:42:09 -0400 Subject: [PATCH 18/28] Use std::is_trivially_copy_constructible --- llvm/include/llvm/ADT/PointerIntPair.h | 12 ---- llvm/include/llvm/Support/type_traits.h | 91 +------------------------ 2 files changed, 2 insertions(+), 101 deletions(-) diff --git a/llvm/include/llvm/ADT/PointerIntPair.h b/llvm/include/llvm/ADT/PointerIntPair.h index b7ddf8855..a48fb904b 100644 --- a/llvm/include/llvm/ADT/PointerIntPair.h +++ b/llvm/include/llvm/ADT/PointerIntPair.h @@ -128,18 +128,6 @@ public: } }; -// Specialize is_trivially_copyable to avoid limitation of llvm::is_trivially_copyable -// when compiled with gcc 4.9. -template -struct is_trivially_copyable> : std::true_type { -#ifdef HAVE_STD_IS_TRIVIALLY_COPYABLE - static_assert(std::is_trivially_copyable>::value, - "inconsistent behavior between llvm:: and std:: implementation of is_trivially_copyable"); -#endif -}; - template struct PointerIntPairInfo { diff --git a/llvm/include/llvm/Support/type_traits.h b/llvm/include/llvm/Support/type_traits.h index 7b7d5d991..72a2e84ad 100644 --- a/llvm/include/llvm/Support/type_traits.h +++ b/llvm/include/llvm/Support/type_traits.h @@ -92,98 +92,11 @@ union trivial_helper { } // end namespace detail -/// An implementation of `std::is_trivially_copy_constructible` since we have -/// users with STLs that don't yet include it. template -struct is_trivially_copy_constructible - : std::is_copy_constructible< - ::llvm::detail::copy_construction_triviality_helper> {}; -template -struct is_trivially_copy_constructible : std::true_type {}; -template -struct is_trivially_copy_constructible : std::false_type {}; +using is_trivially_move_constructible = std::is_trivially_move_constructible; -/// An implementation of `std::is_trivially_move_constructible` since we have -/// users with STLs that don't yet include it. -template -struct is_trivially_move_constructible - : std::is_move_constructible< - ::llvm::detail::move_construction_triviality_helper> {}; template -struct is_trivially_move_constructible : std::true_type {}; -template -struct is_trivially_move_constructible : std::true_type {}; - - -template -struct is_copy_assignable { - template - static auto get(F*) -> decltype(std::declval() = std::declval(), std::true_type{}); - static std::false_type get(...); - static constexpr bool value = decltype(get((T*)nullptr))::value; -}; - -template -struct is_move_assignable { - template - static auto get(F*) -> decltype(std::declval() = std::declval(), std::true_type{}); - static std::false_type get(...); - static constexpr bool value = decltype(get((T*)nullptr))::value; -}; - - -// An implementation of `std::is_trivially_copyable` since STL version -// is not equally supported by all compilers, especially GCC 4.9. -// Uniform implementation of this trait is important for ABI compatibility -// as it has an impact on SmallVector's ABI (among others). -template -class is_trivially_copyable { - - // copy constructors - static constexpr bool has_trivial_copy_constructor = - std::is_copy_constructible>::value; - static constexpr bool has_deleted_copy_constructor = - !std::is_copy_constructible::value; - - // move constructors - static constexpr bool has_trivial_move_constructor = - std::is_move_constructible>::value; - static constexpr bool has_deleted_move_constructor = - !std::is_move_constructible::value; - - // copy assign - static constexpr bool has_trivial_copy_assign = - is_copy_assignable>::value; - static constexpr bool has_deleted_copy_assign = - !is_copy_assignable::value; - - // move assign - static constexpr bool has_trivial_move_assign = - is_move_assignable>::value; - static constexpr bool has_deleted_move_assign = - !is_move_assignable::value; - - // destructor - static constexpr bool has_trivial_destructor = - std::is_destructible>::value; - - public: - - static constexpr bool value = - has_trivial_destructor && - (has_deleted_move_assign || has_trivial_move_assign) && - (has_deleted_move_constructor || has_trivial_move_constructor) && - (has_deleted_copy_assign || has_trivial_copy_assign) && - (has_deleted_copy_constructor || has_trivial_copy_constructor); - -#ifdef HAVE_STD_IS_TRIVIALLY_COPYABLE - static_assert(value == std::is_trivially_copyable::value, - "inconsistent behavior between llvm:: and std:: implementation of is_trivially_copyable"); -#endif -}; -template -class is_trivially_copyable : public std::true_type { -}; +using is_trivially_copy_constructible = std::is_trivially_copy_constructible; } // end namespace llvm