summaryrefslogtreecommitdiff
path: root/tools/llvm-as
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2004-12-30 05:36:08 +0000
committerReid Spencer <rspencer@reidspencer.com>2004-12-30 05:36:08 +0000
commit1ef8bdaedbd98bee35a573b8bc87149f2182cb5e (patch)
treedc21da7903997dfbcf6061f19b35a2a522c740b9 /tools/llvm-as
parentc18671cdcd53df08cbeff7ecf443475f61971b9d (diff)
downloadllvm-1ef8bdaedbd98bee35a573b8bc87149f2182cb5e.tar.gz
llvm-1ef8bdaedbd98bee35a573b8bc87149f2182cb5e.tar.bz2
llvm-1ef8bdaedbd98bee35a573b8bc87149f2182cb5e.tar.xz
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19192 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-as')
-rw-r--r--tools/llvm-as/llvm-as.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/tools/llvm-as/llvm-as.cpp b/tools/llvm-as/llvm-as.cpp
index 7a777a4bab..804490a77e 100644
--- a/tools/llvm-as/llvm-as.cpp
+++ b/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;
}