Skip to content

Commit f7211fd

Browse files
committed
Merging r347004:
------------------------------------------------------------------------ r347004 | tstellar | 2018-11-16 00:47:24 +0000 (Fri, 16 Nov 2018) | 4 lines Re-apply r346985: [ADT] Drop llvm::Optional clang-specific optimization for trivially copyable types Remove a test case that was added with the optimization we are now removing. ------------------------------------------------------------------------ llvm-svn: 352582
1 parent 7735ea3 commit f7211fd

File tree

2 files changed

+0
-26
lines changed

2 files changed

+0
-26
lines changed

llvm/include/llvm/ADT/Optional.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -108,24 +108,6 @@ template <typename T, bool IsPodLike> struct OptionalStorage {
108108
}
109109
};
110110

111-
#if !defined(__GNUC__) || defined(__clang__) // GCC up to GCC7 miscompiles this.
112-
/// Storage for trivially copyable types only.
113-
template <typename T> struct OptionalStorage<T, true> {
114-
AlignedCharArrayUnion<T> storage;
115-
bool hasVal = false;
116-
117-
OptionalStorage() = default;
118-
119-
OptionalStorage(const T &y) : hasVal(true) { new (storage.buffer) T(y); }
120-
OptionalStorage &operator=(const T &y) {
121-
*reinterpret_cast<T *>(storage.buffer) = y;
122-
hasVal = true;
123-
return *this;
124-
}
125-
126-
void reset() { hasVal = false; }
127-
};
128-
#endif
129111
} // namespace optional_detail
130112

131113
template <typename T> class Optional {

llvm/unittests/ADT/OptionalTest.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -518,13 +518,5 @@ TEST_F(OptionalTest, OperatorGreaterEqual) {
518518
CheckRelation<GreaterEqual>(InequalityLhs, InequalityRhs, !IsLess);
519519
}
520520

521-
#if __has_feature(is_trivially_copyable) && defined(_LIBCPP_VERSION)
522-
static_assert(std::is_trivially_copyable<Optional<int>>::value,
523-
"Should be trivially copyable");
524-
static_assert(
525-
!std::is_trivially_copyable<Optional<NonDefaultConstructible>>::value,
526-
"Shouldn't be trivially copyable");
527-
#endif
528-
529521
} // end anonymous namespace
530522

0 commit comments

Comments
 (0)