Fix r213824 on windows
[oota-llvm.git] / unittests / IR / ConstantsTest.cpp
index fee38b891de427b05d3327a635ff245ce6b36048..0cd854998286a529a343d3091d0a22814e796861 100644 (file)
@@ -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