[llvm-readobj] - Remove deprecated unwrapOrError(Expected<T> EO).
This patch changes the code to use a modern unwrapOrError(StringRef Input, Expected<T> EO)
version that contains the input source name and removes the deprecated version.
Differential revision: https://reviews.llvm.org/D65946
llvm-svn: 368428
diff --git a/llvm/tools/llvm-readobj/COFFDumper.cpp b/llvm/tools/llvm-readobj/COFFDumper.cpp
index 3f61edc..9b949f1 100644
--- a/llvm/tools/llvm-readobj/COFFDumper.cpp
+++ b/llvm/tools/llvm-readobj/COFFDumper.cpp
@@ -937,7 +937,8 @@
void COFFDumper::printCodeViewSymbolSection(StringRef SectionName,
const SectionRef &Section) {
- StringRef SectionContents = unwrapOrError(Section.getContents());
+ StringRef SectionContents =
+ unwrapOrError(Obj->getFileName(), Section.getContents());
StringRef Data = SectionContents;
SmallVector<StringRef, 10> FunctionNames;
@@ -1226,7 +1227,7 @@
StringRef SectionName;
error(S.getName(SectionName));
if (SectionName == ".debug$T") {
- StringRef Data = unwrapOrError(S.getContents());
+ StringRef Data = unwrapOrError(Obj->getFileName(), S.getContents());
uint32_t Magic;
error(consume(Data, Magic));
if (Magic != 4)
@@ -1262,7 +1263,7 @@
ListScope D(W, "CodeViewTypes");
W.printNumber("Section", SectionName, Obj->getSectionID(Section));
- StringRef Data = unwrapOrError(Section.getContents());
+ StringRef Data = unwrapOrError(Obj->getFileName(), Section.getContents());
if (opts::CodeViewSubsectionBytes)
W.printBinaryBlock("Data", Data);
@@ -1322,7 +1323,7 @@
if (opts::SectionData &&
!(Section->Characteristics & COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA)) {
- StringRef Data = unwrapOrError(Sec.getContents());
+ StringRef Data = unwrapOrError(Obj->getFileName(), Sec.getContents());
W.printBinaryBlock("SectionData", Data);
}
}
@@ -1670,7 +1671,8 @@
if (Name != ".drectve")
continue;
- StringRef Contents = unwrapOrError(Section.getContents());
+ StringRef Contents =
+ unwrapOrError(Obj->getFileName(), Section.getContents());
W.printString("Directive(s)", Contents);
}
}
@@ -1709,11 +1711,11 @@
if (!Name.startswith(".rsrc"))
continue;
- StringRef Ref = unwrapOrError(S.getContents());
+ StringRef Ref = unwrapOrError(Obj->getFileName(), S.getContents());
if ((Name == ".rsrc") || (Name == ".rsrc$01")) {
ResourceSectionRef RSF(Ref);
- auto &BaseTable = unwrapOrError(RSF.getBaseTable());
+ auto &BaseTable = unwrapOrError(Obj->getFileName(), RSF.getBaseTable());
W.printNumber("Total Number of Resources",
countTotalTableEntries(RSF, BaseTable, "Type"));
W.printHex("Base Table Address",
@@ -1741,7 +1743,8 @@
NextLevel = "Language";
else
NextLevel = "Name";
- auto &NextTable = unwrapOrError(RSF.getEntrySubDir(Entry));
+ auto &NextTable =
+ unwrapOrError(Obj->getFileName(), RSF.getEntrySubDir(Entry));
TotalEntries += countTotalTableEntries(RSF, NextTable, NextLevel);
} else {
TotalEntries += 1;
@@ -1767,7 +1770,7 @@
raw_svector_ostream OS(IDStr);
if (i < Table.NumberOfNameEntries) {
ArrayRef<UTF16> RawEntryNameString =
- unwrapOrError(RSF.getEntryNameString(Entry));
+ unwrapOrError(Obj->getFileName(), RSF.getEntryNameString(Entry));
std::vector<UTF16> EndianCorrectedNameString;
if (llvm::sys::IsBigEndianHost) {
EndianCorrectedNameString.resize(RawEntryNameString.size() + 1);
@@ -1799,7 +1802,8 @@
NextLevel = "Language";
else
NextLevel = "Name";
- auto &NextTable = unwrapOrError(RSF.getEntrySubDir(Entry));
+ auto &NextTable =
+ unwrapOrError(Obj->getFileName(), RSF.getEntrySubDir(Entry));
printResourceDirectoryTable(RSF, NextTable, NextLevel);
} else {
W.printHex("Entry Offset", Entry.Offset.value());
@@ -1837,7 +1841,8 @@
if (StackMapSection == object::SectionRef())
return;
- StringRef StackMapContents = unwrapOrError(StackMapSection.getContents());
+ StringRef StackMapContents =
+ unwrapOrError(Obj->getFileName(), StackMapSection.getContents());
ArrayRef<uint8_t> StackMapContentsArray =
arrayRefFromStringRef(StackMapContents);
@@ -1863,7 +1868,8 @@
if (AddrsigSection == object::SectionRef())
return;
- StringRef AddrsigContents = unwrapOrError(AddrsigSection.getContents());
+ StringRef AddrsigContents =
+ unwrapOrError(Obj->getFileName(), AddrsigSection.getContents());
ArrayRef<uint8_t> AddrsigContentsArray(AddrsigContents.bytes_begin(),
AddrsigContents.size());