diff options
author | Serge Guelton <sguelton@redhat.com> | 2019-02-16 09:47:23 +0000 |
---|---|---|
committer | Serge Guelton <sguelton@redhat.com> | 2019-02-16 09:47:23 +0000 |
commit | 099cbc3e468d7ab583a0de85e06c14e5838f9414 (patch) | |
tree | 8666487d84c6f3c8271027406905c2a0c8f562df | |
parent | 98b4fd82b72f95542ce398c477f7a46df05b2e6a (diff) | |
download | bcm5719-llvm-099cbc3e468d7ab583a0de85e06c14e5838f9414.tar.gz bcm5719-llvm-099cbc3e468d7ab583a0de85e06c14e5838f9414.zip |
Revert r354199: Make Optional<T> Trivially Copyable when T is trivially copyable
llvm-svn: 354200
-rw-r--r-- | llvm/include/llvm/ADT/Optional.h | 53 | ||||
-rw-r--r-- | llvm/unittests/ADT/OptionalTest.cpp | 7 |
2 files changed, 0 insertions, 60 deletions
diff --git a/llvm/include/llvm/ADT/Optional.h b/llvm/include/llvm/ADT/Optional.h index ab83b67b11b..25a3185064f 100644 --- a/llvm/include/llvm/ADT/Optional.h +++ b/llvm/include/llvm/ADT/Optional.h @@ -108,59 +108,6 @@ template <typename T, bool = is_trivially_copyable<T>::value> struct OptionalSto return reinterpret_cast<const T *>(storage.buffer); } }; -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(const OptionalStorage &O) = default; - OptionalStorage(T &&y) : hasVal(true) { - new (storage.buffer) T(std::forward<T>(y)); - } - OptionalStorage(OptionalStorage &&O) = default; - - OptionalStorage &operator=(T &&y) { - if (hasVal) - *getPointer() = std::move(y); - else { - new (storage.buffer) T(std::move(y)); - hasVal = true; - } - return *this; - } - OptionalStorage &operator=(OptionalStorage &&O) = default; - - OptionalStorage &operator=(const T &y) { - if (hasVal) - *getPointer() = y; - else { - new (storage.buffer) T(y); - hasVal = true; - } - return *this; - } - OptionalStorage &operator=(const OptionalStorage &O) = default; - - ~OptionalStorage() = default; - - void reset() { - if (hasVal) { - (*getPointer()).~T(); - hasVal = false; - } - } - - T *getPointer() { - assert(hasVal); - return reinterpret_cast<T *>(storage.buffer); - } - const T *getPointer() const { - assert(hasVal); - return reinterpret_cast<const T *>(storage.buffer); - } -}; } // namespace optional_detail diff --git a/llvm/unittests/ADT/OptionalTest.cpp b/llvm/unittests/ADT/OptionalTest.cpp index 015fcf38981..98adaccca96 100644 --- a/llvm/unittests/ADT/OptionalTest.cpp +++ b/llvm/unittests/ADT/OptionalTest.cpp @@ -14,15 +14,8 @@ #include <array> - using namespace llvm; -static_assert(llvm::is_trivially_copyable<Optional<int>>::value, - "trivially copyable"); - -static_assert(llvm::is_trivially_copyable<Optional<std::array<int, 3>>>::value, - "trivially copyable"); - namespace { struct NonDefaultConstructible { |