diff options
Diffstat (limited to 'tools/llvm-size')
-rw-r--r-- | tools/llvm-size/llvm-size.cpp | 54 |
1 files changed, 24 insertions, 30 deletions
diff --git a/tools/llvm-size/llvm-size.cpp b/tools/llvm-size/llvm-size.cpp index ecc0a0eac3c..c5966ead4b6 100644 --- a/tools/llvm-size/llvm-size.cpp +++ b/tools/llvm-size/llvm-size.cpp @@ -527,15 +527,12 @@ static void printFileSectionSizes(StringRef file) { if (Archive *a = dyn_cast<Archive>(&Bin)) { // 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) { - if (error(i->getError())) - exit(1); - Expected<std::unique_ptr<Binary>> ChildOrErr = i->get().getAsBinary(); + Error Err; + for (auto &C : a->children(Err)) { + Expected<std::unique_ptr<Binary>> ChildOrErr = C.getAsBinary(); if (!ChildOrErr) { if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError())) - error(std::move(E), a->getFileName(), i->get()); + error(std::move(E), a->getFileName(), C); continue; } if (ObjectFile *o = dyn_cast<ObjectFile>(&*ChildOrErr.get())) { @@ -555,6 +552,8 @@ static void printFileSectionSizes(StringRef file) { } } } + if (Err) + error(std::move(Err), a->getFileName()); } else if (MachOUniversalBinary *UB = dyn_cast<MachOUniversalBinary>(&Bin)) { // If we have a list of architecture flags specified dump only those. @@ -597,17 +596,13 @@ static void printFileSectionSizes(StringRef file) { std::unique_ptr<Archive> &UA = *AOrErr; // This is an archive. Iterate over each member and display its // sizes. - for (object::Archive::child_iterator i = UA->child_begin(), - e = UA->child_end(); - i != e; ++i) { - if (error(i->getError())) - exit(1); - Expected<std::unique_ptr<Binary>> ChildOrErr = - i->get().getAsBinary(); + Error Err; + for (auto &C : UA->children(Err)) { + Expected<std::unique_ptr<Binary>> ChildOrErr = C.getAsBinary(); if (!ChildOrErr) { if (auto E = isNotObjectErrorInvalidFileType( ChildOrErr.takeError())) - error(std::move(E), UA->getFileName(), i->get(), + error(std::move(E), UA->getFileName(), C, ArchFlags.size() > 1 ? StringRef(I->getArchTypeName()) : StringRef()); continue; @@ -637,6 +632,8 @@ static void printFileSectionSizes(StringRef file) { } } } + if (Err) + error(std::move(Err), UA->getFileName()); } else { consumeError(AOrErr.takeError()); error("Mach-O universal file: " + file + " for architecture " + @@ -688,17 +685,13 @@ static void printFileSectionSizes(StringRef file) { std::unique_ptr<Archive> &UA = *AOrErr; // This is an archive. Iterate over each member and display its // sizes. - for (object::Archive::child_iterator i = UA->child_begin(), - e = UA->child_end(); - i != e; ++i) { - if (error(i->getError())) - exit(1); - Expected<std::unique_ptr<Binary>> ChildOrErr = - i->get().getAsBinary(); + Error Err; + for (auto &C : UA->children(Err)) { + Expected<std::unique_ptr<Binary>> ChildOrErr = C.getAsBinary(); if (!ChildOrErr) { if (auto E = isNotObjectErrorInvalidFileType( ChildOrErr.takeError())) - error(std::move(E), UA->getFileName(), i->get()); + error(std::move(E), UA->getFileName(), C); continue; } if (ObjectFile *o = dyn_cast<ObjectFile>(&*ChildOrErr.get())) { @@ -721,6 +714,8 @@ static void printFileSectionSizes(StringRef file) { } } } + if (Err) + error(std::move(Err), UA->getFileName()); } else { consumeError(AOrErr.takeError()); error("Mach-O universal file: " + file + " for architecture " + @@ -765,16 +760,13 @@ static void printFileSectionSizes(StringRef file) { I->getAsArchive()) { std::unique_ptr<Archive> &UA = *AOrErr; // This is an archive. Iterate over each member and display its sizes. - for (object::Archive::child_iterator i = UA->child_begin(), - e = UA->child_end(); - i != e; ++i) { - if (error(i->getError())) - exit(1); - Expected<std::unique_ptr<Binary>> ChildOrErr = i->get().getAsBinary(); + Error Err; + for (auto &C : UA->children(Err)) { + Expected<std::unique_ptr<Binary>> ChildOrErr = C.getAsBinary(); if (!ChildOrErr) { if (auto E = isNotObjectErrorInvalidFileType( ChildOrErr.takeError())) - error(std::move(E), UA->getFileName(), i->get(), MoreThanOneArch ? + error(std::move(E), UA->getFileName(), C, MoreThanOneArch ? StringRef(I->getArchTypeName()) : StringRef()); continue; } @@ -798,6 +790,8 @@ static void printFileSectionSizes(StringRef file) { } } } + if (Err) + error(std::move(Err), UA->getFileName()); } else { consumeError(AOrErr.takeError()); error("Mach-O universal file: " + file + " for architecture " + |