summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/Value.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-09-22 02:02:33 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-09-22 02:02:33 +0000
commit70d4fb0d97287117fe7a09fbb5e352ffe1f6eebc (patch)
treeb7b30ab7d8c9dd49cf3d948f235279a1fbfab064 /llvm/lib/VMCore/Value.cpp
parent0dfed43a5b3a559669b86d5739d507d1f9445f3b (diff)
downloadbcm5719-llvm-70d4fb0d97287117fe7a09fbb5e352ffe1f6eebc.tar.gz
bcm5719-llvm-70d4fb0d97287117fe7a09fbb5e352ffe1f6eebc.zip
Add a TrackingVH value handle.
This is designed for tracking a value even when it might move (like WeakVH), but it is an error to delete the referenced value (unlike WeakVH0. TrackingVH is templated like AssertingVH on the tracked Value subclass, it is an error to RAUW a tracked value to an incompatible type. For implementation reasons the latter error is only diagnosed on accesses to a mis-RAUWed TrackingVH, because we don't want a virtual interface in a templated class. The former error is also only diagnosed on access, so that clients are allowed to delete a tracked value, as long as they don't use it. This makes it easier for the client to reason about destruction. llvm-svn: 82506
Diffstat (limited to 'llvm/lib/VMCore/Value.cpp')
-rw-r--r--llvm/lib/VMCore/Value.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/Value.cpp b/llvm/lib/VMCore/Value.cpp
index 773623b8bb4..6d9256fac52 100644
--- a/llvm/lib/VMCore/Value.cpp
+++ b/llvm/lib/VMCore/Value.cpp
@@ -503,6 +503,11 @@ void ValueHandleBase::ValueIsDeleted(Value *V) {
#endif
llvm_unreachable("An asserting value handle still pointed to this"
" value!");
+ case Tracking:
+ // Mark that this value has been deleted by setting it to an invalid Value
+ // pointer.
+ ThisNode->operator=(DenseMapInfo<Value *>::getTombstoneKey());
+ break;
case Weak:
// Weak just goes to null, which will unlink it from the list.
ThisNode->operator=(0);
@@ -539,6 +544,14 @@ void ValueHandleBase::ValueIsRAUWd(Value *Old, Value *New) {
case Assert:
// Asserting handle does not follow RAUW implicitly.
break;
+ case Tracking:
+ // Tracking goes to new value like a WeakVH. Note that this may make it
+ // something incompatible with its templated type. We don't want to have a
+ // virtual (or inline) interface to handle this though, so instead we make
+ // the TrackingVH accessors guarantee that a client never seesl this
+ // value.
+
+ // FALLTHROUGH
case Weak:
// Weak goes to the new value, which will unlink it from Old's list.
ThisNode->operator=(New);
OpenPOWER on IntegriCloud