From: Teresa Johnson Date: Wed, 6 Jan 2016 15:02:40 +0000 (+0000) Subject: Add unittest for new CanReplace flag on MDNodes X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=70e34d75d841f9a233effaae4868bf04285acd60;p=oota-llvm.git Add unittest for new CanReplace flag on MDNodes This adds a unittest for the support added in r256648 to add a flag that can be used to prevent RAUW on temporary metadata used as a map key. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256938 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/unittests/IR/MetadataTest.cpp b/unittests/IR/MetadataTest.cpp index 257ab7204c6..a745b235a38 100644 --- a/unittests/IR/MetadataTest.cpp +++ b/unittests/IR/MetadataTest.cpp @@ -494,6 +494,20 @@ TEST_F(MDNodeTest, isTemporary) { EXPECT_TRUE(T->isTemporary()); } +#if defined(GTEST_HAS_DEATH_TEST) && !defined(NDEBUG) + +TEST_F(MDNodeTest, deathOnNoReplaceTemporaryRAUW) { + auto Temp = MDNode::getTemporary(Context, None); + Temp->setCanReplace(false); + EXPECT_DEATH(Temp->replaceAllUsesWith(nullptr), + "Attempted to replace Metadata marked for no replacement"); + Temp->setCanReplace(true); + // Remove the references to Temp; required for teardown. + Temp->replaceAllUsesWith(nullptr); +} + +#endif + TEST_F(MDNodeTest, getDistinctWithUnresolvedOperands) { // temporary !{} auto Temp = MDTuple::getTemporary(Context, None);