diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2006-08-21 02:04:43 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2006-08-21 02:04:43 +0000 |
commit | 023fcf977660e686e04f5bef0e2a7321db47df7e (patch) | |
tree | 21e3b0af2281c2ede5c731f98d5c6cb22dd135a6 | |
parent | 422fa625d9bdc37ebba9fc8ce16f141ffa80fc58 (diff) | |
download | external_llvm-023fcf977660e686e04f5bef0e2a7321db47df7e.zip external_llvm-023fcf977660e686e04f5bef0e2a7321db47df7e.tar.gz external_llvm-023fcf977660e686e04f5bef0e2a7321db47df7e.tar.bz2 |
For PR797:
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
-rw-r--r-- | include/llvm/System/Program.h | 3 | ||||
-rw-r--r-- | lib/Support/CommandLine.cpp | 2 | ||||
-rw-r--r-- | lib/Support/GraphWriter.cpp | 4 | ||||
-rw-r--r-- | lib/System/Unix/Program.inc | 2 | ||||
-rw-r--r-- | tools/bugpoint/OptimizerDriver.cpp | 2 | ||||
-rw-r--r-- | tools/bugpoint/ToolRunner.cpp | 2 | ||||
-rw-r--r-- | tools/lto/lto.cpp | 2 | ||||
-rw-r--r-- | tools/opt/opt.cpp | 3 |
8 files changed, 12 insertions, 8 deletions
diff --git a/include/llvm/System/Program.h b/include/llvm/System/Program.h index 92534de..2b5b488 100644 --- a/include/llvm/System/Program.h +++ b/include/llvm/System/Program.h @@ -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 diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index f7fbef6..0699401 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -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. diff --git a/lib/Support/GraphWriter.cpp b/lib/Support/GraphWriter.cpp index f3255d8..152261f 100644 --- a/lib/Support/GraphWriter.cpp +++ b/lib/Support/GraphWriter.cpp @@ -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 diff --git a/lib/System/Unix/Program.inc b/lib/System/Unix/Program.inc index 1bf1bc9..c3d5d5c 100644 --- a/lib/System/Unix/Program.inc +++ b/lib/System/Unix/Program.inc @@ -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. diff --git a/tools/bugpoint/OptimizerDriver.cpp b/tools/bugpoint/OptimizerDriver.cpp index df4f470..0ac514b 100644 --- a/tools/bugpoint/OptimizerDriver.cpp +++ b/tools/bugpoint/OptimizerDriver.cpp @@ -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) diff --git a/tools/bugpoint/ToolRunner.cpp b/tools/bugpoint/ToolRunner.cpp index 94cccf2..067bf65 100644 --- a/tools/bugpoint/ToolRunner.cpp +++ b/tools/bugpoint/ToolRunner.cpp @@ -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()); diff --git a/tools/lto/lto.cpp b/tools/lto/lto.cpp index 162bac9..570558a 100644 --- a/tools/lto/lto.cpp +++ b/tools/lto/lto.cpp @@ -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(); diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp index 18b4a8c..6d3b3b6 100644 --- a/tools/opt/opt.cpp +++ b/tools/opt/opt.cpp @@ -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> |