For PR797:
Adjust usage of the ExecuteAndWait function to use the last argument which
is the ErrMsg string. This is necessitated because this function no longer
throws exceptions on error.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29791 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/bugpoint/OptimizerDriver.cpp b/tools/bugpoint/OptimizerDriver.cpp
index 0ac514b..4311200 100644
--- a/tools/bugpoint/OptimizerDriver.cpp
+++ b/tools/bugpoint/OptimizerDriver.cpp
@@ -179,7 +179,8 @@
   args[n++] = 0;
 
   sys::Path prog(sys::Program::FindProgramByName(ToolName));
-  int result = sys::Program::ExecuteAndWait(prog,args,0,0,Timeout);
+  std::string ErrMsg;
+  int result = sys::Program::ExecuteAndWait(prog,args,0,0,Timeout,&ErrMsg);
 
   // If we are supposed to delete the bytecode file or if the passes crashed,
   // remove it now.  This may fail if the file was never created, but that's ok.
@@ -194,10 +195,12 @@
       std::cout << "Success!\n";
     else if (result > 0)
       std::cout << "Exited with error code '" << result << "'\n";
-    else if (result == -9999)
-      std::cout << "Program not executable\n";
-    else if (result < 0)
-      std::cout << "Crashed with signal #" << abs(result) << "\n";
+    else if (result < 0) {
+      if (result == -1)
+        std::cout << "Execute failed: " << ErrMsg << "\n";
+      else
+        std::cout << "Crashed with signal #" << abs(result) << "\n";
+    }
     if (result & 0x01000000)
       std::cout << "Dumped core\n";
   }
diff --git a/tools/bugpoint/ToolRunner.cpp b/tools/bugpoint/ToolRunner.cpp
index 067bf65..8712baf 100644
--- a/tools/bugpoint/ToolRunner.cpp
+++ b/tools/bugpoint/ToolRunner.cpp
@@ -55,7 +55,7 @@
   sys::Path ErrorFilename("error_messages");
   ErrorFilename.makeUnique();
   RunProgramWithTimeout(ProgPath, Args, sys::Path(""), ErrorFilename,
-                        ErrorFilename); // FIXME: check return code
+                        ErrorFilename); // FIXME: check return code ?
 
   // Print out the error messages generated by GCC if possible...
   std::ifstream ErrorFile(ErrorFilename.c_str());