llvm.org GIT mirror llvm / 023d97d
llvm/unittests: Use OwningPtr to fix --vg-leak. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173240 91177308-0d34-0410-b5e6-96231b3b80d8 NAKAMURA Takumi 6 years ago
4 changed file(s) with 11 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
4444 }
4545
4646 static void writeModuleToBuffer(SmallVectorImpl &Buffer) {
47 Module *Mod = makeLLVMModule();
47 OwningPtr Mod(makeLLVMModule());
4848 raw_svector_ostream OS(Buffer);
49 WriteBitcodeToFile(Mod, OS);
49 WriteBitcodeToFile(Mod.get(), OS);
5050 }
5151
5252 TEST(BitReaderTest, MaterializeFunctionsForBlockAddr) { // PR11677
5454 writeModuleToBuffer(Mem);
5555 MemoryBuffer *Buffer = MemoryBuffer::getMemBuffer(Mem.str(), "test", false);
5656 std::string errMsg;
57 Module *m = getLazyBitcodeModule(Buffer, getGlobalContext(), &errMsg);
57 OwningPtr m(getLazyBitcodeModule(Buffer, getGlobalContext(), &errMsg));
5858 PassManager passes;
5959 passes.add(createVerifierPass());
6060 passes.run(*m);
161161 }
162162
163163 TEST(ConstantsTest, AsInstructionsTest) {
164 Module *M = new Module("MyModule", getGlobalContext());
164 OwningPtr M(new Module("MyModule", getGlobalContext()));
165165
166166 Type *Int64Ty = Type::getInt64Ty(getGlobalContext());
167167 Type *Int32Ty = Type::getInt32Ty(getGlobalContext());
190190
191191 TEST(DominatorTree, Unreachable) {
192192 DPass *P = new DPass();
193 Module *M = makeLLVMModule(P);
193 OwningPtr M(makeLLVMModule(P));
194194 PassManager Passes;
195195 Passes.add(P);
196196 Passes.run(*M);
66 //
77 //===----------------------------------------------------------------------===//
88
9 #include "llvm/ADT/OwningPtr.h"
910 #include "llvm/Option/Arg.h"
1011 #include "llvm/Option/ArgList.h"
1112 #include "llvm/Option/Option.h"
5960 TEST(Support, OptionParsing) {
6061 TestOptTable T;
6162 unsigned MAI, MAC;
62 InputArgList *AL = T.ParseArgs(Args, Args + (sizeof(Args) / sizeof(Args[0])), MAI, MAC);
63 OwningPtr
64 AL(T.ParseArgs(Args,
65 Args + (sizeof(Args) / sizeof(Args[0])),
66 MAI,
67 MAC));
6368
6469 // Check they all exist.
6570 EXPECT_TRUE(AL->hasArg(OPT_A));