This is an archive of the discontinued LLVM Phabricator instance.

[llvm-readobj] - Introduce `ObjDumper::reportUniqueWarning(const Twine &Msg)`.
ClosedPublic

Authored by grimar on Dec 1 2020, 1:16 AM.

Details

Summary

This introduces the overload for reportUniqueWarning which allows
to avoid using createError in many places.

Diff Detail

Event Timeline

grimar created this revision.Dec 1 2020, 1:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 1 2020, 1:16 AM
Herald added a subscriber: rupprecht. · View Herald Transcript
grimar requested review of this revision.Dec 1 2020, 1:16 AM
jhenderson accepted this revision.Dec 1 2020, 1:27 AM

Looks reasonable. What cases remain that require the older version?

This revision is now accepted and ready to land.Dec 1 2020, 1:27 AM
grimar added a comment.Dec 1 2020, 1:35 AM

Looks reasonable. What cases remain that require the older version?

There are still many places where it is used.

E.g.:

std::string SymbolName;
if (Expected<StringRef> NameOrErr = Symbol.getName(*StrTable)) {
  SymbolName = maybeDemangle(*NameOrErr);
} else {
  reportUniqueWarning(NameOrErr.takeError());
  return "<?>";
}

if (SymbolName.empty() && Symbol.getType() == ELF::STT_SECTION) {
  Expected<unsigned> SectionIndex = getSymbolSectionIndex(Symbol, SymIndex);
  if (!SectionIndex) {
    reportUniqueWarning(SectionIndex.takeError());
    return "<?>";
  }
  Expected<StringRef> NameOrErr = getSymbolSectionName(Symbol, *SectionIndex);
  if (!NameOrErr) {
    reportUniqueWarning(NameOrErr.takeError());
    return ("<section " + Twine(*SectionIndex) + ">").str();
  }
  return std::string(*NameOrErr);
}

We might use toString() for such places or rewrite them to provide more context probably.

We might use toString() for such places or rewrite them to provide more context probably.

Thanks. i'm thinking more context probably in the future.