Convert the Archive API to use ErrorOr.

Now that we have c++11, even things like ErrorOr<std::unique_ptr<...>> are
easy to use.

No intended functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211033 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola
2014-06-16 16:08:36 +00:00
parent d492c19894
commit 0659928fec
8 changed files with 93 additions and 98 deletions

View File

@ -245,12 +245,12 @@ static void PrintFileSectionSizes(StringRef file) {
// This is an archive. Iterate over each member and display its sizes.
for (object::Archive::child_iterator i = a->child_begin(),
e = a->child_end(); i != e; ++i) {
std::unique_ptr<Binary> child;
if (std::error_code ec = i->getAsBinary(child)) {
errs() << ToolName << ": " << file << ": " << ec.message() << ".\n";
ErrorOr<std::unique_ptr<Binary>> ChildOrErr = i->getAsBinary();
if (std::error_code EC = ChildOrErr.getError()) {
errs() << ToolName << ": " << file << ": " << EC.message() << ".\n";
continue;
}
if (ObjectFile *o = dyn_cast<ObjectFile>(child.get())) {
if (ObjectFile *o = dyn_cast<ObjectFile>(&*ChildOrErr.get())) {
if (OutputFormat == sysv)
outs() << o->getFileName() << " (ex " << a->getFileName()
<< "):\n";