aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorJeffrey Yasskin <jyasskin@google.com>2010-05-11 23:25:16 +0000
committerJeffrey Yasskin <jyasskin@google.com>2010-05-11 23:25:16 +0000
commit6865f29fe71559a18d7f2ff0bc4f67c5fc1d000e (patch)
tree78ce9a99c34d386545924b4058de291eacb49df4 /tools
parent210e2afcc74e8ce5102d13939b23040fafa71c09 (diff)
downloadexternal_llvm-6865f29fe71559a18d7f2ff0bc4f67c5fc1d000e.zip
external_llvm-6865f29fe71559a18d7f2ff0bc4f67c5fc1d000e.tar.gz
external_llvm-6865f29fe71559a18d7f2ff0bc4f67c5fc1d000e.tar.bz2
Fix PR6951 by fixing Module leaks in bugpoint.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103523 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/bugpoint/Miscompilation.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/tools/bugpoint/Miscompilation.cpp b/tools/bugpoint/Miscompilation.cpp
index 45bb745..71484a2 100644
--- a/tools/bugpoint/Miscompilation.cpp
+++ b/tools/bugpoint/Miscompilation.cpp
@@ -126,7 +126,8 @@ ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
// Ok, so now we know that the prefix passes work, try running the suffix
// passes on the result of the prefix passes.
//
- Module *PrefixOutput = ParseInputFile(BitcodeResult, BD.getContext());
+ OwningPtr<Module> PrefixOutput(ParseInputFile(BitcodeResult,
+ BD.getContext()));
if (PrefixOutput == 0) {
errs() << BD.getToolName() << ": Error reading bitcode file '"
<< BitcodeResult << "'!\n";
@@ -142,7 +143,7 @@ ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
<< "' passes compile correctly after the '"
<< getPassesString(Prefix) << "' passes: ";
- Module *OriginalInput = BD.swapProgramIn(PrefixOutput);
+ OwningPtr<Module> OriginalInput(BD.swapProgramIn(PrefixOutput.take()));
if (BD.runPasses(Suffix, BitcodeResult, false/*delete*/, true/*quiet*/)) {
errs() << " Error running this sequence of passes"
<< " on the input program!\n";
@@ -157,13 +158,13 @@ ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
return InternalError;
if (Diff) {
outs() << " nope.\n";
- delete OriginalInput; // We pruned down the original input...
return KeepSuffix;
}
// Otherwise, we must not be running the bad pass anymore.
outs() << " yup.\n"; // No miscompilation!
- delete BD.swapProgramIn(OriginalInput); // Restore orig program & free test
+ // Restore orig program & free test.
+ delete BD.swapProgramIn(OriginalInput.take());
return NoFailure;
}
@@ -222,15 +223,14 @@ static bool TestMergedProgram(BugDriver &BD, Module *M1, Module *M2,
}
delete M2; // We are done with this module.
- Module *OldProgram = BD.swapProgramIn(M1);
+ OwningPtr<Module> OldProgram(BD.swapProgramIn(M1));
// Execute the program. If it does not match the expected output, we must
// return true.
bool Broken = BD.diffProgram("", "", false, &Error);
if (!Error.empty()) {
// Delete the linked module & restore the original
- BD.swapProgramIn(OldProgram);
- delete M1;
+ delete BD.swapProgramIn(OldProgram.take());
}
return Broken;
}