summaryrefslogtreecommitdiffstats
path: root/llvm/tools/bugpoint/BugDriver.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-08-26 17:19:03 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-08-26 17:19:03 +0000
commit28b351a56dce9c633e97cdf2762b23b136642c94 (patch)
tree918591212c345b3e2957abab05472c57d59a61d5 /llvm/tools/bugpoint/BugDriver.cpp
parentd71a5c727716e542faf2494cf16fe285883d7cfc (diff)
downloadbcm5719-llvm-28b351a56dce9c633e97cdf2762b23b136642c94.tar.gz
bcm5719-llvm-28b351a56dce9c633e97cdf2762b23b136642c94.zip
Return a std::unique_ptr from parseInputFile and propagate. NFC.
The memory management in BugPoint is fairly convoluted, so this just unwraps one layer by changing the return type of functions that always return owned Modules. llvm-svn: 216464
Diffstat (limited to 'llvm/tools/bugpoint/BugDriver.cpp')
-rw-r--r--llvm/tools/bugpoint/BugDriver.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/llvm/tools/bugpoint/BugDriver.cpp b/llvm/tools/bugpoint/BugDriver.cpp
index cecccbe0f0e..872f1ba13b9 100644
--- a/llvm/tools/bugpoint/BugDriver.cpp
+++ b/llvm/tools/bugpoint/BugDriver.cpp
@@ -82,14 +82,10 @@ BugDriver::~BugDriver() {
delete gcc;
}
-
-/// ParseInputFile - Given a bitcode or assembly input filename, parse and
-/// return it, or return null if not possible.
-///
-Module *llvm::ParseInputFile(const std::string &Filename,
- LLVMContext& Ctxt) {
+std::unique_ptr<Module> llvm::parseInputFile(StringRef Filename,
+ LLVMContext &Ctxt) {
SMDiagnostic Err;
- Module *Result = ParseIRFile(Filename, Err, Ctxt);
+ std::unique_ptr<Module> Result (ParseIRFile(Filename, Err, Ctxt));
if (!Result)
Err.print("bugpoint", errs());
@@ -120,13 +116,13 @@ bool BugDriver::addSources(const std::vector<std::string> &Filenames) {
assert(!Filenames.empty() && "Must specify at least on input filename!");
// Load the first input file.
- Program = ParseInputFile(Filenames[0], Context);
+ Program = parseInputFile(Filenames[0], Context).release();
if (!Program) return true;
outs() << "Read input file : '" << Filenames[0] << "'\n";
for (unsigned i = 1, e = Filenames.size(); i != e; ++i) {
- std::unique_ptr<Module> M(ParseInputFile(Filenames[i], Context));
+ std::unique_ptr<Module> M = parseInputFile(Filenames[i], Context);
if (!M.get()) return true;
outs() << "Linking in input file: '" << Filenames[i] << "'\n";
OpenPOWER on IntegriCloud