Index: tools/llvm-objdump/MachODump.cpp =================================================================== --- tools/llvm-objdump/MachODump.cpp +++ tools/llvm-objdump/MachODump.cpp @@ -1945,7 +1945,7 @@ // the error message. if (Disassemble || IndirectSymbols || !FilterSections.empty() || UnwindInfo) if (Error Err = MachOOF->checkSymbolTable()) - reportError(std::move(Err), ArchiveName, FileName, ArchitectureName); + reportError(std::move(Err), FileName, ArchiveName, ArchitectureName); if (DisassembleAll) { for (const SectionRef &Section : MachOOF->sections()) { @@ -2219,9 +2219,8 @@ if (print_offset) outs() << C.getChildOffset() << "\t"; sys::fs::perms Mode = - unwrapOrError(C.getAccessMode(), Filename, - getFileNameForError(C, ChildIndex), - ArchitectureName); + unwrapOrError(C.getAccessMode(), getFileNameForError(C, ChildIndex), + Filename, ArchitectureName); if (verbose) { // FIXME: this first dash, "-", is for (Mode & S_IFMT) == S_IFREG. // But there is nothing in sys::fs::perms for S_IFMT or S_IFREG. @@ -2239,14 +2238,14 @@ outs() << format("0%o ", Mode); } - outs() << format( - "%3d/%-3d %5" PRId64 " ", - unwrapOrError(C.getUID(), Filename, getFileNameForError(C, ChildIndex), - ArchitectureName), - unwrapOrError(C.getGID(), Filename, getFileNameForError(C, ChildIndex), - ArchitectureName), - unwrapOrError(C.getRawSize(), Filename, - getFileNameForError(C, ChildIndex), ArchitectureName)); + outs() << format("%3d/%-3d %5" PRId64 " ", + unwrapOrError(C.getUID(), getFileNameForError(C, ChildIndex), + Filename, ArchitectureName), + unwrapOrError(C.getGID(), getFileNameForError(C, ChildIndex), + Filename, ArchitectureName), + unwrapOrError(C.getRawSize(), + getFileNameForError(C, ChildIndex), Filename, + ArchitectureName)); StringRef RawLastModified = C.getRawLastModified(); if (verbose) { @@ -2269,8 +2268,8 @@ Expected NameOrErr = C.getName(); if (!NameOrErr) { consumeError(NameOrErr.takeError()); - outs() << unwrapOrError(C.getRawName(), Filename, - getFileNameForError(C, ChildIndex), + outs() << unwrapOrError(C.getRawName(), + getFileNameForError(C, ChildIndex), Filename, ArchitectureName) << "\n"; } else { @@ -2278,9 +2277,8 @@ outs() << Name << "\n"; } } else { - outs() << unwrapOrError(C.getRawName(), Filename, - getFileNameForError(C, ChildIndex), - ArchitectureName) + outs() << unwrapOrError(C.getRawName(), getFileNameForError(C, ChildIndex), + Filename, ArchitectureName) << "\n"; } } @@ -2295,7 +2293,7 @@ ArchitectureName); if (Err) - reportError(std::move(Err), StringRef(), Filename, ArchitectureName); + reportError(std::move(Err), Filename, "", ArchitectureName); } static bool ValidateArchFlags() { @@ -2346,7 +2344,7 @@ Expected> ChildOrErr = C.getAsBinary(); if (!ChildOrErr) { if (Error E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError())) - reportError(std::move(E), Filename, getFileNameForError(C, I)); + reportError(std::move(E), getFileNameForError(C, I), Filename); continue; } if (MachOObjectFile *O = dyn_cast(&*ChildOrErr.get())) { @@ -2408,7 +2406,7 @@ ProcessMachO(Filename, MachOOF, "", ArchitectureName); } else if (Error E = isNotObjectErrorInvalidFileType( ObjOrErr.takeError())) { - reportError(std::move(E), Filename, StringRef(), ArchitectureName); + reportError(std::move(E), "", Filename, ArchitectureName); continue; } else if (Expected> AOrErr = I->getAsArchive()) { @@ -2428,7 +2426,7 @@ if (!ChildOrErr) { if (Error E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError())) - reportError(std::move(E), Filename, getFileNameForError(C, I), + reportError(std::move(E), getFileNameForError(C, I), Filename, ArchitectureName); continue; } @@ -2489,7 +2487,7 @@ if (!ChildOrErr) { if (Error E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError())) - reportError(std::move(E), Filename, getFileNameForError(C, I)); + reportError(std::move(E), getFileNameForError(C, I), Filename); continue; } if (MachOObjectFile *O = @@ -2524,7 +2522,7 @@ ProcessMachO(Filename, MachOOF, "", ArchitectureName); } else if (Error E = isNotObjectErrorInvalidFileType(ObjOrErr.takeError())) { - reportError(std::move(E), StringRef(), Filename, ArchitectureName); + reportError(std::move(E), Filename, "", ArchitectureName); } else if (Expected> AOrErr = I->getAsArchive()) { std::unique_ptr &A = *AOrErr; outs() << "Archive : " << Filename; @@ -2541,7 +2539,7 @@ Expected> ChildOrErr = C.getAsBinary(); if (!ChildOrErr) { if (Error E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError())) - reportError(std::move(E), Filename, getFileNameForError(C, I), + reportError(std::move(E), getFileNameForError(C, I), Filename, ArchitectureName); continue; } Index: tools/llvm-objdump/llvm-objdump.h =================================================================== --- tools/llvm-objdump/llvm-objdump.h +++ tools/llvm-objdump/llvm-objdump.h @@ -128,10 +128,9 @@ void printSymbolTable(const object::ObjectFile *O, StringRef ArchiveName, StringRef ArchitectureName = StringRef()); LLVM_ATTRIBUTE_NORETURN void reportError(StringRef File, Twine Message); -LLVM_ATTRIBUTE_NORETURN void reportError(Error E, StringRef File); -LLVM_ATTRIBUTE_NORETURN void -reportError(Error E, StringRef FileName, StringRef ArchiveName, - StringRef ArchitectureName = StringRef()); +LLVM_ATTRIBUTE_NORETURN void reportError(Error E, StringRef FileName, + StringRef ArchiveName = "", + StringRef ArchitectureName = ""); void reportWarning(Twine Message, StringRef File); template Index: tools/llvm-objdump/llvm-objdump.cpp =================================================================== --- tools/llvm-objdump/llvm-objdump.cpp +++ tools/llvm-objdump/llvm-objdump.cpp @@ -389,18 +389,8 @@ exit(1); } -LLVM_ATTRIBUTE_NORETURN void reportError(Error E, StringRef File) { - assert(E); - std::string Buf; - raw_string_ostream OS(Buf); - logAllUnhandledErrors(std::move(E), OS); - OS.flush(); - WithColor::error(errs(), ToolName) << "'" << File << "': " << Buf; - exit(1); -} - -LLVM_ATTRIBUTE_NORETURN void reportError(Error E, StringRef ArchiveName, - StringRef FileName, +LLVM_ATTRIBUTE_NORETURN void reportError(Error E, StringRef FileName, + StringRef ArchiveName, StringRef ArchitectureName) { assert(E); WithColor::error(errs(), ToolName); @@ -1752,15 +1742,15 @@ const StringRef FileName = O->getFileName(); for (auto I = O->symbol_begin(), E = O->symbol_end(); I != E; ++I) { const SymbolRef &Symbol = *I; - uint64_t Address = unwrapOrError(Symbol.getAddress(), ArchiveName, FileName, + uint64_t Address = unwrapOrError(Symbol.getAddress(), FileName, ArchiveName, ArchitectureName); if ((Address < StartAddress) || (Address > StopAddress)) continue; - SymbolRef::Type Type = unwrapOrError(Symbol.getType(), ArchiveName, - FileName, ArchitectureName); + SymbolRef::Type Type = unwrapOrError(Symbol.getType(), FileName, + ArchiveName, ArchitectureName); uint32_t Flags = Symbol.getFlags(); - section_iterator Section = unwrapOrError(Symbol.getSection(), ArchiveName, - FileName, ArchitectureName); + section_iterator Section = unwrapOrError(Symbol.getSection(), FileName, + ArchiveName, ArchitectureName); StringRef Name; if (Type == SymbolRef::ST_Debug && Section != O->section_end()) { if (Expected NameOrErr = Section->getName()) @@ -1769,7 +1759,7 @@ consumeError(NameOrErr.takeError()); } else { - Name = unwrapOrError(Symbol.getName(), ArchiveName, FileName, + Name = unwrapOrError(Symbol.getName(), FileName, ArchiveName, ArchitectureName); } @@ -2156,7 +2146,7 @@ Expected> ChildOrErr = C.getAsBinary(); if (!ChildOrErr) { if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError())) - reportError(std::move(E), A->getFileName(), getFileNameForError(C, I)); + reportError(std::move(E), getFileNameForError(C, I), A->getFileName()); continue; } if (ObjectFile *O = dyn_cast(&*ChildOrErr.get()))