llvm.org GIT mirror llvm / e9ddf3a
Change llvm-objdump, llvm-nm and llvm-size when reporting an object file error when the object is from a slice of a Mach-O Universal Binary use something like "foo.o (for architecture i386)" as part of the error message when expected. Also fixed places in these tools that were ignoring object file errors from MachOUniversalBinary::getAsObjectFile() when the code moved on to see if the slice was an archive. To do this MachOUniversalBinary::getAsObjectFile() and MachOUniversalBinary::getObjectForArch() were changed from returning ErrorOr<...> to Expected<...> then that was threaded up to its users. Converting these interfaces to Expected<> from ErrorOr<> does involve touching a number of places. To contain the changes for now the use of errorToErrorCode() is still used in two places yet to be fully converted. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271332 91177308-0d34-0410-b5e6-96231b3b80d8 Kevin Enderby 3 years ago
16 changed file(s) with 174 addition(s) and 49 deletion(s). Raw diff Collapse all Expand all
6262 return T.getArchName();
6363 }
6464
65 ErrorOr> getAsObjectFile() const;
65 Expected> getAsObjectFile() const;
6666
6767 ErrorOr> getAsArchive() const;
6868 };
109109 return V->isMachOUniversalBinary();
110110 }
111111
112 ErrorOr>
112 Expected>
113113 getObjectForArch(StringRef ArchName) const;
114114 };
115115
318318 return EC;
319319 return I->second->get();
320320 }
321 ErrorOr> ObjOrErr =
321 Expected> ObjOrErr =
322322 UB->getObjectForArch(ArchName);
323 if (auto EC = ObjOrErr.getError()) {
323 if (!ObjOrErr) {
324 auto EC = errorToErrorCode(ObjOrErr.takeError());
324325 ObjectForUBPathAndArch.insert(
325326 std::make_pair(std::make_pair(Path, ArchName), EC));
326327 return EC;
6666 }
6767 }
6868
69 ErrorOr>
69 Expected>
7070 MachOUniversalBinary::ObjectForArch::getAsObjectFile() const {
7171 if (!Parent)
72 return object_error::parse_failed;
72 return errorCodeToError(object_error::parse_failed);
7373
7474 StringRef ParentData = Parent->getData();
7575 StringRef ObjectData = ParentData.substr(Header.offset, Header.size);
7676 StringRef ObjectName = Parent->getFileName();
7777 MemoryBufferRef ObjBuffer(ObjectData, ObjectName);
78 return expectedToErrorOr(ObjectFile::createMachOObjectFile(ObjBuffer));
78 return ObjectFile::createMachOObjectFile(ObjBuffer);
7979 }
8080
8181 ErrorOr>
122122 ec = std::error_code();
123123 }
124124
125 ErrorOr>
125 Expected>
126126 MachOUniversalBinary::getObjectForArch(StringRef ArchName) const {
127127 if (Triple(ArchName).getArch() == Triple::ArchType::UnknownArch)
128 return object_error::arch_not_found;
128 return errorCodeToError(object_error::arch_not_found);
129129
130130 for (object_iterator I = begin_objects(), E = end_objects(); I != E; ++I) {
131131 if (I->getArchTypeName() == ArchName)
132132 return I->getAsObjectFile();
133133 }
134 return object_error::arch_not_found;
134 return errorCodeToError(object_error::arch_not_found);
135135 }
596596 // If we have a universal binary, try to look up the object for the
597597 // appropriate architecture.
598598 auto ObjectFileOrErr = Universal->getObjectForArch(Arch);
599 if (auto EC = ObjectFileOrErr.getError())
600 return errorCodeToError(EC);
599 if (!ObjectFileOrErr)
600 return ObjectFileOrErr.takeError();
601601 OF = std::move(ObjectFileOrErr.get());
602602 } else if (isa(Bin.get())) {
603603 // For any other object file, upcast and take ownership.
5959 RUN: | FileCheck -check-prefix NAME-PAST-EOF-ARCHIVE %s
6060 NAME-PAST-EOF-ARCHIVE: macho-bad-archive1.a(macho-invalid-symbol-name-past-eof) truncated or malformed object (bad string index: 4261412866 for symbol at index 0)
6161
62 RUN: not llvm-objdump -macho -arch all -t %p/Inputs/macho-universal-bad1.x86_64.i386 2>&1 \
63 RUN: | FileCheck -check-prefix NAME-PAST-EOF-FAT %s
64 NAME-PAST-EOF-FAT: macho-universal-bad1.x86_64.i386 (for architecture x86_64) truncated or malformed object (bad string index: 4261412866 for symbol at index 0)
65 RUN: not llvm-objdump -macho -arch all -t %p/Inputs/macho-universal-archive-bad1.x86_64.i386 2>&1 \
66 RUN: | FileCheck -check-prefix NAME-PAST-EOF-FAT-ARCHIVE %s
67 NAME-PAST-EOF-FAT-ARCHIVE: macho-universal-archive-bad1.x86_64.i386(macho-invalid-symbol-name-past-eof) (for architecture x86_64) truncated or malformed object (bad string index: 4261412866 for symbol at index 0)
68
6269 RUN: llvm-nm %p/Inputs/macho-invalid-section-index-getSectionRawName 2>&1 \
6370 RUN: | FileCheck -check-prefix INVALID-SECTION-IDX-SYMBOL-SEC %s
6471 INVALID-SECTION-IDX-SYMBOL-SEC: 0000000100000000 S __mh_execute_header
8087
8188 RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho-bad-archive2.a 2>&1 | FileCheck -check-prefix INCOMPLETE-SEGMENT-LOADC-ARCHIVE %s
8289 INCOMPLETE-SEGMENT-LOADC-ARCHIVE: macho-bad-archive2.a(macho64-invalid-incomplete-segment-load-command) truncated or malformed object (load commands extend past the end of the file)
90
91 RUN: not llvm-objdump -macho -private-headers -arch all %p/Inputs/macho-universal-bad2.x86_64.i386 2>&1 | FileCheck -check-prefix INCOMPLETE-SEGMENT-LOADC-FAT %s
92 INCOMPLETE-SEGMENT-LOADC-FAT: macho-universal-bad2.x86_64.i386 (for architecture x86_64) truncated or malformed object (load commands extend past the end of the file)
93
94 RUN: not llvm-objdump -macho -private-headers -arch all %p/Inputs/macho-universal-archive-bad2.x86_64.i386 2>&1 | FileCheck -check-prefix INCOMPLETE-SEGMENT-LOADC-FAT-ARCHIVE %s
95 INCOMPLETE-SEGMENT-LOADC-FAT-ARCHIVE: macho-universal-archive-bad2.x86_64.i386(macho64-invalid-incomplete-segment-load-command) (for architecture x86_64) truncated or malformed object (load commands extend past the end of the file)
104104 else if (auto *Fat = dyn_cast(BinOrErr->get()))
105105 for (auto &ObjForArch : Fat->objects()) {
106106 auto MachOOrErr = ObjForArch.getAsObjectFile();
107 error(Filename, MachOOrErr.getError());
107 error(Filename, errorToErrorCode(MachOOrErr.takeError()));
108108 DumpObjectFile(**MachOOrErr,
109109 Filename + " (" + ObjForArch.getArchTypeName() + ")");
110110 }
192192 // This version of error() prints the archive name and member name, for example:
193193 // "libx.a(foo.o)" after the ToolName before the error message. It sets
194194 // HadError but returns allowing the code to move on to other archive members.
195 static void error(llvm::Error E, StringRef FileName, const Archive::Child &C) {
195 static void error(llvm::Error E, StringRef FileName, const Archive::Child &C,
196 StringRef ArchitectureName = StringRef()) {
196197 HadError = true;
197198 errs() << ToolName << ": " << FileName;
198199
204205 errs() << "(" << "???" << ")";
205206 else
206207 errs() << "(" << NameOrErr.get() << ")";
208
209 if (!ArchitectureName.empty())
210 errs() << " (for architecture " << ArchitectureName << ") ";
211
212 std::string Buf;
213 raw_string_ostream OS(Buf);
214 logAllUnhandledErrors(std::move(E), OS, "");
215 OS.flush();
216 errs() << " " << Buf << "\n";
217 }
218
219 // This version of error() prints the file name and which architecture slice it
220 // is from, for example: "foo.o (for architecture i386)" after the ToolName
221 // before the error message. It sets HadError but returns allowing the code to
222 // move on to other architecture slices.
223 static void error(llvm::Error E, StringRef FileName,
224 StringRef ArchitectureName = StringRef()) {
225 HadError = true;
226 errs() << ToolName << ": " << FileName;
227
228 if (!ArchitectureName.empty())
229 errs() << " (for architecture " << ArchitectureName << ") ";
207230
208231 std::string Buf;
209232 raw_string_ostream OS(Buf);
11221145 I != E; ++I) {
11231146 if (ArchFlags[i] == I->getArchTypeName()) {
11241147 ArchFound = true;
1125 ErrorOr> ObjOrErr =
1148 Expected> ObjOrErr =
11261149 I->getAsObjectFile();
11271150 std::string ArchiveName;
11281151 std::string ArchitectureName;
11401163 }
11411164 dumpSymbolNamesFromObject(Obj, false, ArchiveName,
11421165 ArchitectureName);
1166 } else if (auto E = isNotObjectErrorInvalidFileType(
1167 ObjOrErr.takeError())) {
1168 error(std::move(E), Filename, ArchFlags.size() > 1 ?
1169 StringRef(I->getArchTypeName()) : StringRef());
1170 continue;
11431171 } else if (ErrorOr> AOrErr =
11441172 I->getAsArchive()) {
11451173 std::unique_ptr &A = *AOrErr;
11531181 C.getAsBinary(&Context);
11541182 if (!ChildOrErr) {
11551183 if (auto E = isNotObjectErrorInvalidFileType(
1156 ChildOrErr.takeError()))
1157 error(std::move(E), Filename, C);
1184 ChildOrErr.takeError())) {
1185 error(std::move(E), Filename, C, ArchFlags.size() > 1 ?
1186 StringRef(I->getArchTypeName()) : StringRef());
1187 }
11581188 continue;
11591189 }
11601190 if (SymbolicFile *O =
11951225 E = UB->end_objects();
11961226 I != E; ++I) {
11971227 if (HostArchName == I->getArchTypeName()) {
1198 ErrorOr> ObjOrErr = I->getAsObjectFile();
1228 Expected> ObjOrErr = I->getAsObjectFile();
11991229 std::string ArchiveName;
12001230 ArchiveName.clear();
12011231 if (ObjOrErr) {
12021232 ObjectFile &Obj = *ObjOrErr.get();
12031233 dumpSymbolNamesFromObject(Obj, false);
1234 } else if (auto E = isNotObjectErrorInvalidFileType(
1235 ObjOrErr.takeError())) {
1236 error(std::move(E), Filename);
1237 return;
12041238 } else if (ErrorOr> AOrErr =
12051239 I->getAsArchive()) {
12061240 std::unique_ptr &A = *AOrErr;
12401274 for (MachOUniversalBinary::object_iterator I = UB->begin_objects(),
12411275 E = UB->end_objects();
12421276 I != E; ++I) {
1243 ErrorOr> ObjOrErr = I->getAsObjectFile();
1277 Expected> ObjOrErr = I->getAsObjectFile();
12441278 std::string ArchiveName;
12451279 std::string ArchitectureName;
12461280 ArchiveName.clear();
12591293 outs() << ":\n";
12601294 }
12611295 dumpSymbolNamesFromObject(Obj, false, ArchiveName, ArchitectureName);
1296 } else if (auto E = isNotObjectErrorInvalidFileType(
1297 ObjOrErr.takeError())) {
1298 error(std::move(E), Filename, moreThanOneArch ?
1299 StringRef(I->getArchTypeName()) : StringRef());
1300 continue;
12621301 } else if (ErrorOr> AOrErr = I->getAsArchive()) {
12631302 std::unique_ptr &A = *AOrErr;
12641303 for (Archive::child_iterator AI = A->child_begin(), AE = A->child_end();
12661305 if (error(AI->getError()))
12671306 return;
12681307 auto &C = AI->get();
1269 Expected> ChildOrErr = C.getAsBinary(&Context);
1308 Expected> ChildOrErr =
1309 C.getAsBinary(&Context);
12701310 if (!ChildOrErr) {
12711311 if (auto E = isNotObjectErrorInvalidFileType(
12721312 ChildOrErr.takeError()))
1273 error(std::move(E), Filename, C);
1313 error(std::move(E), Filename, C, moreThanOneArch ?
1314 StringRef(ArchitectureName) : StringRef());
12741315 continue;
12751316 }
12761317 if (SymbolicFile *O = dyn_cast(&*ChildOrErr.get())) {
12651265 PrintDylibs(MachOOF, true);
12661266 if (SymbolTable) {
12671267 StringRef ArchiveName = ArchiveMemberName == StringRef() ? "" : Filename;
1268 PrintSymbolTable(MachOOF, ArchiveName);
1268 PrintSymbolTable(MachOOF, ArchiveName, ArchitectureName);
12691269 }
12701270 if (UnwindInfo)
12711271 printMachOUnwindInfo(MachOOF);
16031603 I != E; ++I) {
16041604 if (ArchFlags[i] == I->getArchTypeName()) {
16051605 ArchFound = true;
1606 ErrorOr> ObjOrErr =
1606 Expected> ObjOrErr =
16071607 I->getAsObjectFile();
16081608 std::string ArchitectureName = "";
16091609 if (ArchFlags.size() > 1)
16121612 ObjectFile &O = *ObjOrErr.get();
16131613 if (MachOObjectFile *MachOOF = dyn_cast(&O))
16141614 ProcessMachO(Filename, MachOOF, "", ArchitectureName);
1615 } else if (auto E = isNotObjectErrorInvalidFileType(
1616 ObjOrErr.takeError())) {
1617 report_error(Filename, StringRef(), std::move(E),
1618 ArchitectureName);
1619 continue;
16151620 } else if (ErrorOr> AOrErr =
16161621 I->getAsArchive()) {
16171622 std::unique_ptr &A = *AOrErr;
16301635 Expected> ChildOrErr = C.getAsBinary();
16311636 if (!ChildOrErr) {
16321637 if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError()))
1633 report_error(Filename, C, std::move(E));
1638 report_error(Filename, C, std::move(E), ArchitectureName);
16341639 continue;
16351640 }
16361641 if (MachOObjectFile *O =
16561661 I != E; ++I) {
16571662 if (MachOObjectFile::getHostArch().getArchName() ==
16581663 I->getArchTypeName()) {
1659 ErrorOr> ObjOrErr = I->getAsObjectFile();
1664 Expected> ObjOrErr = I->getAsObjectFile();
16601665 std::string ArchiveName;
16611666 ArchiveName.clear();
16621667 if (ObjOrErr) {
16631668 ObjectFile &O = *ObjOrErr.get();
16641669 if (MachOObjectFile *MachOOF = dyn_cast(&O))
16651670 ProcessMachO(Filename, MachOOF);
1671 } else if (auto E = isNotObjectErrorInvalidFileType(
1672 ObjOrErr.takeError())) {
1673 report_error(Filename, std::move(E));
1674 continue;
16661675 } else if (ErrorOr> AOrErr =
16671676 I->getAsArchive()) {
16681677 std::unique_ptr &A = *AOrErr;
16961705 for (MachOUniversalBinary::object_iterator I = UB->begin_objects(),
16971706 E = UB->end_objects();
16981707 I != E; ++I) {
1699 ErrorOr> ObjOrErr = I->getAsObjectFile();
1708 Expected> ObjOrErr = I->getAsObjectFile();
17001709 std::string ArchitectureName = "";
17011710 if (moreThanOneArch)
17021711 ArchitectureName = I->getArchTypeName();
17041713 ObjectFile &Obj = *ObjOrErr.get();
17051714 if (MachOObjectFile *MachOOF = dyn_cast(&Obj))
17061715 ProcessMachO(Filename, MachOOF, "", ArchitectureName);
1716 } else if (auto E = isNotObjectErrorInvalidFileType(
1717 ObjOrErr.takeError())) {
1718 report_error(StringRef(), Filename, std::move(E), ArchitectureName);
1719 continue;
17071720 } else if (ErrorOr> AOrErr = I->getAsArchive()) {
17081721 std::unique_ptr &A = *AOrErr;
17091722 outs() << "Archive : " << Filename;
17201733 Expected> ChildOrErr = C.getAsBinary();
17211734 if (!ChildOrErr) {
17221735 if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError()))
1723 report_error(Filename, C, std::move(E));
1736 report_error(Filename, C, std::move(E), ArchitectureName);
17241737 continue;
17251738 }
17261739 if (MachOObjectFile *O =
283283
284284 LLVM_ATTRIBUTE_NORETURN void llvm::report_error(StringRef ArchiveName,
285285 StringRef FileName,
286 llvm::Error E) {
286 llvm::Error E,
287 StringRef ArchitectureName) {
287288 assert(E);
288289 errs() << ToolName << ": ";
289290 if (ArchiveName != "")
290291 errs() << ArchiveName << "(" << FileName << ")";
291292 else
292293 errs() << FileName;
294 if (!ArchitectureName.empty())
295 errs() << " (for architecture " << ArchitectureName << ")";
293296 std::string Buf;
294297 raw_string_ostream OS(Buf);
295298 logAllUnhandledErrors(std::move(E), OS, "");
300303
301304 LLVM_ATTRIBUTE_NORETURN void llvm::report_error(StringRef ArchiveName,
302305 const object::Archive::Child &C,
303 llvm::Error E) {
306 llvm::Error E,
307 StringRef ArchitectureName) {
304308 ErrorOr NameOrErr = C.getName();
305309 // TODO: if we have a error getting the name then it would be nice to print
306310 // the index of which archive member this is and or its offset in the
307311 // archive instead of "???" as the name.
308312 if (NameOrErr.getError())
309 llvm::report_error(ArchiveName, "???", std::move(E));
313 llvm::report_error(ArchiveName, "???", std::move(E), ArchitectureName);
310314 else
311 llvm::report_error(ArchiveName, NameOrErr.get(), std::move(E));
315 llvm::report_error(ArchiveName, NameOrErr.get(), std::move(E),
316 ArchitectureName);
312317 }
313318
314319 static const Target *getTarget(const ObjectFile *Obj = nullptr) {
13761381 }
13771382 }
13781383
1379 void llvm::PrintSymbolTable(const ObjectFile *o, StringRef ArchiveName) {
1384 void llvm::PrintSymbolTable(const ObjectFile *o, StringRef ArchiveName,
1385 StringRef ArchitectureName) {
13801386 outs() << "SYMBOL TABLE:\n";
13811387
13821388 if (const COFFObjectFile *coff = dyn_cast(o)) {
14011407 } else {
14021408 Expected NameOrErr = Symbol.getName();
14031409 if (!NameOrErr)
1404 report_error(ArchiveName, o->getFileName(), NameOrErr.takeError());
1410 report_error(ArchiveName, o->getFileName(), NameOrErr.takeError(),
1411 ArchitectureName);
14051412 Name = *NameOrErr;
14061413 }
14071414
8585 void PrintRelocations(const object::ObjectFile *o);
8686 void PrintSectionHeaders(const object::ObjectFile *o);
8787 void PrintSectionContents(const object::ObjectFile *o);
88 void PrintSymbolTable(const object::ObjectFile *o, StringRef ArchiveName);
88 void PrintSymbolTable(const object::ObjectFile *o, StringRef ArchiveName,
89 StringRef ArchitectureName = StringRef());
8990 LLVM_ATTRIBUTE_NORETURN void report_error(StringRef File, std::error_code EC);
9091 LLVM_ATTRIBUTE_NORETURN void report_error(StringRef File, llvm::Error E);
9192 LLVM_ATTRIBUTE_NORETURN void report_error(StringRef FileName,
9293 StringRef ArchiveName,
93 llvm::Error E);
94 llvm::Error E,
95 StringRef ArchitectureName
96 = StringRef());
9497 LLVM_ATTRIBUTE_NORETURN void report_error(StringRef ArchiveName,
9598 const object::Archive::Child &C,
96 llvm::Error E);
99 llvm::Error E,
100 StringRef ArchitectureName
101 = StringRef());
97102
98103 } // end namespace llvm
99104
441441 /// @brief Dumps each object file in \a MachO Universal Binary;
442442 static void dumpMachOUniversalBinary(const MachOUniversalBinary *UBinary) {
443443 for (const MachOUniversalBinary::ObjectForArch &Obj : UBinary->objects()) {
444 ErrorOr> ObjOrErr = Obj.getAsObjectFile();
444 Expected> ObjOrErr = Obj.getAsObjectFile();
445445 if (ObjOrErr)
446446 dumpObject(&*ObjOrErr.get());
447 else if (auto E = isNotObjectErrorInvalidFileType(ObjOrErr.takeError())) {
448 std::string Buf;
449 raw_string_ostream OS(Buf);
450 logAllUnhandledErrors(ObjOrErr.takeError(), OS, "");
451 OS.flush();
452 reportError(UBinary->getFileName(), Buf);
453 }
447454 else if (ErrorOr> AOrErr = Obj.getAsArchive())
448455 dumpArchive(&*AOrErr.get());
449 else
450 reportError(UBinary->getFileName(), ObjOrErr.getError().message());
451456 }
452457 }
453458
101101 // This version of error() prints the archive name and member name, for example:
102102 // "libx.a(foo.o)" after the ToolName before the error message. It sets
103103 // HadError but returns allowing the code to move on to other archive members.
104 static void error(llvm::Error E, StringRef FileName, const Archive::Child &C) {
104 static void error(llvm::Error E, StringRef FileName, const Archive::Child &C,
105 StringRef ArchitectureName = StringRef()) {
105106 HadError = true;
106107 errs() << ToolName << ": " << FileName;
107108
113114 errs() << "(" << "???" << ")";
114115 else
115116 errs() << "(" << NameOrErr.get() << ")";
117
118 if (!ArchitectureName.empty())
119 errs() << " (for architecture " << ArchitectureName << ") ";
120
121 std::string Buf;
122 raw_string_ostream OS(Buf);
123 logAllUnhandledErrors(std::move(E), OS, "");
124 OS.flush();
125 errs() << " " << Buf << "\n";
126 }
127
128 // This version of error() prints the file name and which architecture slice it // is from, for example: "foo.o (for architecture i386)" after the ToolName
129 // before the error message. It sets HadError but returns allowing the code to
130 // move on to other architecture slices.
131 static void error(llvm::Error E, StringRef FileName,
132 StringRef ArchitectureName = StringRef()) {
133 HadError = true;
134 errs() << ToolName << ": " << FileName;
135
136 if (!ArchitectureName.empty())
137 errs() << " (for architecture " << ArchitectureName << ") ";
116138
117139 std::string Buf;
118140 raw_string_ostream OS(Buf);
538560 I != E; ++I) {
539561 if (ArchFlags[i] == I->getArchTypeName()) {
540562 ArchFound = true;
541 ErrorOr> UO = I->getAsObjectFile();
563 Expected> UO = I->getAsObjectFile();
542564 if (UO) {
543565 if (ObjectFile *o = dyn_cast(&*UO.get())) {
544566 MachOObjectFile *MachO = dyn_cast(o);
557579 outs() << "\n";
558580 }
559581 }
582 } else if (auto E = isNotObjectErrorInvalidFileType(
583 UO.takeError())) {
584 error(std::move(E), file, ArchFlags.size() > 1 ?
585 StringRef(I->getArchTypeName()) : StringRef());
586 return;
560587 } else if (ErrorOr> AOrErr =
561588 I->getAsArchive()) {
562589 std::unique_ptr &UA = *AOrErr;
570597 Expected> ChildOrErr =
571598 i->get().getAsBinary();
572599 if (!ChildOrErr) {
573 if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError()))
574 error(std::move(E), a->getFileName(), i->get());
600 if (auto E = isNotObjectErrorInvalidFileType(
601 ChildOrErr.takeError()))
602 error(std::move(E), UA->getFileName(), i->get(),
603 ArchFlags.size() > 1 ?
604 StringRef(I->getArchTypeName()) : StringRef());
575605 continue;
576606 }
577607 if (ObjectFile *o = dyn_cast(&*ChildOrErr.get())) {
618648 E = UB->end_objects();
619649 I != E; ++I) {
620650 if (HostArchName == I->getArchTypeName()) {
621 ErrorOr> UO = I->getAsObjectFile();
651 Expected> UO = I->getAsObjectFile();
622652 if (UO) {
623653 if (ObjectFile *o = dyn_cast(&*UO.get())) {
624654 MachOObjectFile *MachO = dyn_cast(o);
637667 outs() << "\n";
638668 }
639669 }
670 } else if (auto E = isNotObjectErrorInvalidFileType(UO.takeError())) {
671 error(std::move(E), file);
672 return;
640673 } else if (ErrorOr> AOrErr =
641674 I->getAsArchive()) {
642675 std::unique_ptr &UA = *AOrErr;
650683 Expected> ChildOrErr =
651684 i->get().getAsBinary();
652685 if (!ChildOrErr) {
653 if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError()))
654 error(std::move(E), a->getFileName(), i->get());
686 if (auto E = isNotObjectErrorInvalidFileType(
687 ChildOrErr.takeError()))
688 error(std::move(E), UA->getFileName(), i->get());
655689 continue;
656690 }
657691 if (ObjectFile *o = dyn_cast(&*ChildOrErr.get())) {
685719 for (MachOUniversalBinary::object_iterator I = UB->begin_objects(),
686720 E = UB->end_objects();
687721 I != E; ++I) {
688 ErrorOr> UO = I->getAsObjectFile();
722 Expected> UO = I->getAsObjectFile();
689723 if (UO) {
690724 if (ObjectFile *o = dyn_cast(&*UO.get())) {
691725 MachOObjectFile *MachO = dyn_cast(o);
705739 outs() << "\n";
706740 }
707741 }
742 } else if (auto E = isNotObjectErrorInvalidFileType(UO.takeError())) {
743 error(std::move(E), file, MoreThanOneArch ?
744 StringRef(I->getArchTypeName()) : StringRef());
745 return;
708746 } else if (ErrorOr> AOrErr =
709747 I->getAsArchive()) {
710748 std::unique_ptr &UA = *AOrErr;
716754 exit(1);
717755 Expected> ChildOrErr = i->get().getAsBinary();
718756 if (!ChildOrErr) {
719 if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError()))
720 error(std::move(E), UA->getFileName(), i->get());
757 if (auto E = isNotObjectErrorInvalidFileType(
758 ChildOrErr.takeError()))
759 error(std::move(E), UA->getFileName(), i->get(), MoreThanOneArch ?
760 StringRef(I->getArchTypeName()) : StringRef());
721761 continue;
722762 }
723763 if (ObjectFile *o = dyn_cast(&*ChildOrErr.get())) {