[PATCH] D106783: [AIX][XCOFF][llvm-readobj] Replace unwrapOrError with reportUniqueWarning
Maryam via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 26 02:49:25 PDT 2021
MaryamBen created this revision.
MaryamBen added reviewers: jhenderson, Esme, PowerPC, daltenty, hubert.reinterpretcast, MaskRay.
MaryamBen added a project: LLVM.
MaryamBen requested review of this revision.
Report warnings rather than errors, so that llvm-readobj doesn't bail out on malformed inputs.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D106783
Files:
llvm/tools/llvm-readobj/XCOFFDumper.cpp
Index: llvm/tools/llvm-readobj/XCOFFDumper.cpp
===================================================================
--- llvm/tools/llvm-readobj/XCOFFDumper.cpp
+++ llvm/tools/llvm-readobj/XCOFFDumper.cpp
@@ -134,16 +134,23 @@
if (Sec.Flags != XCOFF::STYP_TEXT && Sec.Flags != XCOFF::STYP_DATA &&
Sec.Flags != XCOFF::STYP_TDATA && Sec.Flags != XCOFF::STYP_DWARF)
continue;
- auto Relocations = unwrapOrError(Obj.getFileName(), Obj.relocations(Sec));
+ auto ErrOrRelocations = Obj.relocations(Sec);
+ if (Error E = ErrOrRelocations.takeError())
+ reportUniqueWarning(std::move(E));
+
+ auto Relocations = *ErrOrRelocations;
if (Relocations.empty())
continue;
W.startLine() << "Section (index: " << Index << ") " << Sec.getName()
<< " {\n";
for (auto Reloc : Relocations) {
- StringRef SymbolName = unwrapOrError(
- Obj.getFileName(), Obj.getSymbolNameByIndex(Reloc.SymbolIndex));
+ Expected<StringRef> ErrOrSymbolName =
+ Obj.getSymbolNameByIndex(Reloc.SymbolIndex);
+ if (Error E = ErrOrSymbolName.takeError())
+ reportUniqueWarning(std::move(E));
+ StringRef SymbolName = *ErrOrSymbolName;
DictScope RelocScope(W, "Relocation");
W.printHex("Virtual Address", Reloc.VirtualAddress);
W.printNumber("Symbol", SymbolName, Reloc.SymbolIndex);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106783.361602.patch
Type: text/x-patch
Size: 1386 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210726/bf8dfa45/attachment.bin>
More information about the llvm-commits
mailing list