diff options
Diffstat (limited to 'unittests/VMCore')
-rw-r--r-- | unittests/VMCore/InstructionsTest.cpp | 41 | ||||
-rw-r--r-- | unittests/VMCore/MetadataTest.cpp | 4 | ||||
-rw-r--r-- | unittests/VMCore/PassManagerTest.cpp | 4 | ||||
-rw-r--r-- | unittests/VMCore/VerifierTest.cpp | 7 |
4 files changed, 49 insertions, 7 deletions
diff --git a/unittests/VMCore/InstructionsTest.cpp b/unittests/VMCore/InstructionsTest.cpp new file mode 100644 index 000000000000..2d98cad27fb8 --- /dev/null +++ b/unittests/VMCore/InstructionsTest.cpp @@ -0,0 +1,41 @@ +//===- llvm/unittest/VMCore/InstructionsTest.cpp - Instructions unit tests ===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "llvm/Instructions.h" +#include "llvm/DerivedTypes.h" +#include "llvm/LLVMContext.h" +#include "gtest/gtest.h" + +namespace llvm { +namespace { + +TEST(InstructionsTest, ReturnInst) { + LLVMContext &C(getGlobalContext()); + + // test for PR6589 + const ReturnInst* r0 = ReturnInst::Create(C); + EXPECT_EQ(r0->op_begin(), r0->op_end()); + + const IntegerType* Int1 = IntegerType::get(C, 1); + Constant* One = ConstantInt::get(Int1, 1, true); + const ReturnInst* r1 = ReturnInst::Create(C, One); + User::const_op_iterator b(r1->op_begin()); + EXPECT_NE(b, r1->op_end()); + EXPECT_EQ(*b, One); + EXPECT_EQ(r1->getOperand(0), One); + ++b; + EXPECT_EQ(b, r1->op_end()); + + // clean up + delete r0; + delete r1; +} + +} // end anonymous namespace +} // end namespace llvm diff --git a/unittests/VMCore/MetadataTest.cpp b/unittests/VMCore/MetadataTest.cpp index 13bf27e5d8fa..04db486cd871 100644 --- a/unittests/VMCore/MetadataTest.cpp +++ b/unittests/VMCore/MetadataTest.cpp @@ -132,9 +132,9 @@ TEST(NamedMDNodeTest, Search) { MDNode *Nodes[2] = { n, n2 }; - Module *M = new Module("MyModule", Context); + Module M("MyModule", Context); const char *Name = "llvm.NMD1"; - NamedMDNode *NMD = NamedMDNode::Create(Context, Name, &Nodes[0], 2, M); + NamedMDNode *NMD = NamedMDNode::Create(Context, Name, &Nodes[0], 2, &M); std::string Str; raw_string_ostream oss(Str); NMD->print(oss); diff --git a/unittests/VMCore/PassManagerTest.cpp b/unittests/VMCore/PassManagerTest.cpp index cb8f9ebb939b..bc21298ef200 100644 --- a/unittests/VMCore/PassManagerTest.cpp +++ b/unittests/VMCore/PassManagerTest.cpp @@ -324,10 +324,10 @@ namespace llvm { template<typename T> void MemoryTestHelper(int run) { - Module *M = makeLLVMModule(); + OwningPtr<Module> M(makeLLVMModule()); T *P = new T(); PassManager Passes; - Passes.add(new TargetData(M)); + Passes.add(new TargetData(M.get())); Passes.add(P); Passes.run(*M); T::finishedOK(run); diff --git a/unittests/VMCore/VerifierTest.cpp b/unittests/VMCore/VerifierTest.cpp index c8838c5276db..1173b2d18f76 100644 --- a/unittests/VMCore/VerifierTest.cpp +++ b/unittests/VMCore/VerifierTest.cpp @@ -12,6 +12,7 @@ #include "llvm/Function.h" #include "llvm/Instructions.h" #include "llvm/LLVMContext.h" +#include "llvm/ADT/OwningPtr.h" #include "llvm/Analysis/Verifier.h" #include "gtest/gtest.h" @@ -21,9 +22,9 @@ namespace { TEST(VerifierTest, Branch_i1) { LLVMContext &C = getGlobalContext(); FunctionType *FTy = FunctionType::get(Type::getVoidTy(C), /*isVarArg=*/false); - Function *F = Function::Create(FTy, GlobalValue::ExternalLinkage); - BasicBlock *Entry = BasicBlock::Create(C, "entry", F); - BasicBlock *Exit = BasicBlock::Create(C, "exit", F); + OwningPtr<Function> F(Function::Create(FTy, GlobalValue::ExternalLinkage)); + BasicBlock *Entry = BasicBlock::Create(C, "entry", F.get()); + BasicBlock *Exit = BasicBlock::Create(C, "exit", F.get()); ReturnInst::Create(C, Exit); // To avoid triggering an assertion in BranchInst::Create, we first create |