aboutsummaryrefslogtreecommitdiff
path: root/unittests/IR/ConstantsTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'unittests/IR/ConstantsTest.cpp')
-rw-r--r--unittests/IR/ConstantsTest.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/unittests/IR/ConstantsTest.cpp b/unittests/IR/ConstantsTest.cpp
index fee38b891de4..0cd854998286 100644
--- a/unittests/IR/ConstantsTest.cpp
+++ b/unittests/IR/ConstantsTest.cpp
@@ -162,7 +162,7 @@ TEST(ConstantsTest, PointerCast) {
}
TEST(ConstantsTest, AsInstructionsTest) {
- OwningPtr<Module> M(new Module("MyModule", getGlobalContext()));
+ std::unique_ptr<Module> M(new Module("MyModule", getGlobalContext()));
Type *Int64Ty = Type::getInt64Ty(getGlobalContext());
Type *Int32Ty = Type::getInt32Ty(getGlobalContext());
@@ -254,6 +254,24 @@ TEST(ConstantsTest, AsInstructionsTest) {
P6STR ", i32 1");
}
+#ifdef GTEST_HAS_DEATH_TEST
+#ifndef NDEBUG
+TEST(ConstantsTest, ReplaceWithConstantTest) {
+ std::unique_ptr<Module> M(new Module("MyModule", getGlobalContext()));
+
+ Type *Int32Ty = Type::getInt32Ty(getGlobalContext());
+ Constant *One = ConstantInt::get(Int32Ty, 1);
+
+ Constant *Global =
+ M->getOrInsertGlobal("dummy", PointerType::getUnqual(Int32Ty));
+ Constant *GEP = ConstantExpr::getGetElementPtr(Global, One);
+ EXPECT_DEATH(Global->replaceAllUsesWith(GEP),
+ "this->replaceAllUsesWith\\(expr\\(this\\)\\) is NOT valid!");
+}
+
+#endif
+#endif
+
#undef CHECK
} // end anonymous namespace