For PR797:
authorReid Spencer <rspencer@reidspencer.com>
Mon, 21 Aug 2006 02:04:43 +0000 (02:04 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Mon, 21 Aug 2006 02:04:43 +0000 (02:04 +0000)
Make sys::Program::ExecuteAndWait not throw exceptions and update any
affected code. It now return -9999 to signal that the program couldn't be
executed. Only one case (in bugpoint) actually examines the result code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29785 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/System/Program.h
lib/Support/CommandLine.cpp
lib/Support/GraphWriter.cpp
lib/System/Unix/Program.inc
tools/bugpoint/OptimizerDriver.cpp
tools/bugpoint/ToolRunner.cpp
tools/lto/lto.cpp
tools/opt/opt.cpp

index 92534de4052fe4b2d9030166836c5f64a3a12d39..2b5b488ffbb04b3867f1b277acad68580fd79fda 100644 (file)
@@ -49,7 +49,8 @@ namespace sys {
       /// called then a std::string is thrown.
       /// @returns an integer result code indicating the status of the program.
       /// A zero or positive value indicates the result code of the program. A
-      /// negative value is the signal number on which it terminated.
+      /// negative value is the signal number on which it terminated. A value of
+      /// -9999 indicates the program could not be executed.
       /// @throws std::string on a variety of error conditions or if the invoked
       /// program aborted abnormally.
       /// @see FindProgrambyName
index f7fbef6b72862b83467ed4fa2ae94107ea786065..069940162b4a1ee69866badf0533c2e1e395ab75 100644 (file)
@@ -31,7 +31,7 @@ using namespace llvm;
 using namespace cl;
 
 // Globals for name and overview of program
-static const char *ProgramName = "<unknown>";
+static const char *ProgramName = "<premain>";
 static const char *ProgramOverview = 0;
 
 // This collects additional help to be printed.
index f3255d815c6c7659934069dba8c1419686c629a8..152261fbac62f36c9c1049d9e8165ec6334daa1f 100644 (file)
@@ -59,7 +59,9 @@ void llvm::DisplayGraph(const sys::Path &Filename) {
     args.push_back(PSFilename.c_str());
     args.push_back(0);
     
-    sys::Program::ExecuteAndWait(gv, &args[0]);
+    if (sys::Program::ExecuteAndWait(gv, &args[0])) {
+      std::cerr << "Error viewing graph: 'gv' not in path?\n";
+    }
   }
   PSFilename.eraseFromDisk();
 #elif HAVE_DOTTY
index 1bf1bc91f81c32f9996f978bd9704e4cc0bcdef6..c3d5d5ce6e5ec31a66432f0355be50a3c2f1c6c5 100644 (file)
@@ -108,7 +108,7 @@ Program::ExecuteAndWait(const Path& path,
                         unsigned secondsToWait
 ) {
   if (!path.canExecute())
-    throw path.toString() + " is not executable"; 
+    return -9999;
 
 #ifdef HAVE_SYS_WAIT_H
   // Create a child process.
index df4f470da2b80cbad8277eac78f8f77e5e0ccd64..0ac514bbefede4273b541927f2f0e743dc479843 100644 (file)
@@ -194,6 +194,8 @@ bool BugDriver::runPasses(const std::vector<const PassInfo*> &Passes,
       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";
     if (result & 0x01000000)
index 94cccf277412cb252b4df047d60b7af633a7a99b..067bf658c7329557fffe3654d90d64cc70c2b800 100644 (file)
@@ -55,7 +55,7 @@ static void ProcessFailure(sys::Path ProgPath, const char** Args) {
   sys::Path ErrorFilename("error_messages");
   ErrorFilename.makeUnique();
   RunProgramWithTimeout(ProgPath, Args, sys::Path(""), ErrorFilename,
-                        ErrorFilename);
+                        ErrorFilename); // FIXME: check return code
 
   // Print out the error messages generated by GCC if possible...
   std::ifstream ErrorFile(ErrorFilename.c_str());
index 162bac9e617efefca004fb92c9495dbca98e054f..570558a62b4c08768e72ebbaddfd086371904ea6 100644 (file)
@@ -334,7 +334,7 @@ LinkTimeOptimizer::optimizeModules(const std::string &OutputFilename,
   args.push_back(tmpAsmFilePath.c_str());
   args.push_back(0);
 
-  int R1 = sys::Program::ExecuteAndWait(gcc, &args[0], 0, 0, 1);
+  sys::Program::ExecuteAndWait(gcc, &args[0], 0, 0, 1);
 
   tmpAsmFilePath.eraseFromDisk();
 
index 18b4a8c15742d2333362cb43c4e9914fd61eb11f..6d3b3b648aadc2a3c039f7593a6a971b4c9fc1ac 100644 (file)
@@ -26,8 +26,7 @@
 #include "llvm/Support/PluginLoader.h"
 #include "llvm/Support/SystemUtils.h"
 #include "llvm/Support/Timer.h"
-#include "llvm/Analysis/LinkAllAnalyses.h"
-#include "llvm/Transforms/LinkAllPasses.h"
+#include "llvm/LinkAllPasses.h"
 #include "llvm/LinkAllVMCore.h"
 #include <fstream>
 #include <memory>