[PATCH] D54540: [ADT] Drop llvm::Optional clang-specific optmization for trivially copyable types

Tom Stellard via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 15 11:35:08 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL346985: [ADT] Drop llvm::Optional clang-specific optmization for trivially copyable… (authored by tstellar, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D54540

Files:
  llvm/trunk/include/llvm/ADT/Optional.h


Index: llvm/trunk/include/llvm/ADT/Optional.h
===================================================================
--- llvm/trunk/include/llvm/ADT/Optional.h
+++ llvm/trunk/include/llvm/ADT/Optional.h
@@ -108,24 +108,6 @@
   }
 };
 
-#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 {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54540.174260.patch
Type: text/x-patch
Size: 854 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181115/1c2f9bdf/attachment.bin>


More information about the llvm-commits mailing list