diff --git a/llvm/lib/Support/GraphWriter.cpp b/llvm/lib/Support/GraphWriter.cpp index 3910b12da89b..054df528474e 100644 --- a/llvm/lib/Support/GraphWriter.cpp +++ b/llvm/lib/Support/GraphWriter.cpp @@ -105,8 +105,7 @@ struct GraphSession { SmallVector parts; Names.split(parts, "|"); for (auto Name : parts) { - auto P = sys::findProgramByName(Name); - if (P) { + if (ErrorOr P = sys::findProgramByName(Name)) { ProgramPath = *P; return true; } diff --git a/llvm/tools/bugpoint/OptimizerDriver.cpp b/llvm/tools/bugpoint/OptimizerDriver.cpp index 752fc8950e5b..f197cc53926a 100644 --- a/llvm/tools/bugpoint/OptimizerDriver.cpp +++ b/llvm/tools/bugpoint/OptimizerDriver.cpp @@ -161,11 +161,10 @@ bool BugDriver::runPasses(Module *Program, std::string tool = OptCmd; if (OptCmd.empty()) { - auto Path = sys::findProgramByName("opt"); - if (!Path) - errs() << Path.getError().message() << "\n"; - else + if (ErrorOr Path = sys::findProgramByName("opt")) tool = *Path; + else + errs() << Path.getError().message() << "\n"; } if (tool.empty()) { errs() << "Cannot find `opt' in PATH!\n"; @@ -174,11 +173,10 @@ bool BugDriver::runPasses(Module *Program, std::string Prog; if (UseValgrind) { - auto Path = sys::findProgramByName("valgrind"); - if (!Path) - errs() << Path.getError().message() << "\n"; - else + if (ErrorOr Path = sys::findProgramByName("valgrind")) Prog = *Path; + else + errs() << Path.getError().message() << "\n"; } else Prog = tool; if (Prog.empty()) {