[llvm] r217875 - Interpreter: Hack around a series of bugs in MSVC 2012 that copies around this

Benjamin Kramer benny.kra at googlemail.com
Tue Sep 16 08:26:41 PDT 2014


Author: d0k
Date: Tue Sep 16 10:26:41 2014
New Revision: 217875

URL: http://llvm.org/viewvc/llvm-project?rev=217875&view=rev
Log:
Interpreter: Hack around a series of bugs in MSVC 2012 that copies around this
move-only struct.

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

Modified:
    llvm/trunk/lib/ExecutionEngine/Interpreter/Interpreter.h

Modified: llvm/trunk/lib/ExecutionEngine/Interpreter/Interpreter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Interpreter/Interpreter.h?rev=217875&r1=217874&r2=217875&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/Interpreter/Interpreter.h (original)
+++ llvm/trunk/lib/ExecutionEngine/Interpreter/Interpreter.h Tue Sep 16 10:26:41 2014
@@ -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)





More information about the llvm-commits mailing list