diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-09-22 02:02:33 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-09-22 02:02:33 +0000 |
commit | e5b18362dbafc8ee44ae864664fffe47066f685a (patch) | |
tree | 9c205f4fef1b148ea8ac352c7c50f2c71cb0fddc /lib/VMCore | |
parent | 014d624a2864605b10d3b14fd9cda3163c41f6bf (diff) | |
download | external_llvm-e5b18362dbafc8ee44ae864664fffe47066f685a.zip external_llvm-e5b18362dbafc8ee44ae864664fffe47066f685a.tar.gz external_llvm-e5b18362dbafc8ee44ae864664fffe47066f685a.tar.bz2 |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82506 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r-- | lib/VMCore/Value.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/VMCore/Value.cpp b/lib/VMCore/Value.cpp index 773623b..6d9256f 100644 --- a/lib/VMCore/Value.cpp +++ b/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); |