From: Chris Lattner Date: Fri, 1 Feb 2002 05:09:35 +0000 (+0000) Subject: Catch the parse exception if bad input is provided. Much better than an abort X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=7d922623e3e108cecfda6ca282acd9bcb1e0776d;p=oota-llvm.git 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 --- diff --git a/tools/analyze/analyze.cpp b/tools/analyze/analyze.cpp index 3bc2ee9e22e..112bfcc04b4 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; }