llvm-readobj: call exit(1) on error.

llvm-readobj exists for testing llvm. We can safely stop the program
the first time we know the input in corrupted.

This is in preparation for making it handle a few more broken files.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242656 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola
2015-07-20 03:23:55 +00:00
parent b9adbd998f
commit d60ced8e08
7 changed files with 61 additions and 92 deletions

View File

@ -188,22 +188,19 @@ namespace opts {
} // namespace opts
static int ReturnValue = EXIT_SUCCESS;
static void reportError(Twine Msg) {
ReturnValue = EXIT_FAILURE;
outs() << Msg << "\n";
outs().flush();
exit(1);
}
namespace llvm {
bool error(std::error_code EC) {
void error(std::error_code EC) {
if (!EC)
return false;
return;
reportError(Twine("\nError reading file: ") + EC.message() + ".");
return true;
}
bool relocAddressLess(RelocationRef a, RelocationRef b) {
@ -408,5 +405,5 @@ int main(int argc, const char *argv[]) {
std::for_each(opts::InputFilenames.begin(), opts::InputFilenames.end(),
dumpInput);
return ReturnValue;
return 0;
}