[PATCH] D117254: [ADT] Fix Optional<> with llvm::is_trivially_move_constructible
Steven Wu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 13 14:35:53 PST 2022
steven_wu created this revision.
steven_wu added reviewers: dblaikie, dexonsmith, jplayer-nv, tatyana-krasnukha.
Herald added a subscriber: ributzka.
steven_wu requested review of this revision.
Herald added a project: LLVM.
Fix the compatibility of Optional<> with some GCC versions that it will fail
to compile when T is getting checked for `is_trivially_move_constructible`
as mentioned here: https://reviews.llvm.org/D93510#2538983
Fix the problem by using `llvm::is_trivially_move_constructible`.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D117254
Files:
llvm/include/llvm/ADT/Optional.h
llvm/unittests/ADT/OptionalTest.cpp
Index: llvm/unittests/ADT/OptionalTest.cpp
===================================================================
--- llvm/unittests/ADT/OptionalTest.cpp
+++ llvm/unittests/ADT/OptionalTest.cpp
@@ -805,4 +805,15 @@
EXPECT_EQ(hash_value(B), hash_value(I));
}
+struct ImplicitlyNonMovable {
+ ImplicitlyNonMovable(); // Constructor out-of-line.
+ virtual ~ImplicitlyNonMovable() = default;
+ Optional<MoveOnly> Alloc;
+};
+
+TEST(OptionalTest, ImplicitlyNonMovable) {
+ Optional<ImplicitlyNonMovable> V;
+ EXPECT_FALSE(V);
+}
+
} // end anonymous namespace
Index: llvm/include/llvm/ADT/Optional.h
===================================================================
--- llvm/include/llvm/ADT/Optional.h
+++ llvm/include/llvm/ADT/Optional.h
@@ -52,7 +52,7 @@
// of std::is_trivially_copyable.
template <typename T, bool = (llvm::is_trivially_copy_constructible<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_trivially_move_assignable<T>::value ||
!std::is_move_assignable<T>::value))>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117254.399791.patch
Type: text/x-patch
Size: 1347 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220113/24ba7152/attachment.bin>
More information about the llvm-commits
mailing list