From 56620da5b486225dfbb0db02d5cbc5c976d0dc02 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 16 Apr 2003 20:51:36 +0000 Subject: [PATCH] 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 --- tools/dis/dis.cpp | 9 +++++++-- tools/llvm-dis/dis.cpp | 9 +++++++-- tools/llvm-dis/llvm-dis.cpp | 9 +++++++-- tools/opt/opt.cpp | 9 +++++++-- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/tools/dis/dis.cpp b/tools/dis/dis.cpp index 166a178d574..a48dd7eb1a0 100644 --- a/tools/dis/dis.cpp +++ b/tools/dis/dis.cpp @@ -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 M(ParseBytecodeFile(InputFilename)); + std::auto_ptr 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; } diff --git a/tools/llvm-dis/dis.cpp b/tools/llvm-dis/dis.cpp index 166a178d574..a48dd7eb1a0 100644 --- a/tools/llvm-dis/dis.cpp +++ b/tools/llvm-dis/dis.cpp @@ -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 M(ParseBytecodeFile(InputFilename)); + std::auto_ptr 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; } diff --git a/tools/llvm-dis/llvm-dis.cpp b/tools/llvm-dis/llvm-dis.cpp index 166a178d574..a48dd7eb1a0 100644 --- a/tools/llvm-dis/llvm-dis.cpp +++ b/tools/llvm-dis/llvm-dis.cpp @@ -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 M(ParseBytecodeFile(InputFilename)); + std::auto_ptr 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; } diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp index 803f4c69931..6633dd18cba 100644 --- a/tools/opt/opt.cpp +++ b/tools/opt/opt.cpp @@ -76,11 +76,16 @@ int main(int argc, char **argv) { std::auto_ptr target; TargetMachine* TM = NULL; + std::string ErrorMessage; // Load the input module... - std::auto_ptr M(ParseBytecodeFile(InputFilename)); + std::auto_ptr 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; }