[llvm] Remove llvm::is_trivially_{copy/move}_constructible (NFC)

This patch removes llvm::is_trivially_{copy/move}_constructible in
favor of std::is_trivially_{copy/move}_constructible.

The previous attempt to remove them in Dec 2020,
c8d406c93c, broke builds with "some
versions of GCC" according to
6cd9608fb3.

It's been 20 months since then, and the minimum requirement for GCC
has been updated to 7.1 from 5.1.

FWIW, I was able to build llvm with gcc 8.4.0.

Differential Revision: https://reviews.llvm.org/D132311
This commit is contained in:
Kazu Hirata 2022-08-20 14:06:42 -07:00
parent e0fc85e092
commit 01ffe31cbb
5 changed files with 13 additions and 52 deletions

View File

@ -59,7 +59,7 @@ namespace detail {
template <typename T>
using EnableIfTrivial =
std::enable_if_t<llvm::is_trivially_move_constructible<T>::value &&
std::enable_if_t<std::is_trivially_move_constructible<T>::value &&
std::is_trivially_destructible<T>::value>;
template <typename CallableT, typename ThisT>
using EnableUnlessSameType =
@ -100,8 +100,8 @@ protected:
static_assert(!std::is_reference<T>::value,
"references should be handled by template specialization");
using type = typename std::conditional<
llvm::is_trivially_copy_constructible<T>::value &&
llvm::is_trivially_move_constructible<T>::value &&
std::is_trivially_copy_constructible<T>::value &&
std::is_trivially_move_constructible<T>::value &&
IsSizeLessThanThresholdT<T>::value,
T, T &>::type;
};

View File

@ -50,13 +50,12 @@ namespace optional_detail {
//
// The move constructible / assignable conditions emulate the remaining behavior
// of std::is_trivially_copyable.
template <typename T,
bool = (llvm::is_trivially_copy_constructible<T>::value &&
std::is_trivially_copy_assignable<T>::value &&
(llvm::is_trivially_move_constructible<T>::value ||
!std::is_move_constructible<T>::value) &&
(std::is_trivially_move_assignable<T>::value ||
!std::is_move_assignable<T>::value))>
template <typename T, bool = (std::is_trivially_copy_constructible<T>::value &&
std::is_trivially_copy_assignable<T>::value &&
(std::is_trivially_move_constructible<T>::value ||
!std::is_move_constructible<T>::value) &&
(std::is_trivially_move_assignable<T>::value ||
!std::is_move_assignable<T>::value))>
class OptionalStorage {
union {
char empty;

View File

@ -312,8 +312,8 @@ public:
/// copy these types with memcpy, there is no way for the type to observe this.
/// This catches the important case of std::pair<POD, POD>, which is not
/// trivially assignable.
template <typename T, bool = (is_trivially_copy_constructible<T>::value) &&
(is_trivially_move_constructible<T>::value) &&
template <typename T, bool = (std::is_trivially_copy_constructible<T>::value) &&
(std::is_trivially_move_constructible<T>::value) &&
std::is_trivially_destructible<T>::value>
class SmallVectorTemplateBase : public SmallVectorTemplateCommon<T> {
friend class SmallVectorTemplateCommon<T>;

View File

@ -70,21 +70,6 @@ struct const_pointer_or_const_ref<T,
};
namespace detail {
/// Internal utility to detect trivial copy construction.
template<typename T> union copy_construction_triviality_helper {
T t;
copy_construction_triviality_helper() = default;
copy_construction_triviality_helper(const copy_construction_triviality_helper&) = default;
~copy_construction_triviality_helper() = default;
};
/// Internal utility to detect trivial move construction.
template<typename T> union move_construction_triviality_helper {
T t;
move_construction_triviality_helper() = default;
move_construction_triviality_helper(move_construction_triviality_helper&&) = default;
~move_construction_triviality_helper() = default;
};
template<class T>
union trivial_helper {
T t;
@ -92,29 +77,6 @@ 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 {};
/// 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>

View File

@ -26,10 +26,10 @@ namespace triviality {
template <typename T, bool IsTriviallyCopyConstructible,
bool IsTriviallyMoveConstructible>
void TrivialityTester() {
static_assert(llvm::is_trivially_copy_constructible<T>::value ==
static_assert(std::is_trivially_copy_constructible<T>::value ==
IsTriviallyCopyConstructible,
"Mismatch in expected trivial copy construction!");
static_assert(llvm::is_trivially_move_constructible<T>::value ==
static_assert(std::is_trivially_move_constructible<T>::value ==
IsTriviallyMoveConstructible,
"Mismatch in expected trivial move construction!");