forked from OSchip/llvm-project
[ADT] Drop llvm::Optional clang-specific optmization for trivially copyable types
Summary: This fixes libLLVM.so ABI mismatches between llvm compiled with clang and llvm compiled with gcc (PR39427). Reviewers: bkramer, sylvestre.ledru, mgorny, hans Reviewed By: bkramer, hans Subscribers: dexonsmith, kristina, llvm-commits Differential Revision: https://reviews.llvm.org/D54540 llvm-svn: 346985
This commit is contained in:
parent
782a15a0d1
commit
cc14a32411
|
@ -108,24 +108,6 @@ template <typename T, bool IsPodLike> struct OptionalStorage {
|
|||
}
|
||||
};
|
||||
|
||||
#if !defined(__GNUC__) || defined(__clang__) // GCC up to GCC7 miscompiles this.
|
||||
/// Storage for trivially copyable types only.
|
||||
template <typename T> struct OptionalStorage<T, true> {
|
||||
AlignedCharArrayUnion<T> storage;
|
||||
bool hasVal = false;
|
||||
|
||||
OptionalStorage() = default;
|
||||
|
||||
OptionalStorage(const T &y) : hasVal(true) { new (storage.buffer) T(y); }
|
||||
OptionalStorage &operator=(const T &y) {
|
||||
*reinterpret_cast<T *>(storage.buffer) = y;
|
||||
hasVal = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void reset() { hasVal = false; }
|
||||
};
|
||||
#endif
|
||||
} // namespace optional_detail
|
||||
|
||||
template <typename T> class Optional {
|
||||
|
|
Loading…
Reference in New Issue