diff options
author | Sanjoy Das <sanjoy@playingwithpointers.com> | 2017-05-01 17:07:54 +0000 |
---|---|---|
committer | Sanjoy Das <sanjoy@playingwithpointers.com> | 2017-05-01 17:07:54 +0000 |
commit | 41673c62eceb523c6eb56eb91ce2aaceaea9599c (patch) | |
tree | 2f607da4fcfd8ee57c4660cdcc2d7d5f73739917 /unittests/IR/ValueHandleTest.cpp | |
parent | 399b4d037da5dc48bef296dcd6ccdad46aa75c9e (diff) |
Add a new WeakVH value handle; NFC
This relands r301425.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301813 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/IR/ValueHandleTest.cpp')
-rw-r--r-- | unittests/IR/ValueHandleTest.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/unittests/IR/ValueHandleTest.cpp b/unittests/IR/ValueHandleTest.cpp index 96331288d07..9a4ce156dc3 100644 --- a/unittests/IR/ValueHandleTest.cpp +++ b/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); |