Interpreter: Hack around a series of bugs in MSVC 2012 that copies around this
authorBenjamin Kramer <benny.kra@googlemail.com>
Tue, 16 Sep 2014 15:26:41 +0000 (15:26 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Tue, 16 Sep 2014 15:26:41 +0000 (15:26 +0000)
move-only struct.

I feel terrible now, but at least it's shielded away from proper compilers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217875 91177308-0d34-0410-b5e6-96231b3b80d8

lib/ExecutionEngine/Interpreter/Interpreter.h

index 9715e71e85924299338c9d48bda4d1fcdd49e124..282b1e04bea74dec7c751d9c6761254e369e993c 100644 (file)
@@ -42,11 +42,17 @@ class AllocaHolder {
 public:
   AllocaHolder() {}
   // Make this type move-only.
-  AllocaHolder(AllocaHolder &&RHS) : Allocations(std::move(RHS.Allocations)) {}
-  AllocaHolder &operator=(AllocaHolder &&RHS) {
-    Allocations = std::move(RHS.Allocations);
+#if defined(_MSC_VER) && _MSC_VER < 1800
+  // Hack around bugs in MSVC 2012. It always tries to copy this class.
+  AllocaHolder(const AllocaHolder &RHS)
+      : Allocations(std::move(const_cast<AllocaHolder &>(RHS).Allocations)) {}
+  AllocaHolder &operator=(const AllocaHolder &RHS) {
+    Allocations = std::move(const_cast<AllocaHolder &>(RHS).Allocations);
     return *this;
   }
+#else
+  AllocaHolder(AllocaHolder &&RHS) = default;
+#endif
 
   ~AllocaHolder() {
     for (void *Allocation : Allocations)