summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/IR/ValueHandleTest.cpp
diff options
context:
space:
mode:
authorSanjoy Das <sanjoy@playingwithpointers.com>2017-04-26 16:20:59 +0000
committerSanjoy Das <sanjoy@playingwithpointers.com>2017-04-26 16:20:59 +0000
commit7de051ba0c4632dc5fcabc4f17cdf0cedf97724e (patch)
tree0ebb49094b5c389a8028fb5ef8e34cca64b7e36b /llvm/unittests/IR/ValueHandleTest.cpp
parent01de5577388a02ea289b5517d55dc0e8eb4efc76 (diff)
downloadbcm5719-llvm-7de051ba0c4632dc5fcabc4f17cdf0cedf97724e.tar.gz
bcm5719-llvm-7de051ba0c4632dc5fcabc4f17cdf0cedf97724e.zip
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
Diffstat (limited to 'llvm/unittests/IR/ValueHandleTest.cpp')
-rw-r--r--llvm/unittests/IR/ValueHandleTest.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/unittests/IR/ValueHandleTest.cpp b/llvm/unittests/IR/ValueHandleTest.cpp
index f4cacd3f7dd..191fdbb8f0f 100644
--- a/llvm/unittests/IR/ValueHandleTest.cpp
+++ b/llvm/unittests/IR/ValueHandleTest.cpp
@@ -34,6 +34,24 @@ public:
ConcreteCallbackVH(Value *V) : CallbackVH(V) {}
};
+TEST_F(ValueHandle, WeakVH_BasicOperation) {
+ WeakVH WVH(BitcastV.get());
+ EXPECT_EQ(BitcastV.get(), WVH);
+ WVH = ConstantV;
+ EXPECT_EQ(ConstantV, WVH);
+
+ // Make sure I can call a method on the underlying Value. It
+ // doesn't matter which method.
+ EXPECT_EQ(Type::getInt32Ty(Context), WVH->getType());
+ EXPECT_EQ(Type::getInt32Ty(Context), (*WVH).getType());
+
+ WVH = BitcastV.get();
+ BitcastV->replaceAllUsesWith(ConstantV);
+ EXPECT_EQ(WVH, BitcastV.get());
+ BitcastV.reset();
+ EXPECT_EQ(WVH, nullptr);
+}
+
TEST_F(ValueHandle, WeakTrackingVH_BasicOperation) {
WeakTrackingVH WVH(BitcastV.get());
EXPECT_EQ(BitcastV.get(), WVH);
OpenPOWER on IntegriCloud