From 7d922623e3e108cecfda6ca282acd9bcb1e0776d Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 1 Feb 2002 05:09:35 +0000 Subject: [PATCH] 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 --- tools/analyze/analyze.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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; }