summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-size/llvm-size.cpp
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2016-07-14 02:24:01 +0000
committerLang Hames <lhames@gmail.com>2016-07-14 02:24:01 +0000
commitfc209623e976118cf016c0d3c1dccacb6bfa27c1 (patch)
tree407a60990972f87acb6c6aed9c218ac6ab4b203a /llvm/tools/llvm-size/llvm-size.cpp
parentaf7e8465e1fabdfff6c3a08a14cdb83ed79a10dc (diff)
downloadbcm5719-llvm-fc209623e976118cf016c0d3c1dccacb6bfa27c1.tar.gz
bcm5719-llvm-fc209623e976118cf016c0d3c1dccacb6bfa27c1.zip
[Object] Re-apply r275316 now that I have the corresponding LLD patch ready.
llvm-svn: 275361
Diffstat (limited to 'llvm/tools/llvm-size/llvm-size.cpp')
-rw-r--r--llvm/tools/llvm-size/llvm-size.cpp54
1 files changed, 24 insertions, 30 deletions
diff --git a/llvm/tools/llvm-size/llvm-size.cpp b/llvm/tools/llvm-size/llvm-size.cpp
index ecc0a0eac3c..c5966ead4b6 100644
--- a/llvm/tools/llvm-size/llvm-size.cpp
+++ b/llvm/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 " +
OpenPOWER on IntegriCloud