summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/IR/UserTest.cpp
diff options
context:
space:
mode:
authorKeno Fischer <kfischer@college.harvard.edu>2015-12-23 18:27:23 +0000
committerKeno Fischer <kfischer@college.harvard.edu>2015-12-23 18:27:23 +0000
commit9bc46b117b460d83565794e1b7bdc3196afee907 (patch)
tree0f43bbc095133062a2bbfe66078d628a48eb6d95 /llvm/unittests/IR/UserTest.cpp
parent61ad8b3907e4812aa5fb76edb030ff384c889246 (diff)
downloadbcm5719-llvm-9bc46b117b460d83565794e1b7bdc3196afee907.tar.gz
bcm5719-llvm-9bc46b117b460d83565794e1b7bdc3196afee907.zip
[Function] Properly remove use when clearing personality
Summary: We need to actually remove the use of the personality function, otherwise we can run into trouble if we want to e.g. delete the personality function because ther's no way to get rid of its uses. Do this by resetting to ConstantPointerNull value that the operands are set to when first allocated. Reviewers: vsk, dexonsmith Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D15752 llvm-svn: 256345
Diffstat (limited to 'llvm/unittests/IR/UserTest.cpp')
-rw-r--r--llvm/unittests/IR/UserTest.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/llvm/unittests/IR/UserTest.cpp b/llvm/unittests/IR/UserTest.cpp
index 56b054b6835..8d488389448 100644
--- a/llvm/unittests/IR/UserTest.cpp
+++ b/llvm/unittests/IR/UserTest.cpp
@@ -93,4 +93,28 @@ TEST(UserTest, ValueOpIteration) {
EXPECT_EQ(P.value_op_end(), (I - 2) + 8);
}
+TEST(UserTest, PersonalityUser) {
+ Module M("", getGlobalContext());
+ FunctionType *RetVoidTy =
+ FunctionType::get(Type::getVoidTy(getGlobalContext()), false);
+ Function *PersonalityF = Function::Create(
+ RetVoidTy, GlobalValue::ExternalLinkage, "PersonalityFn", &M);
+ Function *TestF =
+ Function::Create(RetVoidTy, GlobalValue::ExternalLinkage, "TestFn", &M);
+
+ // Set up the personality function
+ TestF->setPersonalityFn(PersonalityF);
+ auto PersonalityUsers = PersonalityF->user_begin();
+
+ // One user and that user is the Test function
+ EXPECT_EQ(*PersonalityUsers, TestF);
+ EXPECT_EQ(++PersonalityUsers, PersonalityF->user_end());
+
+ // Reset the personality function
+ TestF->setPersonalityFn(nullptr);
+
+ // No users should remain
+ EXPECT_TRUE(TestF->user_empty());
+}
+
} // end anonymous namespace
OpenPOWER on IntegriCloud