forked from OSchip/llvm-project
Revert "[llvm] Remove llvm::is_trivially_{copy/move}_constructible (NFC)"
This reverts commit 01ffe31cbb
.
A build breakage with GCC 7.3 has been reported:
https://reviews.llvm.org/D132311#3797053
FWIW, GCC 7.5 is OK according to Pavel Chupin. I also personally
tested GCC 8.4.0.
This commit is contained in:
parent
6cf11f4462
commit
29c841ce93
|
@ -59,7 +59,7 @@ namespace detail {
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
using EnableIfTrivial =
|
using EnableIfTrivial =
|
||||||
std::enable_if_t<std::is_trivially_move_constructible<T>::value &&
|
std::enable_if_t<llvm::is_trivially_move_constructible<T>::value &&
|
||||||
std::is_trivially_destructible<T>::value>;
|
std::is_trivially_destructible<T>::value>;
|
||||||
template <typename CallableT, typename ThisT>
|
template <typename CallableT, typename ThisT>
|
||||||
using EnableUnlessSameType =
|
using EnableUnlessSameType =
|
||||||
|
@ -100,8 +100,8 @@ protected:
|
||||||
static_assert(!std::is_reference<T>::value,
|
static_assert(!std::is_reference<T>::value,
|
||||||
"references should be handled by template specialization");
|
"references should be handled by template specialization");
|
||||||
using type = typename std::conditional<
|
using type = typename std::conditional<
|
||||||
std::is_trivially_copy_constructible<T>::value &&
|
llvm::is_trivially_copy_constructible<T>::value &&
|
||||||
std::is_trivially_move_constructible<T>::value &&
|
llvm::is_trivially_move_constructible<T>::value &&
|
||||||
IsSizeLessThanThresholdT<T>::value,
|
IsSizeLessThanThresholdT<T>::value,
|
||||||
T, T &>::type;
|
T, T &>::type;
|
||||||
};
|
};
|
||||||
|
|
|
@ -50,9 +50,10 @@ namespace optional_detail {
|
||||||
//
|
//
|
||||||
// The move constructible / assignable conditions emulate the remaining behavior
|
// The move constructible / assignable conditions emulate the remaining behavior
|
||||||
// of std::is_trivially_copyable.
|
// of std::is_trivially_copyable.
|
||||||
template <typename T, bool = (std::is_trivially_copy_constructible<T>::value &&
|
template <typename T,
|
||||||
|
bool = (llvm::is_trivially_copy_constructible<T>::value &&
|
||||||
std::is_trivially_copy_assignable<T>::value &&
|
std::is_trivially_copy_assignable<T>::value &&
|
||||||
(std::is_trivially_move_constructible<T>::value ||
|
(llvm::is_trivially_move_constructible<T>::value ||
|
||||||
!std::is_move_constructible<T>::value) &&
|
!std::is_move_constructible<T>::value) &&
|
||||||
(std::is_trivially_move_assignable<T>::value ||
|
(std::is_trivially_move_assignable<T>::value ||
|
||||||
!std::is_move_assignable<T>::value))>
|
!std::is_move_assignable<T>::value))>
|
||||||
|
|
|
@ -312,8 +312,8 @@ public:
|
||||||
/// copy these types with memcpy, there is no way for the type to observe this.
|
/// 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
|
/// This catches the important case of std::pair<POD, POD>, which is not
|
||||||
/// trivially assignable.
|
/// trivially assignable.
|
||||||
template <typename T, bool = (std::is_trivially_copy_constructible<T>::value) &&
|
template <typename T, bool = (is_trivially_copy_constructible<T>::value) &&
|
||||||
(std::is_trivially_move_constructible<T>::value) &&
|
(is_trivially_move_constructible<T>::value) &&
|
||||||
std::is_trivially_destructible<T>::value>
|
std::is_trivially_destructible<T>::value>
|
||||||
class SmallVectorTemplateBase : public SmallVectorTemplateCommon<T> {
|
class SmallVectorTemplateBase : public SmallVectorTemplateCommon<T> {
|
||||||
friend class SmallVectorTemplateCommon<T>;
|
friend class SmallVectorTemplateCommon<T>;
|
||||||
|
|
|
@ -70,6 +70,21 @@ struct const_pointer_or_const_ref<T,
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace detail {
|
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>
|
template<class T>
|
||||||
union trivial_helper {
|
union trivial_helper {
|
||||||
T t;
|
T t;
|
||||||
|
@ -77,6 +92,29 @@ union trivial_helper {
|
||||||
|
|
||||||
} // end namespace detail
|
} // 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>
|
template <typename T>
|
||||||
struct is_copy_assignable {
|
struct is_copy_assignable {
|
||||||
template<class F>
|
template<class F>
|
||||||
|
|
|
@ -26,10 +26,10 @@ namespace triviality {
|
||||||
template <typename T, bool IsTriviallyCopyConstructible,
|
template <typename T, bool IsTriviallyCopyConstructible,
|
||||||
bool IsTriviallyMoveConstructible>
|
bool IsTriviallyMoveConstructible>
|
||||||
void TrivialityTester() {
|
void TrivialityTester() {
|
||||||
static_assert(std::is_trivially_copy_constructible<T>::value ==
|
static_assert(llvm::is_trivially_copy_constructible<T>::value ==
|
||||||
IsTriviallyCopyConstructible,
|
IsTriviallyCopyConstructible,
|
||||||
"Mismatch in expected trivial copy construction!");
|
"Mismatch in expected trivial copy construction!");
|
||||||
static_assert(std::is_trivially_move_constructible<T>::value ==
|
static_assert(llvm::is_trivially_move_constructible<T>::value ==
|
||||||
IsTriviallyMoveConstructible,
|
IsTriviallyMoveConstructible,
|
||||||
"Mismatch in expected trivial move construction!");
|
"Mismatch in expected trivial move construction!");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue