From 78f1087b01e33d5da77febd8cf7bd3f4d4f96cb1 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 1 Feb 2002 05:09:35 +0000 Subject: Catch the parse exception if bad input is provided. Much better than an abort llvm-svn: 1631 --- llvm/tools/analyze/analyze.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'llvm/tools/analyze/analyze.cpp') diff --git a/llvm/tools/analyze/analyze.cpp b/llvm/tools/analyze/analyze.cpp index 3bc2ee9e22e..112bfcc04b4 100644 --- a/llvm/tools/analyze/analyze.cpp +++ b/llvm/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; } -- cgit v1.2.3