From 7de051ba0c4632dc5fcabc4f17cdf0cedf97724e Mon Sep 17 00:00:00 2001 From: Sanjoy Das Date: Wed, 26 Apr 2017 16:20:59 +0000 Subject: Add a new WeakVH value handle; NFC Summary: WeakVH nulls itself out if the value it was tracking gets deleted, but it does not track RAUW. Reviewers: dblaikie, davide Subscribers: mcrosier, llvm-commits Differential Revision: https://reviews.llvm.org/D32267 llvm-svn: 301425 --- llvm/lib/IR/Value.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'llvm/lib') diff --git a/llvm/lib/IR/Value.cpp b/llvm/lib/IR/Value.cpp index 23a0f7a2601..18e44dcd352 100644 --- a/llvm/lib/IR/Value.cpp +++ b/llvm/lib/IR/Value.cpp @@ -825,8 +825,10 @@ void ValueHandleBase::ValueIsDeleted(Value *V) { // pointer. Entry->operator=(DenseMapInfo::getTombstoneKey()); break; + case Weak: case WeakTracking: - // WeakTracking just goes to null, which will unlink it from the list. + // WeakTracking and Weak just go to null, which unlinks them + // from the list. Entry->operator=(nullptr); break; case Callback: @@ -874,7 +876,8 @@ void ValueHandleBase::ValueIsRAUWd(Value *Old, Value *New) { switch (Entry->getKind()) { case Assert: - // Asserting handle does not follow RAUW implicitly. + case Weak: + // Asserting and Weak handles do not follow RAUW implicitly. break; case Tracking: // Tracking goes to new value like a WeakTrackingVH. Note that this may -- cgit v1.2.3