[llvm] r256938 - Add unittest for new CanReplace flag on MDNodes
Teresa Johnson via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 6 07:02:41 PST 2016
Author: tejohnson
Date: Wed Jan 6 09:02:40 2016
New Revision: 256938
URL: http://llvm.org/viewvc/llvm-project?rev=256938&view=rev
Log:
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.
Modified:
llvm/trunk/unittests/IR/MetadataTest.cpp
Modified: llvm/trunk/unittests/IR/MetadataTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/IR/MetadataTest.cpp?rev=256938&r1=256937&r2=256938&view=diff
==============================================================================
--- llvm/trunk/unittests/IR/MetadataTest.cpp (original)
+++ llvm/trunk/unittests/IR/MetadataTest.cpp Wed Jan 6 09:02:40 2016
@@ -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);
More information about the llvm-commits
mailing list