Check for (unlikely) errors from FindExecutable.
authorDan Gohman <gohman@apple.com>
Fri, 29 Oct 2010 16:18:26 +0000 (16:18 +0000)
committerDan Gohman <gohman@apple.com>
Fri, 29 Oct 2010 16:18:26 +0000 (16:18 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117658 91177308-0d34-0410-b5e6-96231b3b80d8

tools/bugpoint/OptimizerDriver.cpp

index 131bc997b16ba6585ac3b51faad4c2518e847377..178b1ff3ed1619c5734da119a002b89c110535f4 100644 (file)
@@ -143,11 +143,18 @@ bool BugDriver::runPasses(Module *Program,
     InFile.os().clear_error();
     return 1;
   }
+
+  sys::Path tool = FindExecutable("opt", getToolName(), (void*)"opt");
+  if (tool.empty()) {
+    errs() << "Cannot find `opt' in executable directory!\n";
+    return 1;
+  }
+
+  // Ok, everything that could go wrong before running opt is done.
   InFile.keep();
 
   // setup the child process' arguments
   SmallVector<const char*, 8> Args;
-  sys::Path tool = FindExecutable("opt", getToolName(), (void*)"opt");
   std::string Opt = tool.str();
   if (UseValgrind) {
     Args.push_back("valgrind");