Give verbose error messages if bytecode file cannot be parsed

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5789 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2003-04-16 20:51:36 +00:00
parent 5399741622
commit 56620da5b4
4 changed files with 28 additions and 8 deletions

View File

@ -48,10 +48,15 @@ WriteMode(cl::desc("Specify the output format:"),
int main(int argc, char **argv) {
cl::ParseCommandLineOptions(argc, argv, " llvm .bc -> .ll disassembler\n");
std::ostream *Out = &std::cout; // Default to printing to stdout...
std::string ErrorMessage;
std::auto_ptr<Module> M(ParseBytecodeFile(InputFilename));
std::auto_ptr<Module> M(ParseBytecodeFile(InputFilename, &ErrorMessage));
if (M.get() == 0) {
cerr << argv[0] << ": bytecode didn't read correctly.\n";
cerr << argv[0] << ": ";
if (ErrorMessage.size())
cerr << ErrorMessage << "\n";
else
cerr << "bytecode didn't read correctly.\n";
return 1;
}

View File

@ -48,10 +48,15 @@ WriteMode(cl::desc("Specify the output format:"),
int main(int argc, char **argv) {
cl::ParseCommandLineOptions(argc, argv, " llvm .bc -> .ll disassembler\n");
std::ostream *Out = &std::cout; // Default to printing to stdout...
std::string ErrorMessage;
std::auto_ptr<Module> M(ParseBytecodeFile(InputFilename));
std::auto_ptr<Module> M(ParseBytecodeFile(InputFilename, &ErrorMessage));
if (M.get() == 0) {
cerr << argv[0] << ": bytecode didn't read correctly.\n";
cerr << argv[0] << ": ";
if (ErrorMessage.size())
cerr << ErrorMessage << "\n";
else
cerr << "bytecode didn't read correctly.\n";
return 1;
}

View File

@ -48,10 +48,15 @@ WriteMode(cl::desc("Specify the output format:"),
int main(int argc, char **argv) {
cl::ParseCommandLineOptions(argc, argv, " llvm .bc -> .ll disassembler\n");
std::ostream *Out = &std::cout; // Default to printing to stdout...
std::string ErrorMessage;
std::auto_ptr<Module> M(ParseBytecodeFile(InputFilename));
std::auto_ptr<Module> M(ParseBytecodeFile(InputFilename, &ErrorMessage));
if (M.get() == 0) {
cerr << argv[0] << ": bytecode didn't read correctly.\n";
cerr << argv[0] << ": ";
if (ErrorMessage.size())
cerr << ErrorMessage << "\n";
else
cerr << "bytecode didn't read correctly.\n";
return 1;
}

View File

@ -76,11 +76,16 @@ int main(int argc, char **argv) {
std::auto_ptr<TargetMachine> target;
TargetMachine* TM = NULL;
std::string ErrorMessage;
// Load the input module...
std::auto_ptr<Module> M(ParseBytecodeFile(InputFilename));
std::auto_ptr<Module> M(ParseBytecodeFile(InputFilename, &ErrorMessage));
if (M.get() == 0) {
cerr << argv[0] << ": bytecode didn't read correctly.\n";
cerr << argv[0] << ": ";
if (ErrorMessage.size())
cerr << ErrorMessage << "\n";
else
cerr << "bytecode didn't read correctly.\n";
return 1;
}