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
This commit is contained in:
Chris Lattner 2002-02-01 05:09:35 +00:00
parent 07ae06d18e
commit 7d922623e3

View File

@ -259,9 +259,14 @@ struct {
int main(int argc, char **argv) { int main(int argc, char **argv) {
cl::ParseCommandLineOptions(argc, argv, " llvm analysis printer tool\n"); cl::ParseCommandLineOptions(argc, argv, " llvm analysis printer tool\n");
CurrentModule = ParseBytecodeFile(InputFilename); try {
if (!CurrentModule && !(CurrentModule = ParseAssemblyFile(InputFilename))) { CurrentModule = ParseBytecodeFile(InputFilename);
std::cerr << "Input file didn't read correctly.\n"; 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; return 1;
} }