$OpenBSD: patch-include_llvm_ADT_Optional_h,v 1.1 2019/01/28 06:27:28 jca Exp $

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

This fixes libLLVM.so ABI mismatches between llvm compiled with clang
and llvm compiled with gcc (PR39427).

Index: include/llvm/ADT/Optional.h
--- include/llvm/ADT/Optional.h.orig
+++ include/llvm/ADT/Optional.h
@@ -108,24 +108,6 @@ template <typename T, bool IsPodLike> struct OptionalS
   }
 };
 
-#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 {
