diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2004-12-30 05:36:08 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2004-12-30 05:36:08 +0000 |
commit | 996ec72d48e86d16dc14b1c014be4c13d2f1f686 (patch) | |
tree | 388b95aebb8676f1fcbf8447e60a06c6223ed613 /llvm/tools/llvm-as/llvm-as.cpp | |
parent | a6d9c1415ce032235324f70cd074a4bad4c1cb86 (diff) | |
download | bcm5719-llvm-996ec72d48e86d16dc14b1c014be4c13d2f1f686.tar.gz bcm5719-llvm-996ec72d48e86d16dc14b1c014be4c13d2f1f686.zip |
For PR351:
* Place a try/catch block around the entire tool to Make sure std::string
exceptions are caught and printed before exiting the tool.
* Make sure we catch unhandled exceptions at the top level so that we don't
abort with a useless message but indicate than an unhandled exception was
generated.
llvm-svn: 19192
Diffstat (limited to 'llvm/tools/llvm-as/llvm-as.cpp')
-rw-r--r-- | llvm/tools/llvm-as/llvm-as.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/llvm/tools/llvm-as/llvm-as.cpp b/llvm/tools/llvm-as/llvm-as.cpp index 7a777a4bab4..804490a77ea 100644 --- a/llvm/tools/llvm-as/llvm-as.cpp +++ b/llvm/tools/llvm-as/llvm-as.cpp @@ -52,6 +52,7 @@ int main(int argc, char **argv) { cl::ParseCommandLineOptions(argc, argv, " llvm .ll -> .bc assembler\n"); sys::PrintStackTraceOnErrorSignal(); + int exitCode = 0; std::ostream *Out = 0; try { // Parse the file now... @@ -126,10 +127,16 @@ int main(int argc, char **argv) { WriteBytecodeToFile(M.get(), *Out, !NoCompress); } catch (const ParseException &E) { std::cerr << argv[0] << ": " << E.getMessage() << "\n"; - return 1; + exitCode = 1; + } catch (const std::string& msg) { + std::cerr << argv[0] << ": " << msg << "\n"; + exitCode = 1; + } catch (...) { + std::cerr << argv[0] << ": Unexpected unknown exception occurred.\n"; + exitCode = 1; } if (Out != &std::cout) delete Out; - return 0; + return exitCode; } |