diff options
author | Chris Lattner <sabre@nondot.org> | 2002-02-01 05:09:35 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-02-01 05:09:35 +0000 |
commit | 7d922623e3e108cecfda6ca282acd9bcb1e0776d (patch) | |
tree | 5ba9f0ac5a10046e319df7f2548163908b989fa2 /tools/analyze | |
parent | 07ae06d18e8a3482fcd956307e09baa4bdaf2ec4 (diff) | |
download | llvm-7d922623e3e108cecfda6ca282acd9bcb1e0776d.tar.gz llvm-7d922623e3e108cecfda6ca282acd9bcb1e0776d.tar.bz2 llvm-7d922623e3e108cecfda6ca282acd9bcb1e0776d.tar.xz |
Catch the parse exception if bad input is provided. Much better than an abort
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1631 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/analyze')
-rw-r--r-- | tools/analyze/analyze.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/tools/analyze/analyze.cpp b/tools/analyze/analyze.cpp index 3bc2ee9e22..112bfcc04b 100644 --- a/tools/analyze/analyze.cpp +++ b/tools/analyze/analyze.cpp @@ -259,9 +259,14 @@ struct { int main(int argc, char **argv) { cl::ParseCommandLineOptions(argc, argv, " llvm analysis printer tool\n"); - CurrentModule = ParseBytecodeFile(InputFilename); - if (!CurrentModule && !(CurrentModule = ParseAssemblyFile(InputFilename))) { - std::cerr << "Input file didn't read correctly.\n"; + try { + CurrentModule = ParseBytecodeFile(InputFilename); + if (!CurrentModule && !(CurrentModule = ParseAssemblyFile(InputFilename))){ + std::cerr << "Input file didn't read correctly.\n"; + return 1; + } + } catch (const ParseException &E) { + cerr << E.getMessage() << endl; return 1; } |