Skip to content

Commit 01ffe31

Browse files
[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, c8d406c, broke builds with "some versions of GCC" according to 6cd9608. 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
1 parent e0fc85e commit 01ffe31

File tree

5 files changed

+13
-52
lines changed

5 files changed

+13
-52
lines changed

llvm/include/llvm/ADT/FunctionExtras.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ namespace detail {
5959

6060
template <typename T>
6161
using EnableIfTrivial =
62-
std::enable_if_t<llvm::is_trivially_move_constructible<T>::value &&
62+
std::enable_if_t<std::is_trivially_move_constructible<T>::value &&
6363
std::is_trivially_destructible<T>::value>;
6464
template <typename CallableT, typename ThisT>
6565
using EnableUnlessSameType =
@@ -100,8 +100,8 @@ template <typename ReturnT, typename... ParamTs> class UniqueFunctionBase {
100100
static_assert(!std::is_reference<T>::value,
101101
"references should be handled by template specialization");
102102
using type = typename std::conditional<
103-
llvm::is_trivially_copy_constructible<T>::value &&
104-
llvm::is_trivially_move_constructible<T>::value &&
103+
std::is_trivially_copy_constructible<T>::value &&
104+
std::is_trivially_move_constructible<T>::value &&
105105
IsSizeLessThanThresholdT<T>::value,
106106
T, T &>::type;
107107
};

llvm/include/llvm/ADT/Optional.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,12 @@ namespace optional_detail {
5050
//
5151
// The move constructible / assignable conditions emulate the remaining behavior
5252
// of std::is_trivially_copyable.
53-
template <typename T,
54-
bool = (llvm::is_trivially_copy_constructible<T>::value &&
55-
std::is_trivially_copy_assignable<T>::value &&
56-
(llvm::is_trivially_move_constructible<T>::value ||
57-
!std::is_move_constructible<T>::value) &&
58-
(std::is_trivially_move_assignable<T>::value ||
59-
!std::is_move_assignable<T>::value))>
53+
template <typename T, bool = (std::is_trivially_copy_constructible<T>::value &&
54+
std::is_trivially_copy_assignable<T>::value &&
55+
(std::is_trivially_move_constructible<T>::value ||
56+
!std::is_move_constructible<T>::value) &&
57+
(std::is_trivially_move_assignable<T>::value ||
58+
!std::is_move_assignable<T>::value))>
6059
class OptionalStorage {
6160
union {
6261
char empty;

llvm/include/llvm/ADT/SmallVector.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,8 @@ class SmallVectorTemplateCommon
312312
/// copy these types with memcpy, there is no way for the type to observe this.
313313
/// This catches the important case of std::pair<POD, POD>, which is not
314314
/// trivially assignable.
315-
template <typename T, bool = (is_trivially_copy_constructible<T>::value) &&
316-
(is_trivially_move_constructible<T>::value) &&
315+
template <typename T, bool = (std::is_trivially_copy_constructible<T>::value) &&
316+
(std::is_trivially_move_constructible<T>::value) &&
317317
std::is_trivially_destructible<T>::value>
318318
class SmallVectorTemplateBase : public SmallVectorTemplateCommon<T> {
319319
friend class SmallVectorTemplateCommon<T>;

llvm/include/llvm/Support/type_traits.h

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -70,51 +70,13 @@ struct const_pointer_or_const_ref<T,
7070
};
7171

7272
namespace detail {
73-
/// Internal utility to detect trivial copy construction.
74-
template<typename T> union copy_construction_triviality_helper {
75-
T t;
76-
copy_construction_triviality_helper() = default;
77-
copy_construction_triviality_helper(const copy_construction_triviality_helper&) = default;
78-
~copy_construction_triviality_helper() = default;
79-
};
80-
/// Internal utility to detect trivial move construction.
81-
template<typename T> union move_construction_triviality_helper {
82-
T t;
83-
move_construction_triviality_helper() = default;
84-
move_construction_triviality_helper(move_construction_triviality_helper&&) = default;
85-
~move_construction_triviality_helper() = default;
86-
};
87-
8873
template<class T>
8974
union trivial_helper {
9075
T t;
9176
};
9277

9378
} // end namespace detail
9479

95-
/// An implementation of `std::is_trivially_copy_constructible` since we have
96-
/// users with STLs that don't yet include it.
97-
template <typename T>
98-
struct is_trivially_copy_constructible
99-
: std::is_copy_constructible<
100-
::llvm::detail::copy_construction_triviality_helper<T>> {};
101-
template <typename T>
102-
struct is_trivially_copy_constructible<T &> : std::true_type {};
103-
template <typename T>
104-
struct is_trivially_copy_constructible<T &&> : std::false_type {};
105-
106-
/// An implementation of `std::is_trivially_move_constructible` since we have
107-
/// users with STLs that don't yet include it.
108-
template <typename T>
109-
struct is_trivially_move_constructible
110-
: std::is_move_constructible<
111-
::llvm::detail::move_construction_triviality_helper<T>> {};
112-
template <typename T>
113-
struct is_trivially_move_constructible<T &> : std::true_type {};
114-
template <typename T>
115-
struct is_trivially_move_constructible<T &&> : std::true_type {};
116-
117-
11880
template <typename T>
11981
struct is_copy_assignable {
12082
template<class F>

llvm/unittests/Support/TypeTraitsTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ namespace triviality {
2626
template <typename T, bool IsTriviallyCopyConstructible,
2727
bool IsTriviallyMoveConstructible>
2828
void TrivialityTester() {
29-
static_assert(llvm::is_trivially_copy_constructible<T>::value ==
29+
static_assert(std::is_trivially_copy_constructible<T>::value ==
3030
IsTriviallyCopyConstructible,
3131
"Mismatch in expected trivial copy construction!");
32-
static_assert(llvm::is_trivially_move_constructible<T>::value ==
32+
static_assert(std::is_trivially_move_constructible<T>::value ==
3333
IsTriviallyMoveConstructible,
3434
"Mismatch in expected trivial move construction!");
3535

0 commit comments

Comments
 (0)