summaryrefslogtreecommitdiff
path: root/lib/ExecutionEngine/Interpreter
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2014-09-16 17:28:15 +0000
committerReid Kleckner <reid@kleckner.net>2014-09-16 17:28:15 +0000
commit61e184dbe5594eb9243bcf91bd7b4bc5d68e69c5 (patch)
tree4dafd3ea41a39bc2c9dcd1d54007191a1e0d4318 /lib/ExecutionEngine/Interpreter
parent763d8b2ef7fe7926c0f82fc725ee8d2cb40c51a9 (diff)
Fix move-only type issues in Interpreter with MSVC
MSVC 2012 cannot infer any move special members, but it will call them if available. MSVC 2013 cannot infer move assignment. Therefore, explicitly implement the special members for the ExecutionContext class and its contained types. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217887 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine/Interpreter')
-rw-r--r--lib/ExecutionEngine/Interpreter/Interpreter.h36
1 files changed, 24 insertions, 12 deletions
diff --git a/lib/ExecutionEngine/Interpreter/Interpreter.h b/lib/ExecutionEngine/Interpreter/Interpreter.h
index befd5c76d83..1661b034e52 100644
--- a/lib/ExecutionEngine/Interpreter/Interpreter.h
+++ b/lib/ExecutionEngine/Interpreter/Interpreter.h
@@ -41,18 +41,13 @@ class AllocaHolder {
public:
AllocaHolder() {}
- // Make this type move-only.
-#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);
+
+ // Make this type move-only. Define explicit move special members for MSVC.
+ AllocaHolder(AllocaHolder &&RHS) : Allocations(std::move(RHS.Allocations)) {}
+ AllocaHolder &operator=(AllocaHolder &&RHS) {
+ Allocations = std::move(RHS.Allocations);
return *this;
}
-#else
- AllocaHolder(AllocaHolder &&RHS) : Allocations(std::move(RHS.Allocations)) {}
-#endif
~AllocaHolder() {
for (void *Allocation : Allocations)
@@ -71,11 +66,28 @@ struct ExecutionContext {
Function *CurFunction;// The currently executing function
BasicBlock *CurBB; // The currently executing BB
BasicBlock::iterator CurInst; // The next instruction to execute
- std::map<Value *, GenericValue> Values; // LLVM values used in this invocation
- std::vector<GenericValue> VarArgs; // Values passed through an ellipsis
CallSite Caller; // Holds the call that called subframes.
// NULL if main func or debugger invoked fn
+ std::map<Value *, GenericValue> Values; // LLVM values used in this invocation
+ std::vector<GenericValue> VarArgs; // Values passed through an ellipsis
AllocaHolder Allocas; // Track memory allocated by alloca
+
+ ExecutionContext() : CurFunction(nullptr), CurBB(nullptr), CurInst(nullptr) {}
+
+ ExecutionContext(ExecutionContext &&O)
+ : CurFunction(O.CurFunction), CurBB(O.CurBB), CurInst(O.CurInst),
+ Caller(O.Caller), Values(std::move(O.Values)),
+ VarArgs(std::move(O.VarArgs)), Allocas(std::move(O.Allocas)) {}
+
+ ExecutionContext &operator=(ExecutionContext &&O) {
+ CurFunction = O.CurFunction;
+ CurBB = O.CurBB;
+ CurInst = O.CurInst;
+ Caller = O.Caller;
+ Values = std::move(O.Values);
+ VarArgs = std::move(O.VarArgs);
+ Allocas = std::move(O.Allocas);
+ }
};
// Interpreter - This class represents the entirety of the interpreter.