aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-objdump/llvm-objdump.cpp
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2019-05-16 12:08:34 +0000
committerHans Wennborg <hans@hanshq.net>2019-05-16 12:08:34 +0000
commit4da9ff9fcfe8987472dc894489597bd338aac85e (patch)
tree21bc0332451ec4093db5da5255ee98577ac5926e /llvm/tools/llvm-objdump/llvm-objdump.cpp
parenta8f88c388f75cb03bd21beb0b64f87d8a8727254 (diff)
downloadllvm-4da9ff9fcfe8987472dc894489597bd338aac85e.zip
llvm-4da9ff9fcfe8987472dc894489597bd338aac85e.tar.gz
llvm-4da9ff9fcfe8987472dc894489597bd338aac85e.tar.bz2
Revert r360876 "[Object] Change object::SectionRef::getContents() to return Expected<StringRef>"
It broke the Clang build, see llvm-commits thread. > Expected<ArrayRef<uint8_t>> may be better but use Expected<StringRef> for now. > > Follow-up of D61781. llvm-svn: 360878
Diffstat (limited to 'llvm/tools/llvm-objdump/llvm-objdump.cpp')
-rw-r--r--llvm/tools/llvm-objdump/llvm-objdump.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index de26b61..3fddfd2 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -1126,8 +1126,9 @@ static void disassembleObject(const Target *TheTarget, const ObjectFile *Obj,
SmallString<40> Comments;
raw_svector_ostream CommentStream(Comments);
- ArrayRef<uint8_t> Bytes = arrayRefFromStringRef(
- unwrapOrError(Section.getContents(), Obj->getFileName()));
+ StringRef BytesStr;
+ error(Section.getContents(BytesStr));
+ ArrayRef<uint8_t> Bytes = arrayRefFromStringRef(BytesStr);
uint64_t VMAAdjustment = 0;
if (shouldAdjustVA(Section))
@@ -1560,6 +1561,7 @@ void printSectionHeaders(const ObjectFile *Obj) {
void printSectionContents(const ObjectFile *Obj) {
for (const SectionRef &Section : ToolSectionFilter(*Obj)) {
StringRef Name;
+ StringRef Contents;
error(Section.getName(Name));
uint64_t BaseAddr = Section.getAddress();
uint64_t Size = Section.getSize();
@@ -1574,7 +1576,7 @@ void printSectionContents(const ObjectFile *Obj) {
continue;
}
- StringRef Contents = unwrapOrError(Section.getContents(), Obj->getFileName());
+ error(Section.getContents(Contents));
// Dump out the content as hex and printable ascii characters.
for (std::size_t Addr = 0, End = Contents.size(); Addr < End; Addr += 16) {
@@ -1762,8 +1764,8 @@ void printRawClangAST(const ObjectFile *Obj) {
if (!ClangASTSection)
return;
- StringRef ClangASTContents = unwrapOrError(
- ClangASTSection.getValue().getContents(), Obj->getFileName());
+ StringRef ClangASTContents;
+ error(ClangASTSection.getValue().getContents(ClangASTContents));
outs().write(ClangASTContents.data(), ClangASTContents.size());
}
@@ -1799,8 +1801,9 @@ static void printFaultMaps(const ObjectFile *Obj) {
return;
}
- StringRef FaultMapContents =
- unwrapOrError(FaultMapSection.getValue().getContents(), Obj->getFileName());
+ StringRef FaultMapContents;
+ error(FaultMapSection.getValue().getContents(FaultMapContents));
+
FaultMapParser FMP(FaultMapContents.bytes_begin(),
FaultMapContents.bytes_end());