[llvm-ar] Use failIfError/fail helpers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253141 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Davide Italiano 2015-11-14 19:00:33 +00:00
parent 8baf5a3c92
commit 51ad607ad8

View File

@ -653,20 +653,13 @@ static int performOperation(ArchiveOperation Operation,
ErrorOr<std::unique_ptr<MemoryBuffer>> Buf =
MemoryBuffer::getFile(ArchiveName, -1, false);
std::error_code EC = Buf.getError();
if (EC && EC != errc::no_such_file_or_directory) {
errs() << ToolName << ": error opening '" << ArchiveName
<< "': " << EC.message() << "!\n";
return 1;
}
if (EC && EC != errc::no_such_file_or_directory)
fail("error opening '" + ArchiveName + "': " + EC.message() + "!");
if (!EC) {
object::Archive Archive(Buf.get()->getMemBufferRef(), EC);
if (EC) {
errs() << ToolName << ": error loading '" << ArchiveName
<< "': " << EC.message() << "!\n";
return 1;
}
failIfError(EC,
"error loading '" + ArchiveName + "': " + EC.message() + "!");
performOperation(Operation, &Archive, NewMembers);
return 0;
}