[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:39:54 PST 2022
steven_wu updated this revision to Diff 399797.
steven_wu added a comment.
Rename the variables to be more accurate.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D117254/new/
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 NotTriviallyCopyable {
+ NotTriviallyCopyable(); // Constructor out-of-line.
+ virtual ~NotTriviallyCopyable() = default;
+ Optional<MoveOnly> MO;
+};
+
+TEST(OptionalTest, ImplicitlyNonMovable) {
+ Optional<NotTriviallyCopyable> 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.399797.patch
Type: text/x-patch
Size: 1344 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220113/1c61d1b2/attachment.bin>
More information about the llvm-commits
mailing list