[llvm] r370034 - [llvm-objdump] - Remove one overload of reportError. NFCI.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 27 03:03:45 PDT 2019
Author: grimar
Date: Tue Aug 27 03:03:45 2019
New Revision: 370034
URL: http://llvm.org/viewvc/llvm-project?rev=370034&view=rev
Log:
[llvm-objdump] - Remove one overload of reportError. NFCI.
There is a problem with reportError we have.
Declaration says we have ArchiveName
that follows the FileName:
reportError(Error E, StringRef FileName, StringRef ArchiveName,...
Though implementation have them reversed. I cleaned it up and
removed an excessive reportError(Error E, StringRef File) version.
Rebased on top of D66418.
Differential revision: https://reviews.llvm.org/D66517
Modified:
llvm/trunk/tools/llvm-objdump/MachODump.cpp
llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
llvm/trunk/tools/llvm-objdump/llvm-objdump.h
Modified: llvm/trunk/tools/llvm-objdump/MachODump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/MachODump.cpp?rev=370034&r1=370033&r2=370034&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/MachODump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/MachODump.cpp Tue Aug 27 03:03:45 2019
@@ -1945,7 +1945,7 @@ static void ProcessMachO(StringRef Name,
// 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 @@ static void printArchiveChild(StringRef
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 @@ static void printArchiveChild(StringRef
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 @@ static void printArchiveChild(StringRef
Expected<StringRef> 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 @@ static void printArchiveChild(StringRef
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 @@ static void printArchiveHeaders(StringRe
ArchitectureName);
if (Err)
- reportError(std::move(Err), StringRef(), Filename, ArchitectureName);
+ reportError(std::move(Err), Filename, "", ArchitectureName);
}
static bool ValidateArchFlags() {
@@ -2346,7 +2344,7 @@ void parseInputMachO(StringRef Filename)
Expected<std::unique_ptr<Binary>> 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<MachOObjectFile>(&*ChildOrErr.get())) {
@@ -2408,7 +2406,7 @@ void parseInputMachO(MachOUniversalBinar
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<std::unique_ptr<Archive>> AOrErr =
I->getAsArchive()) {
@@ -2428,7 +2426,7 @@ void parseInputMachO(MachOUniversalBinar
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 @@ void parseInputMachO(MachOUniversalBinar
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 @@ void parseInputMachO(MachOUniversalBinar
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<std::unique_ptr<Archive>> AOrErr = I->getAsArchive()) {
std::unique_ptr<Archive> &A = *AOrErr;
outs() << "Archive : " << Filename;
@@ -2541,7 +2539,7 @@ void parseInputMachO(MachOUniversalBinar
Expected<std::unique_ptr<Binary>> 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;
}
Modified: llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp?rev=370034&r1=370033&r2=370034&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp Tue Aug 27 03:03:45 2019
@@ -389,18 +389,8 @@ LLVM_ATTRIBUTE_NORETURN void reportError
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 @@ void printSymbolTable(const ObjectFile *
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<StringRef> NameOrErr = Section->getName())
@@ -1769,7 +1759,7 @@ void printSymbolTable(const ObjectFile *
consumeError(NameOrErr.takeError());
} else {
- Name = unwrapOrError(Symbol.getName(), ArchiveName, FileName,
+ Name = unwrapOrError(Symbol.getName(), FileName, ArchiveName,
ArchitectureName);
}
@@ -2156,7 +2146,7 @@ static void dumpArchive(const Archive *A
Expected<std::unique_ptr<Binary>> 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<ObjectFile>(&*ChildOrErr.get()))
Modified: llvm/trunk/tools/llvm-objdump/llvm-objdump.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/llvm-objdump.h?rev=370034&r1=370033&r2=370034&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/llvm-objdump.h (original)
+++ llvm/trunk/tools/llvm-objdump/llvm-objdump.h Tue Aug 27 03:03:45 2019
@@ -128,10 +128,9 @@ void printSectionContents(const object::
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 <typename T, typename... Ts>
More information about the llvm-commits
mailing list