summaryrefslogtreecommitdiff
path: root/tools/llvm-size
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
commitaacf2fbfe4c8c0a030a36a602814c0d472a8a447 (patch)
tree82f398a54def4b557e2c79c0f8a167317ba116a6 /tools/llvm-size
parent0e9e4ecaa4bc49ab42a038b347e823107d23269b (diff)
[Object] Re-apply r275316 now that I have the corresponding LLD patch ready.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275361 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-size')
-rw-r--r--tools/llvm-size/llvm-size.cpp54
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 " +