diff options
author | Michael J. Spencer <bigcheesegs@gmail.com> | 2014-11-04 01:29:59 +0000 |
---|---|---|
committer | Michael J. Spencer <bigcheesegs@gmail.com> | 2014-11-04 01:29:59 +0000 |
commit | f9074b5a91d93f786a80039a2f4ba48bfcd269c2 (patch) | |
tree | 9fe851a1dc00aaaf39e6b744e3aedf6e337bff9a /llvm/tools/bugpoint/OptimizerDriver.cpp | |
parent | 65ffd92f07799710f2501f8c223e1df4f379b08b (diff) | |
download | bcm5719-llvm-f9074b5a91d93f786a80039a2f4ba48bfcd269c2.tar.gz bcm5719-llvm-f9074b5a91d93f786a80039a2f4ba48bfcd269c2.zip |
Use findProgramByName.
llvm-svn: 221221
Diffstat (limited to 'llvm/tools/bugpoint/OptimizerDriver.cpp')
-rw-r--r-- | llvm/tools/bugpoint/OptimizerDriver.cpp | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/llvm/tools/bugpoint/OptimizerDriver.cpp b/llvm/tools/bugpoint/OptimizerDriver.cpp index 3854aa1e5bf..752fc8950e5 100644 --- a/llvm/tools/bugpoint/OptimizerDriver.cpp +++ b/llvm/tools/bugpoint/OptimizerDriver.cpp @@ -159,12 +159,33 @@ bool BugDriver::runPasses(Module *Program, return 1; } - std::string tool = OptCmd.empty()? sys::FindProgramByName("opt") : OptCmd; + std::string tool = OptCmd; + if (OptCmd.empty()) { + auto Path = sys::findProgramByName("opt"); + if (!Path) + errs() << Path.getError().message() << "\n"; + else + tool = *Path; + } if (tool.empty()) { errs() << "Cannot find `opt' in PATH!\n"; return 1; } + std::string Prog; + if (UseValgrind) { + auto Path = sys::findProgramByName("valgrind"); + if (!Path) + errs() << Path.getError().message() << "\n"; + else + Prog = *Path; + } else + Prog = tool; + if (Prog.empty()) { + errs() << "Cannot find `valgrind' in PATH!\n"; + return 1; + } + // Ok, everything that could go wrong before running opt is done. InFile.keep(); @@ -204,12 +225,6 @@ bool BugDriver::runPasses(Module *Program, errs() << "\n"; ); - std::string Prog; - if (UseValgrind) - Prog = sys::FindProgramByName("valgrind"); - else - Prog = tool; - // Redirect stdout and stderr to nowhere if SilencePasses is given StringRef Nowhere; const StringRef *Redirects[3] = {nullptr, &Nowhere, &Nowhere}; |