Files
allwpilib/upstream_utils/llvm_patches/0022-use-std-is_trivially_copy_constructible.patch
2022-05-20 15:59:53 -07:00

142 lines
5.4 KiB
Diff

From 6df7cc04af50a1afad6f8baf8ea0520576944bed Mon Sep 17 00:00:00 2001
From: PJ Reiniger <pj.reiniger@gmail.com>
Date: Sun, 8 May 2022 16:42:09 -0400
Subject: [PATCH 22/31] 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 cb8b202c48b7..f9c4d2dd14c7 100644
--- a/llvm/include/llvm/ADT/PointerIntPair.h
+++ b/llvm/include/llvm/ADT/PointerIntPair.h
@@ -127,18 +127,6 @@ public:
}
};
-// Specialize is_trivially_copyable to avoid limitation of llvm::is_trivially_copyable
-// when compiled with gcc 4.9.
-template <typename PointerTy, unsigned IntBits, typename IntType,
- typename PtrTraits,
- typename Info>
-struct is_trivially_copyable<PointerIntPair<PointerTy, IntBits, IntType, PtrTraits, Info>> : std::true_type {
-#ifdef HAVE_STD_IS_TRIVIALLY_COPYABLE
- static_assert(std::is_trivially_copyable<PointerIntPair<PointerTy, IntBits, IntType, PtrTraits, Info>>::value,
- "inconsistent behavior between llvm:: and std:: implementation of is_trivially_copyable");
-#endif
-};
-
template <typename PointerT, unsigned IntBits, typename PtrTraits>
struct PointerIntPairInfo {
diff --git a/llvm/include/llvm/Support/type_traits.h b/llvm/include/llvm/Support/type_traits.h
index 7b7d5d991f3f..72a2e84ad452 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 <typename T>
-struct is_trivially_copy_constructible
- : std::is_copy_constructible<
- ::llvm::detail::copy_construction_triviality_helper<T>> {};
-template <typename T>
-struct is_trivially_copy_constructible<T &> : std::true_type {};
-template <typename T>
-struct is_trivially_copy_constructible<T &&> : std::false_type {};
+using is_trivially_move_constructible = std::is_trivially_move_constructible<T>;
-/// An implementation of `std::is_trivially_move_constructible` since we have
-/// users with STLs that don't yet include it.
-template <typename T>
-struct is_trivially_move_constructible
- : std::is_move_constructible<
- ::llvm::detail::move_construction_triviality_helper<T>> {};
template <typename T>
-struct is_trivially_move_constructible<T &> : std::true_type {};
-template <typename T>
-struct is_trivially_move_constructible<T &&> : std::true_type {};
-
-
-template <typename T>
-struct is_copy_assignable {
- template<class F>
- static auto get(F*) -> decltype(std::declval<F &>() = std::declval<const F &>(), std::true_type{});
- static std::false_type get(...);
- static constexpr bool value = decltype(get((T*)nullptr))::value;
-};
-
-template <typename T>
-struct is_move_assignable {
- template<class F>
- static auto get(F*) -> decltype(std::declval<F &>() = std::declval<F &&>(), 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 <typename T>
-class is_trivially_copyable {
-
- // copy constructors
- static constexpr bool has_trivial_copy_constructor =
- std::is_copy_constructible<detail::trivial_helper<T>>::value;
- static constexpr bool has_deleted_copy_constructor =
- !std::is_copy_constructible<T>::value;
-
- // move constructors
- static constexpr bool has_trivial_move_constructor =
- std::is_move_constructible<detail::trivial_helper<T>>::value;
- static constexpr bool has_deleted_move_constructor =
- !std::is_move_constructible<T>::value;
-
- // copy assign
- static constexpr bool has_trivial_copy_assign =
- is_copy_assignable<detail::trivial_helper<T>>::value;
- static constexpr bool has_deleted_copy_assign =
- !is_copy_assignable<T>::value;
-
- // move assign
- static constexpr bool has_trivial_move_assign =
- is_move_assignable<detail::trivial_helper<T>>::value;
- static constexpr bool has_deleted_move_assign =
- !is_move_assignable<T>::value;
-
- // destructor
- static constexpr bool has_trivial_destructor =
- std::is_destructible<detail::trivial_helper<T>>::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<T>::value,
- "inconsistent behavior between llvm:: and std:: implementation of is_trivially_copyable");
-#endif
-};
-template <typename T>
-class is_trivially_copyable<T*> : public std::true_type {
-};
+using is_trivially_copy_constructible = std::is_trivially_copy_constructible<T>;
} // end namespace llvm
--
2.20.1.windows.1