Index: llvm/tools/llvm-readobj/ELFDumper.cpp =================================================================== --- llvm/tools/llvm-readobj/ELFDumper.cpp +++ llvm/tools/llvm-readobj/ELFDumper.cpp @@ -517,7 +517,7 @@ Expected, StringRef>> SymTabOrErr = getLinkAsSymtab(Obj, Sec, SHT_DYNSYM); if (!SymTabOrErr) { - reportUniqueWarning(SymTabOrErr.takeError()); + reportUniqueWarning(toString(SymTabOrErr.takeError())); return *VersionsOrErr; } @@ -625,7 +625,7 @@ StringRef StrTab; Expected StrTabOrErr = getLinkAsStrtab(Obj, Sec); if (!StrTabOrErr) - reportUniqueWarning(StrTabOrErr.takeError()); + reportUniqueWarning(toString(StrTabOrErr.takeError())); else StrTab = *StrTabOrErr; @@ -799,7 +799,6 @@ virtual void printMipsPLT(const MipsGOTParser &Parser) = 0; virtual void printMipsABIFlags() = 0; const ELFDumper &dumper() const { return Dumper; } - void reportUniqueWarning(Error Err) const; void reportUniqueWarning(const Twine &Msg) const; protected: @@ -953,11 +952,6 @@ const Twine &Label, unsigned EntriesNum); }; -template -void DumpStyle::reportUniqueWarning(Error Err) const { - this->dumper().reportUniqueWarning(std::move(Err)); -} - template void DumpStyle::reportUniqueWarning(const Twine &Msg) const { this->dumper().reportUniqueWarning(Msg); @@ -1201,19 +1195,19 @@ if (Expected NameOrErr = Symbol.getName(*StrTable)) { SymbolName = maybeDemangle(*NameOrErr); } else { - reportUniqueWarning(NameOrErr.takeError()); + reportUniqueWarning(toString(NameOrErr.takeError())); return ""; } if (SymbolName.empty() && Symbol.getType() == ELF::STT_SECTION) { Expected SectionIndex = getSymbolSectionIndex(Symbol, SymIndex); if (!SectionIndex) { - reportUniqueWarning(SectionIndex.takeError()); + reportUniqueWarning(toString(SectionIndex.takeError())); return ""; } Expected NameOrErr = getSymbolSectionName(Symbol, *SectionIndex); if (!NameOrErr) { - reportUniqueWarning(NameOrErr.takeError()); + reportUniqueWarning(toString(NameOrErr.takeError())); return ("
").str(); } return std::string(*NameOrErr); @@ -1225,7 +1219,7 @@ bool IsDefault; Expected VersionOrErr = getSymbolVersion(Symbol, IsDefault); if (!VersionOrErr) { - reportUniqueWarning(VersionOrErr.takeError()); + reportUniqueWarning(toString(VersionOrErr.takeError())); return SymbolName + "@"; } @@ -2057,7 +2051,7 @@ if (Expected> ShndxTableOrErr = Obj.getSHNDXTable(Sec)) ShndxTable = *ShndxTableOrErr; else - this->reportUniqueWarning(ShndxTableOrErr.takeError()); + this->reportUniqueWarning(toString(ShndxTableOrErr.takeError())); break; case ELF::SHT_GNU_versym: if (!SymbolVersionSection) @@ -2221,8 +2215,8 @@ // and the location we find here should match. if (DynSymFromTable && DynSymFromTable->Addr != DynSymRegion->Addr) reportUniqueWarning( - createError("SHT_DYNSYM section header and DT_SYMTAB disagree about " - "the location of the dynamic symbol table")); + "SHT_DYNSYM section header and DT_SYMTAB disagree about " + "the location of the dynamic symbol table"); // According to the ELF gABI: "The number of symbol table entries should // equal nchain". Check to see if the DT_HASH hash table nchain value @@ -2766,7 +2760,7 @@ } if (Err) { - reportUniqueWarning(std::move(Err)); + reportUniqueWarning(toString(std::move(Err))); return; } @@ -2824,7 +2818,7 @@ } if (Err) { - reportUniqueWarning(std::move(Err)); + reportUniqueWarning(toString(std::move(Err))); return; } @@ -2865,12 +2859,12 @@ printMipsReginfo(); MipsGOTParser Parser(*this); if (Error E = Parser.findGOT(dynamic_table(), dynamic_symbols())) - reportUniqueWarning(std::move(E)); + reportUniqueWarning(toString(std::move(E))); else if (!Parser.isGotEmpty()) ELFDumperStyle->printMipsGOT(Parser); if (Error E = Parser.findPLT(dynamic_table())) - reportUniqueWarning(std::move(E)); + reportUniqueWarning(toString(std::move(E))); else if (!Parser.isPltEmpty()) ELFDumperStyle->printMipsPLT(Parser); break; @@ -3398,7 +3392,7 @@ Expected *> OptsOrErr = readMipsOptions(SecBegin, Data, IsSupported); if (!OptsOrErr) { - reportUniqueWarning(OptsOrErr.takeError()); + reportUniqueWarning(toString(OptsOrErr.takeError())); break; } @@ -3905,7 +3899,7 @@ Sections, this->dumper().WarningHandler)) SecStrTable = *SecStrTableOrErr; else - this->reportUniqueWarning(SecStrTableOrErr.takeError()); + this->reportUniqueWarning(toString(SecStrTableOrErr.takeError())); size_t SectionIndex = 0; for (const Elf_Shdr &Sec : Sections) { @@ -3985,7 +3979,7 @@ assert(Symbol.st_shndx == SHN_XINDEX && "getExtendedSymbolTableIndex should only fail due to an invalid " "SHT_SYMTAB_SHNDX table/reference"); - this->reportUniqueWarning(IndexOrErr.takeError()); + this->reportUniqueWarning(toString(IndexOrErr.takeError())); return "RSV[0xffff]"; } return to_string(format_decimal(*IndexOrErr, 3)); @@ -4209,7 +4203,7 @@ if (const Elf_Hash *SysVHash = this->dumper().getHashTable()) { OS << "\n Symbol table of .hash for image:\n"; if (Error E = checkHashTable(this->dumper(), SysVHash)) - this->reportUniqueWarning(std::move(E)); + this->reportUniqueWarning(toString(std::move(E))); else printHashTableSymbols(*SysVHash); } @@ -4224,7 +4218,7 @@ OS << "\n"; if (Error E = checkGNUHashTable(this->Obj, GnuHash)) - this->reportUniqueWarning(std::move(E)); + this->reportUniqueWarning(toString(std::move(E))); else printGnuHashTableSymbols(*GnuHash); } @@ -4262,7 +4256,7 @@ Sections, this->dumper().WarningHandler)) SecStrTable = *SecStrTableOrErr; else - this->reportUniqueWarning(SecStrTableOrErr.takeError()); + this->reportUniqueWarning(toString(SecStrTableOrErr.takeError())); size_t SectionIndex = 0; const unsigned AddrSize = Is64 ? 16 : 8; @@ -4272,7 +4266,7 @@ this->Obj.getSectionName(S, SecStrTable)) Name = *NameOrErr; else - this->reportUniqueWarning(NameOrErr.takeError()); + this->reportUniqueWarning(toString(NameOrErr.takeError())); OS.PadToColumn(2); OS << "[" << right_justify(to_string(SectionIndex), 2) << "]"; @@ -4726,7 +4720,7 @@ this->dumper().getVersionTable(*Sec, /*SymTab=*/nullptr, /*StrTab=*/nullptr); if (!VerTableOrErr) { - this->reportUniqueWarning(VerTableOrErr.takeError()); + this->reportUniqueWarning(toString(VerTableOrErr.takeError())); return; } @@ -4797,7 +4791,7 @@ Expected> V = this->dumper().getVersionDefinitions(*Sec); if (!V) { - this->reportUniqueWarning(V.takeError()); + this->reportUniqueWarning(toString(V.takeError())); return; } @@ -4826,7 +4820,7 @@ Expected> V = this->dumper().getVersionDependencies(*Sec); if (!V) { - this->reportUniqueWarning(V.takeError()); + this->reportUniqueWarning(toString(V.takeError())); return; } @@ -4958,7 +4952,7 @@ // Print histogram for the .hash section. if (const Elf_Hash *HashTable = this->dumper().getHashTable()) { if (Error E = checkHashTable(this->dumper(), HashTable)) - this->reportUniqueWarning(std::move(E)); + this->reportUniqueWarning(toString(std::move(E))); else printHashHistogram(*HashTable); } @@ -4966,7 +4960,7 @@ // Print histogram for the .gnu.hash section. if (const Elf_GnuHash *GnuHashTable = this->dumper().getGnuHashTable()) { if (Error E = checkGNUHashTable(this->Obj, GnuHashTable)) - this->reportUniqueWarning(std::move(E)); + this->reportUniqueWarning(toString(std::move(E))); else printGnuHashHistogram(*GnuHashTable); } @@ -5014,7 +5008,7 @@ Expected> SymsOrErr = decodeAddrsigSection(this->Obj, *Sec); if (!SymsOrErr) { - this->reportUniqueWarning(SymsOrErr.takeError()); + this->reportUniqueWarning(toString(SymsOrErr.takeError())); return; } @@ -6030,11 +6024,9 @@ // Warn about stack size sections without a relocation section. if (!RelocSec) { - reportWarning(createError(".stack_sizes (" + - describe(Obj, *StackSizesELFSec) + - ") does not have a corresponding " - "relocation section"), - FileName); + reportUniqueWarning(".stack_sizes (" + describe(Obj, *StackSizesELFSec) + + ") does not have a corresponding " + "relocation section"); continue; } @@ -6247,7 +6239,7 @@ getMipsAbiFlagsSection(this->dumper())) Flags = *SecOrErr; else - this->reportUniqueWarning(SecOrErr.takeError()); + this->reportUniqueWarning(toString(SecOrErr.takeError())); if (!Flags) return; @@ -6508,7 +6500,7 @@ assert(Symbol.st_shndx == SHN_XINDEX && "getSymbolSectionIndex should only fail due to an invalid " "SHT_SYMTAB_SHNDX table/reference"); - this->reportUniqueWarning(SectionIndex.takeError()); + this->reportUniqueWarning(toString(SectionIndex.takeError())); W.printHex("Section", "Reserved", SHN_XINDEX); return; } @@ -6519,7 +6511,7 @@ // Don't report an invalid section name if the section headers are missing. // In such situations, all sections will be "invalid". if (!this->dumper().getElfObject().sections().empty()) - this->reportUniqueWarning(SectionName.takeError()); + this->reportUniqueWarning(toString(SectionName.takeError())); else consumeError(SectionName.takeError()); W.printHex("Section", "", *SectionIndex); @@ -6677,7 +6669,7 @@ Expected> VerTableOrErr = this->dumper().getVersionTable(*Sec, &Syms, &StrTable); if (!VerTableOrErr) { - this->reportUniqueWarning(VerTableOrErr.takeError()); + this->reportUniqueWarning(toString(VerTableOrErr.takeError())); return; } @@ -6705,7 +6697,7 @@ Expected> V = this->dumper().getVersionDefinitions(*Sec); if (!V) { - this->reportUniqueWarning(V.takeError()); + this->reportUniqueWarning(toString(V.takeError())); return; } @@ -6730,7 +6722,7 @@ Expected> V = this->dumper().getVersionDependencies(*Sec); if (!V) { - this->reportUniqueWarning(V.takeError()); + this->reportUniqueWarning(toString(V.takeError())); return; } @@ -6789,7 +6781,7 @@ Expected> SymsOrErr = decodeAddrsigSection(this->Obj, *Sec); if (!SymsOrErr) { - this->reportUniqueWarning(SymsOrErr.takeError()); + this->reportUniqueWarning(toString(SymsOrErr.takeError())); return; } @@ -7084,7 +7076,7 @@ return; } } else { - this->reportUniqueWarning(SecOrErr.takeError()); + this->reportUniqueWarning(toString(SecOrErr.takeError())); return; } Index: llvm/tools/llvm-readobj/ObjDumper.h =================================================================== --- llvm/tools/llvm-readobj/ObjDumper.h +++ llvm/tools/llvm-readobj/ObjDumper.h @@ -112,7 +112,6 @@ ArrayRef Sections); std::function WarningHandler; - void reportUniqueWarning(Error Err) const; void reportUniqueWarning(const Twine &Msg) const; protected: Index: llvm/tools/llvm-readobj/ObjDumper.cpp =================================================================== --- llvm/tools/llvm-readobj/ObjDumper.cpp +++ llvm/tools/llvm-readobj/ObjDumper.cpp @@ -38,10 +38,6 @@ ObjDumper::~ObjDumper() {} -void ObjDumper::reportUniqueWarning(Error Err) const { - reportUniqueWarning(toString(std::move(Err))); -} - void ObjDumper::reportUniqueWarning(const Twine &Msg) const { cantFail(WarningHandler(Msg), "WarningHandler should always return ErrorSuccess");