llvm.org GIT mirror llvm / 77be094
Change llvm-objdump, llvm-nm and llvm-size when reporting an object file error when the object is in an archive to use something like libx.a(foo.o) as part of the error message. Also changed llvm-objdump and llvm-size to be like llvm-nm and ignore non-object files in archives and not produce any error message. To do this Archive::Child::getAsBinary() was changed from ErrorOr<...> to Expected<...> then that was threaded up to its users. Converting this interface 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 one place yet to be fully converted. Again there some were bugs in the existing code that did not deal with the old ErrorOr<> return values.  So now with Expected<> since they must be checked and the error handled, I added a TODO and a comments for those. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269784 91177308-0d34-0410-b5e6-96231b3b80d8 Kevin Enderby 3 years ago
17 changed file(s) with 254 addition(s) and 63 deletion(s). Raw diff Collapse all Expand all
100100
101101 ErrorOr getMemoryBufferRef() const;
102102
103 ErrorOr>
103 Expected>
104104 getAsBinary(LLVMContext *Context = nullptr) const;
105105 };
106106
8080 struct is_error_code_enum : std::true_type {};
8181 }
8282
83 namespace llvm {
84 namespace object {
85
86 // isNotObjectErrorInvalidFileType() is used when looping through the children
87 // of an archive after calling getAsBinary() on the child and it returns an
88 // llvm::Error. In the cases we want to loop through the children and ignore the
89 // non-objects in the archive this is used to test the error to see if an
90 // error() function needs to called on the llvm::Error.
91 static inline llvm::Error isNotObjectErrorInvalidFileType(llvm::Error Err) {
92 if (auto Err2 =
93 handleErrors(std::move(Err),
94 [](std::unique_ptr M) {
95 // Try to handle 'M'. If successful, return a success value from
96 // the handler.
97 if (M->convertToErrorCode() == object_error::invalid_file_type)
98 return Error::success();
99
100 // We failed to handle 'M' - return it from the handler.
101 // This value will be passed back from catchErrors and
102 // wind up in Err2, where it will be returned from this function.
103 return Error(std::move(M));
104 }))
105 return Err2;
106 return Err;
107 }
108
109 } // end namespace object.
110
111 } // end namespace llvm.
112
83113 #endif
328328 report_fatal_error(EC.message());
329329 if (ChildIt != A->child_end()) {
330330 // FIXME: Support nested archives?
331 ErrorOr> ChildBinOrErr =
331 Expected> ChildBinOrErr =
332332 (*ChildIt)->getAsBinary();
333 if (ChildBinOrErr.getError())
333 if (!ChildBinOrErr) {
334 // TODO: Actually report errors helpfully.
335 consumeError(ChildBinOrErr.takeError());
334336 continue;
337 }
335338 std::unique_ptr &ChildBin = ChildBinOrErr.get();
336339 if (ChildBin->isObject()) {
337340 std::unique_ptr OF(
262262 report_fatal_error(EC.message());
263263 if (ChildIt != A->child_end()) {
264264 // FIXME: Support nested archives?
265 ErrorOr> ChildBinOrErr =
265 Expected> ChildBinOrErr =
266266 (*ChildIt)->getAsBinary();
267 if (ChildBinOrErr.getError())
267 if (!ChildBinOrErr) {
268 // TODO: Actually report errors helpfully.
269 consumeError(ChildBinOrErr.takeError());
268270 continue;
271 }
269272 std::unique_ptr &ChildBin = ChildBinOrErr.get();
270273 if (ChildBin->isObject()) {
271274 std::vector> ObjSet;
227227 if (name.substr(3).rtrim(' ').getAsInteger(10, name_size))
228228 llvm_unreachable("Long name length is not an ingeter");
229229 return Data.substr(sizeof(ArchiveMemberHeader), name_size).rtrim('\0');
230 } else {
231 // It is not a long name so trim the blanks at the end of the name.
232 if (name[name.size() - 1] != '/') {
233 return name.rtrim(' ');
234 }
230235 }
231236 // It's a simple name.
232237 if (name[name.size() - 1] == '/')
245250 return MemoryBufferRef(*Buf, Name);
246251 }
247252
248 ErrorOr>
253 Expected>
249254 Archive::Child::getAsBinary(LLVMContext *Context) const {
250255 ErrorOr BuffOrErr = getMemoryBufferRef();
251256 if (std::error_code EC = BuffOrErr.getError())
252 return EC;
257 return errorCodeToError(EC);
253258
254259 auto BinaryOrErr = createBinary(BuffOrErr.get(), Context);
255260 if (BinaryOrErr)
256261 return std::move(*BinaryOrErr);
257 return errorToErrorCode(BinaryOrErr.takeError());
262 return BinaryOrErr.takeError();
258263 }
259264
260265 ErrorOr> Archive::create(MemoryBufferRef Source) {
5555 RUN: | FileCheck -check-prefix NAME-PAST-EOF-nm-pax %s
5656 NAME-PAST-EOF-nm-pax: 0000000000000000 64 00 0000 fe000002 bad string index
5757
58 RUN: not llvm-objdump -t %p/Inputs/macho-bad-archive1.a 2>&1 \
59 RUN: | FileCheck -check-prefix NAME-PAST-EOF-ARCHIVE %s
60 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)
61
5862 RUN: llvm-nm %p/Inputs/macho-invalid-section-index-getSectionRawName 2>&1 \
5963 RUN: | FileCheck -check-prefix INVALID-SECTION-IDX-SYMBOL-SEC %s
6064 INVALID-SECTION-IDX-SYMBOL-SEC: 0000000100000000 S __mh_execute_header
7377
7478 RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho64-invalid-incomplete-segment-load-command 2>&1 | FileCheck -check-prefix INCOMPLETE-SEGMENT-LOADC %s
7579 INCOMPLETE-SEGMENT-LOADC: truncated or malformed object (load commands extend past the end of the file)
80
81 RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho-bad-archive2.a 2>&1 | FileCheck -check-prefix INCOMPLETE-SEGMENT-LOADC-ARCHIVE %s
82 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)
5454
5555 This archive has an unaligned member and a unknown format member.
5656 GNU AR is able to parse the unaligned member and warns about the member with
57 the unknown format. We should probably simply warn on both. For now just check
58 that we don't produce an error.
59 RUN: llvm-nm %p/Inputs/corrupt-archive.a
57 the unknown format. We should probably simply warn on both. For now we just
58 produce an error for the unknown format.
59 RUN: not llvm-nm %p/Inputs/corrupt-archive.a 2>&1 | FileCheck %s -check-prefix CORRUPT
60 CORRUPT: corrupt-archive.a(trivial-object-test2.elf-x86-64) Invalid data was encountered while parsing the file
6061
6162
6263 RUN: llvm-nm %p/Inputs/thin.a | FileCheck %s -check-prefix THIN
484484 for (auto &ErrorOrChild : Arc->children()) {
485485 error(ErrorOrChild.getError());
486486 const Archive::Child &ArcC = *ErrorOrChild;
487 ErrorOr> ChildOrErr = ArcC.getAsBinary();
488 if (std::error_code EC = ChildOrErr.getError()) {
487 Expected> ChildOrErr = ArcC.getAsBinary();
488 if (!ChildOrErr) {
489489 // Ignore non-object files.
490 if (EC != object_error::invalid_file_type)
491 reportError(Arc->getFileName(), EC.message());
490 if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError())) {
491 std::string Buf;
492 raw_string_ostream OS(Buf);
493 logAllUnhandledErrors(std::move(E), OS, "");
494 OS.flush();
495 reportError(Arc->getFileName(), Buf);
496 }
497 ChildOrErr.takeError();
492498 continue;
493499 }
494500
187187 return true;
188188 }
189189 return false;
190 }
191
192 // This version of error() prints the archive name and member name, for example:
193 // "libx.a(foo.o)" after the ToolName before the error message. It sets
194 // 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) {
196 HadError = true;
197 errs() << ToolName << ": " << FileName;
198
199 ErrorOr NameOrErr = C.getName();
200 // TODO: if we have a error getting the name then it would be nice to print
201 // the index of which archive member this is and or its offset in the
202 // archive instead of "???" as the name.
203 if (NameOrErr.getError())
204 errs() << "(" << "???" << ")";
205 else
206 errs() << "(" << NameOrErr.get() << ")";
207
208 std::string Buf;
209 raw_string_ostream OS(Buf);
210 logAllUnhandledErrors(std::move(E), OS, "");
211 OS.flush();
212 errs() << " " << Buf << "\n";
190213 }
191214
192215 namespace {
10651088 if (error(I->getError()))
10661089 return;
10671090 auto &C = I->get();
1068 ErrorOr> ChildOrErr = C.getAsBinary(&Context);
1069 if (ChildOrErr.getError())
1091 Expected> ChildOrErr = C.getAsBinary(&Context);
1092 if (!ChildOrErr) {
1093 if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError()))
1094 error(std::move(E), Filename, C);
10701095 continue;
1096 }
10711097 if (SymbolicFile *O = dyn_cast(&*ChildOrErr.get())) {
10721098 if (!checkMachOAndArchFlags(O, Filename))
10731099 return;
11231149 if (error(AI->getError()))
11241150 return;
11251151 auto &C = AI->get();
1126 ErrorOr> ChildOrErr =
1152 Expected> ChildOrErr =
11271153 C.getAsBinary(&Context);
1128 if (ChildOrErr.getError())
1154 if (!ChildOrErr) {
1155 if (auto E = isNotObjectErrorInvalidFileType(
1156 ChildOrErr.takeError()))
1157 error(std::move(E), Filename, C);
11291158 continue;
1159 }
11301160 if (SymbolicFile *O =
11311161 dyn_cast(&*ChildOrErr.get())) {
11321162 if (PrintFileName) {
11801210 if (error(AI->getError()))
11811211 return;
11821212 auto &C = AI->get();
1183 ErrorOr> ChildOrErr =
1213 Expected> ChildOrErr =
11841214 C.getAsBinary(&Context);
1185 if (ChildOrErr.getError())
1215 if (!ChildOrErr) {
1216 if (auto E = isNotObjectErrorInvalidFileType(
1217 ChildOrErr.takeError()))
1218 error(std::move(E), Filename, C);
11861219 continue;
1220 }
11871221 if (SymbolicFile *O =
11881222 dyn_cast(&*ChildOrErr.get())) {
11891223 if (PrintFileName)
12321266 if (error(AI->getError()))
12331267 return;
12341268 auto &C = AI->get();
1235 ErrorOr> ChildOrErr = C.getAsBinary(&Context);
1236 if (ChildOrErr.getError())
1269 Expected> ChildOrErr = C.getAsBinary(&Context);
1270 if (!ChildOrErr) {
1271 if (auto E = isNotObjectErrorInvalidFileType(
1272 ChildOrErr.takeError()))
1273 error(std::move(E), Filename, C);
12371274 continue;
1275 }
12381276 if (SymbolicFile *O = dyn_cast(&*ChildOrErr.get())) {
12391277 if (PrintFileName) {
12401278 ArchiveName = A->getFileName();
12101210 // If we are doing some processing here on the Mach-O file print the header
12111211 // info. And don't print it otherwise like in the case of printing the
12121212 // UniversalHeaders or ArchiveHeaders.
1213 if (Disassemble || PrivateHeaders || ExportsTrie || Rebase || Bind ||
1213 if (Disassemble || PrivateHeaders || ExportsTrie || Rebase || Bind || SymbolTable ||
12141214 LazyBind || WeakBind || IndirectSymbols || DataInCode || LinkOptHints ||
12151215 DylibsUsed || DylibId || ObjcMetaData || (FilterSections.size() != 0)) {
12161216 outs() << Filename;
12431243 PrintDylibs(MachOOF, false);
12441244 if (DylibId)
12451245 PrintDylibs(MachOOF, true);
1246 if (SymbolTable)
1247 PrintSymbolTable(MachOOF);
1246 if (SymbolTable) {
1247 StringRef ArchiveName = ArchiveMemberName == StringRef() ? "" : Filename;
1248 PrintSymbolTable(MachOOF, ArchiveName);
1249 }
12481250 if (UnwindInfo)
12491251 printMachOUnwindInfo(MachOOF);
12501252 if (PrivateHeaders) {
15511553 if (std::error_code EC = I->getError())
15521554 report_error(Filename, EC);
15531555 auto &C = I->get();
1554 ErrorOr> ChildOrErr = C.getAsBinary();
1555 if (ChildOrErr.getError())
1556 Expected> ChildOrErr = C.getAsBinary();
1557 if (!ChildOrErr) {
1558 if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError()))
1559 report_error(Filename, C, std::move(E));
15561560 continue;
1561 }
15571562 if (MachOObjectFile *O = dyn_cast(&*ChildOrErr.get())) {
15581563 if (!checkMachOAndArchFlags(O, Filename))
15591564 return;
16021607 if (std::error_code EC = AI->getError())
16031608 report_error(Filename, EC);
16041609 auto &C = AI->get();
1605 ErrorOr> ChildOrErr = C.getAsBinary();
1606 if (ChildOrErr.getError())
1610 Expected> ChildOrErr = C.getAsBinary();
1611 if (!ChildOrErr) {
1612 if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError()))
1613 report_error(Filename, C, std::move(E));
16071614 continue;
1615 }
16081616 if (MachOObjectFile *O =
16091617 dyn_cast(&*ChildOrErr.get()))
16101618 ProcessMachO(Filename, O, O->getFileName(), ArchitectureName);
16471655 if (std::error_code EC = AI->getError())
16481656 report_error(Filename, EC);
16491657 auto &C = AI->get();
1650 ErrorOr> ChildOrErr = C.getAsBinary();
1651 if (ChildOrErr.getError())
1658 Expected> ChildOrErr = C.getAsBinary();
1659 if (!ChildOrErr) {
1660 if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError()))
1661 report_error(Filename, C, std::move(E));
16521662 continue;
1663 }
16531664 if (MachOObjectFile *O =
16541665 dyn_cast(&*ChildOrErr.get()))
16551666 ProcessMachO(Filename, O, O->getFileName());
16861697 if (std::error_code EC = AI->getError())
16871698 report_error(Filename, EC);
16881699 auto &C = AI->get();
1689 ErrorOr> ChildOrErr = C.getAsBinary();
1690 if (ChildOrErr.getError())
1700 Expected> ChildOrErr = C.getAsBinary();
1701 if (!ChildOrErr) {
1702 if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError()))
1703 report_error(Filename, C, std::move(E));
16911704 continue;
1705 }
16921706 if (MachOObjectFile *O =
16931707 dyn_cast(&*ChildOrErr.get())) {
16941708 if (MachOObjectFile *MachOOF = dyn_cast(O))
280280 exit(1);
281281 }
282282
283 LLVM_ATTRIBUTE_NORETURN void llvm::report_error(StringRef ArchiveName,
284 StringRef FileName,
285 llvm::Error E) {
286 assert(E);
287 errs() << ToolName << ": ";
288 if (ArchiveName != "")
289 errs() << ArchiveName << "(" << FileName << ")";
290 else
291 errs() << FileName;
292 std::string Buf;
293 raw_string_ostream OS(Buf);
294 logAllUnhandledErrors(std::move(E), OS, "");
295 OS.flush();
296 errs() << " " << Buf;
297 exit(1);
298 }
299
300 LLVM_ATTRIBUTE_NORETURN void llvm::report_error(StringRef ArchiveName,
301 const object::Archive::Child &C,
302 llvm::Error E) {
303 ErrorOr NameOrErr = C.getName();
304 // TODO: if we have a error getting the name then it would be nice to print
305 // the index of which archive member this is and or its offset in the
306 // archive instead of "???" as the name.
307 if (NameOrErr.getError())
308 llvm::report_error(ArchiveName, "???", std::move(E));
309 else
310 llvm::report_error(ArchiveName, NameOrErr.get(), std::move(E));
311 }
312
283313 static const Target *getTarget(const ObjectFile *Obj = nullptr) {
284314 // Figure out the target triple.
285315 llvm::Triple TheTriple("unknown-unknown-unknown");
13451375 }
13461376 }
13471377
1348 void llvm::PrintSymbolTable(const ObjectFile *o) {
1378 void llvm::PrintSymbolTable(const ObjectFile *o, StringRef ArchiveName) {
13491379 outs() << "SYMBOL TABLE:\n";
13501380
13511381 if (const COFFObjectFile *coff = dyn_cast(o)) {
13581388 uint64_t Address = *AddressOrError;
13591389 Expected TypeOrError = Symbol.getType();
13601390 if (!TypeOrError)
1361 report_error(o->getFileName(), TypeOrError.takeError());
1391 report_error(ArchiveName, o->getFileName(), TypeOrError.takeError());
13621392 SymbolRef::Type Type = *TypeOrError;
13631393 uint32_t Flags = Symbol.getFlags();
13641394 Expected SectionOrErr = Symbol.getSection();
13701400 } else {
13711401 Expected NameOrErr = Symbol.getName();
13721402 if (!NameOrErr)
1373 report_error(o->getFileName(), NameOrErr.takeError());
1403 report_error(ArchiveName, o->getFileName(), NameOrErr.takeError());
13741404 Name = *NameOrErr;
13751405 }
13761406
16021632 report_fatal_error("Invalid/Unsupported object file format");
16031633 }
16041634
1605 static void DumpObject(const ObjectFile *o) {
1635 static void DumpObject(const ObjectFile *o, const Archive *a = nullptr) {
1636 StringRef ArchiveName = a != nullptr ? a->getFileName() : "";
16061637 // Avoid other output when using a raw option.
16071638 if (!RawClangAST) {
16081639 outs() << '\n';
1609 outs() << o->getFileName()
1610 << ":\tfile format " << o->getFileFormatName() << "\n\n";
1640 if (a)
1641 outs() << a->getFileName() << "(" << o->getFileName() << ")";
1642 else
1643 outs() << o->getFileName();
1644 outs() << ":\tfile format " << o->getFileFormatName() << "\n\n";
16111645 }
16121646
16131647 if (Disassemble)
16191653 if (SectionContents)
16201654 PrintSectionContents(o);
16211655 if (SymbolTable)
1622 PrintSymbolTable(o);
1656 PrintSymbolTable(o, ArchiveName);
16231657 if (UnwindInfo)
16241658 PrintUnwindInfo(o);
16251659 if (PrivateHeaders)
16531687 if (std::error_code EC = ErrorOrChild.getError())
16541688 report_error(a->getFileName(), EC);
16551689 const Archive::Child &C = *ErrorOrChild;
1656 ErrorOr> ChildOrErr = C.getAsBinary();
1657 if (std::error_code EC = ChildOrErr.getError())
1658 if (EC != object_error::invalid_file_type)
1659 report_error(a->getFileName(), EC);
1690 Expected> ChildOrErr = C.getAsBinary();
1691 if (!ChildOrErr) {
1692 if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError()))
1693 report_error(a->getFileName(), C, std::move(E));
1694 continue;
1695 }
16601696 if (ObjectFile *o = dyn_cast(&*ChildOrErr.get()))
1661 DumpObject(o);
1697 DumpObject(o, a);
16621698 else
16631699 report_error(a->getFileName(), object_error::invalid_file_type);
16641700 }
1212 #include "llvm/Support/CommandLine.h"
1313 #include "llvm/Support/Compiler.h"
1414 #include "llvm/Support/DataTypes.h"
15 #include "llvm/Object/Archive.h"
1516
1617 namespace llvm {
1718 class StringRef;
2021 class COFFObjectFile;
2122 class MachOObjectFile;
2223 class ObjectFile;
24 class Archive;
2325 class RelocationRef;
2426 }
2527
8385 void PrintRelocations(const object::ObjectFile *o);
8486 void PrintSectionHeaders(const object::ObjectFile *o);
8587 void PrintSectionContents(const object::ObjectFile *o);
86 void PrintSymbolTable(const object::ObjectFile *o);
88 void PrintSymbolTable(const object::ObjectFile *o, StringRef ArchiveName);
8789 LLVM_ATTRIBUTE_NORETURN void report_error(StringRef File, std::error_code EC);
8890 LLVM_ATTRIBUTE_NORETURN void report_error(StringRef File, llvm::Error E);
91 LLVM_ATTRIBUTE_NORETURN void report_error(StringRef FileName,
92 StringRef ArchiveName,
93 llvm::Error E);
94 LLVM_ATTRIBUTE_NORETURN void report_error(StringRef ArchiveName,
95 const object::Archive::Child &C,
96 llvm::Error E);
8997
9098 } // end namespace llvm
9199
420420 if (std::error_code EC = ErrorOrChild.getError())
421421 reportError(Arc->getFileName(), EC.message());
422422 const auto &Child = *ErrorOrChild;
423 ErrorOr> ChildOrErr = Child.getAsBinary();
424 if (std::error_code EC = ChildOrErr.getError()) {
425 // Ignore non-object files.
426 if (EC != object_error::invalid_file_type)
427 reportError(Arc->getFileName(), EC.message());
423 Expected> ChildOrErr = Child.getAsBinary();
424 if (!ChildOrErr) {
425 if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError())) {
426 std::string Buf;
427 raw_string_ostream OS(Buf);
428 logAllUnhandledErrors(ChildOrErr.takeError(), OS, "");
429 OS.flush();
430 reportError(Arc->getFileName(), Buf);
431 }
428432 continue;
429433 }
430
431434 if (ObjectFile *Obj = dyn_cast(&*ChildOrErr.get()))
432435 dumpObject(Obj);
433436 else
9696 errs() << ToolName << ": error reading file: " << ec.message() << ".\n";
9797 errs().flush();
9898 return true;
99 }
100
101 // This version of error() prints the archive name and member name, for example:
102 // "libx.a(foo.o)" after the ToolName before the error message. It sets
103 // 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) {
105 HadError = true;
106 errs() << ToolName << ": " << FileName;
107
108 ErrorOr NameOrErr = C.getName();
109 // TODO: if we have a error getting the name then it would be nice to print
110 // the index of which archive member this is and or its offset in the
111 // archive instead of "???" as the name.
112 if (NameOrErr.getError())
113 errs() << "(" << "???" << ")";
114 else
115 errs() << "(" << NameOrErr.get() << ")";
116
117 std::string Buf;
118 raw_string_ostream OS(Buf);
119 logAllUnhandledErrors(std::move(E), OS, "");
120 OS.flush();
121 errs() << " " << Buf << "\n";
99122 }
100123
101124 /// Get the length of the string that represents @p num in Radix including the
479502 i != e; ++i) {
480503 if (error(i->getError()))
481504 exit(1);
482 ErrorOr> ChildOrErr = i->get().getAsBinary();
483 if (error(ChildOrErr.getError()))
505 Expected> ChildOrErr = i->get().getAsBinary();
506 if (!ChildOrErr) {
507 if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError()))
508 error(std::move(E), a->getFileName(), i->get());
484509 continue;
510 }
485511 if (ObjectFile *o = dyn_cast(&*ChildOrErr.get())) {
486512 MachOObjectFile *MachO = dyn_cast(o);
487513 if (!checkMachOAndArchFlags(o, file))
541567 i != e; ++i) {
542568 if (error(i->getError()))
543569 exit(1);
544 ErrorOr> ChildOrErr = i->get().getAsBinary();
545 if (error(ChildOrErr.getError()))
570 Expected> ChildOrErr =
571 i->get().getAsBinary();
572 if (!ChildOrErr) {
573 if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError()))
574 error(std::move(E), a->getFileName(), i->get());
546575 continue;
576 }
547577 if (ObjectFile *o = dyn_cast(&*ChildOrErr.get())) {
548578 MachOObjectFile *MachO = dyn_cast(o);
549579 if (OutputFormat == sysv)
617647 i != e; ++i) {
618648 if (error(i->getError()))
619649 exit(1);
620 ErrorOr> ChildOrErr = i->get().getAsBinary();
621 if (error(ChildOrErr.getError()))
650 Expected> ChildOrErr =
651 i->get().getAsBinary();
652 if (!ChildOrErr) {
653 if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError()))
654 error(std::move(E), a->getFileName(), i->get());
622655 continue;
656 }
623657 if (ObjectFile *o = dyn_cast(&*ChildOrErr.get())) {
624658 MachOObjectFile *MachO = dyn_cast(o);
625659 if (OutputFormat == sysv)
680714 i != e; ++i) {
681715 if (error(i->getError()))
682716 exit(1);
683 ErrorOr> ChildOrErr = i->get().getAsBinary();
684 if (error(ChildOrErr.getError()))
717 Expected> ChildOrErr = i->get().getAsBinary();
718 if (!ChildOrErr) {
719 if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError()))
720 error(std::move(E), UA->getFileName(), i->get());
685721 continue;
722 }
686723 if (ObjectFile *o = dyn_cast(&*ChildOrErr.get())) {
687724 MachOObjectFile *MachO = dyn_cast(o);
688725 if (OutputFormat == sysv)
413413 for (auto &ErrorOrChild : A.children()) {
414414 FailIfError(ErrorOrChild);
415415 const object::Archive::Child &C = *ErrorOrChild;
416 ErrorOr> ChildOrErr = C.getAsBinary();
417 FailIfError(ChildOrErr);
416 Expected> ChildOrErr = C.getAsBinary();
417 FailIfError(errorToErrorCode(ChildOrErr.takeError()));
418418 if (auto *O = dyn_cast(&*ChildOrErr.get()))
419419 Fn(*O);
420420 else