Replace OwningPtr<T> with std::unique_ptr<T>.
[oota-llvm.git] / unittests / IR / VerifierTest.cpp
index 2848cb82cf05ee58c7bf066fa5c6dfad116e9141..0a660a6b9135edd2180399952f0238c04fcef0be 100644 (file)
@@ -7,8 +7,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Analysis/Verifier.h"
-#include "llvm/ADT/OwningPtr.h"
+#include "llvm/IR/Verifier.h"
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/DerivedTypes.h"
 #include "llvm/IR/Function.h"
@@ -24,10 +23,11 @@ namespace {
 
 TEST(VerifierTest, Branch_i1) {
   LLVMContext &C = getGlobalContext();
+  Module M("M", C);
   FunctionType *FTy = FunctionType::get(Type::getVoidTy(C), /*isVarArg=*/false);
-  OwningPtr<Function> F(Function::Create(FTy, GlobalValue::ExternalLinkage));
-  BasicBlock *Entry = BasicBlock::Create(C, "entry", F.get());
-  BasicBlock *Exit = BasicBlock::Create(C, "exit", F.get());
+  Function *F = cast<Function>(M.getOrInsertFunction("foo", FTy));
+  BasicBlock *Entry = BasicBlock::Create(C, "entry", F);
+  BasicBlock *Exit = BasicBlock::Create(C, "exit", F);
   ReturnInst::Create(C, Exit);
 
   // To avoid triggering an assertion in BranchInst::Create, we first create
@@ -41,7 +41,7 @@ TEST(VerifierTest, Branch_i1) {
   Constant *Zero32 = ConstantInt::get(IntegerType::get(C, 32), 0);
   BI->setOperand(0, Zero32);
 
-  EXPECT_TRUE(verifyFunction(*F, ReturnStatusAction));
+  EXPECT_TRUE(verifyFunction(*F));
 }
 
 TEST(VerifierTest, AliasUnnamedAddr) {
@@ -57,8 +57,10 @@ TEST(VerifierTest, AliasUnnamedAddr) {
                                     "bar", Aliasee, &M);
   GA->setUnnamedAddr(true);
   std::string Error;
-  EXPECT_TRUE(verifyModule(M, ReturnStatusAction, &Error));
-  EXPECT_TRUE(StringRef(Error).startswith("Alias cannot have unnamed_addr"));
+  raw_string_ostream ErrorOS(Error);
+  EXPECT_TRUE(verifyModule(M, &ErrorOS));
+  EXPECT_TRUE(
+      StringRef(ErrorOS.str()).startswith("Alias cannot have unnamed_addr"));
 }
 
 TEST(VerifierTest, InvalidRetAttribute) {
@@ -71,9 +73,10 @@ TEST(VerifierTest, InvalidRetAttribute) {
                                    Attribute::UWTable));
 
   std::string Error;
-  EXPECT_TRUE(verifyModule(M, ReturnStatusAction, &Error));
-  EXPECT_TRUE(StringRef(Error).
-              startswith("Attribute 'uwtable' only applies to functions!"));
+  raw_string_ostream ErrorOS(Error);
+  EXPECT_TRUE(verifyModule(M, &ErrorOS));
+  EXPECT_TRUE(StringRef(ErrorOS.str()).startswith(
+      "Attribute 'uwtable' only applies to functions!"));
 }
 
 }