summaryrefslogtreecommitdiff
path: root/include/llvm/Support/ValueHandle.h
diff options
context:
space:
mode:
authorJeffrey Yasskin <jyasskin@google.com>2009-08-07 19:54:29 +0000
committerJeffrey Yasskin <jyasskin@google.com>2009-08-07 19:54:29 +0000
commit0d5bd59553375dc85ac04c81ef48ef74c9e7193e (patch)
treef9cf8660342725fc1e0008b31e2929145180dde9 /include/llvm/Support/ValueHandle.h
parentf12288e8aa27a7cb1e48e1fceccd5cf49876104e (diff)
downloadllvm-0d5bd59553375dc85ac04c81ef48ef74c9e7193e.tar.gz
llvm-0d5bd59553375dc85ac04c81ef48ef74c9e7193e.tar.bz2
llvm-0d5bd59553375dc85ac04c81ef48ef74c9e7193e.tar.xz
To catch bugs like the one fixed in
http://llvm.org/viewvc/llvm-project?view=rev&revision=78127, I'm changing the ExecutionEngine's global mappings to hold AssertingVH<const GlobalValue>. That way, if unregistering a mapping fails to actually unregister it, we'll get an assert. Running the jit nightly tests didn't uncover any actual instances of the problem. This also uncovered the fact that AssertingVH<const X> didn't work, so I fixed that too. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78400 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/ValueHandle.h')
-rw-r--r--include/llvm/Support/ValueHandle.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/include/llvm/Support/ValueHandle.h b/include/llvm/Support/ValueHandle.h
index 84745ff2c3..e0e06e1186 100644
--- a/include/llvm/Support/ValueHandle.h
+++ b/include/llvm/Support/ValueHandle.h
@@ -171,7 +171,7 @@ class AssertingVH
return static_cast<ValueTy*>(ValueHandleBase::getValPtr());
}
void setValPtr(ValueTy *P) {
- ValueHandleBase::operator=(P);
+ ValueHandleBase::operator=(GetAsValue(P));
}
#else
ValueTy *ThePtr;
@@ -179,10 +179,15 @@ class AssertingVH
void setValPtr(ValueTy *P) { ThePtr = P; }
#endif
+ // Convert a ValueTy*, which may be const, to the type the base
+ // class expects.
+ static Value *GetAsValue(Value *V) { return V; }
+ static Value *GetAsValue(const Value *V) { return const_cast<Value*>(V); }
+
public:
#ifndef NDEBUG
AssertingVH() : ValueHandleBase(Assert) {}
- AssertingVH(ValueTy *P) : ValueHandleBase(Assert, P) {}
+ AssertingVH(ValueTy *P) : ValueHandleBase(Assert, GetAsValue(P)) {}
AssertingVH(const AssertingVH &RHS) : ValueHandleBase(Assert, RHS) {}
#else
AssertingVH() : ThePtr(0) {}