[PATCH] D85302: [llvm-readobj] - Make decode_relrs() don't return Expected<>. NFCI.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 5 06:59:33 PDT 2020
grimar created this revision.
grimar added reviewers: jhenderson, MaskRay.
Herald added subscribers: rupprecht, hiraditya.
Herald added a project: LLVM.
grimar requested review of this revision.
The `decode_relrs` helper is declared as:
`Expected<std::vector<Elf_Rel>> decode_relrs(Elf_Relr_Range relrs) const;`
it never returns an error though and hence can be simplified to return
a vector.
https://reviews.llvm.org/D85302
Files:
llvm/include/llvm/Object/ELF.h
llvm/lib/Object/ELF.cpp
llvm/tools/llvm-readobj/ELFDumper.cpp
Index: llvm/tools/llvm-readobj/ELFDumper.cpp
===================================================================
--- llvm/tools/llvm-readobj/ELFDumper.cpp
+++ llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -3779,7 +3779,7 @@
} else if (!opts::RawRelr && (Sec.sh_type == ELF::SHT_RELR ||
Sec.sh_type == ELF::SHT_ANDROID_RELR)) {
Elf_Relr_Range Relrs = unwrapOrError(this->FileName, Obj->relrs(&Sec));
- Entries = unwrapOrError(this->FileName, Obj->decode_relrs(Relrs)).size();
+ Entries = Obj->decode_relrs(Relrs).size();
} else {
Entries = Sec.getEntityCount();
}
@@ -4507,9 +4507,7 @@
<< " contains " << DynRelrRegion.Size << " bytes:\n";
printRelocHeader(ELF::SHT_REL);
Elf_Relr_Range Relrs = this->dumper()->dyn_relrs();
- std::vector<Elf_Rel> RelrRels =
- unwrapOrError(this->FileName, Obj->decode_relrs(Relrs));
- for (const Elf_Rel &R : RelrRels)
+ for (const Elf_Rel &R : Obj->decode_relrs(Relrs))
printDynamicRelocation(Obj, R);
}
if (DynPLTRelRegion.Size) {
@@ -5533,9 +5531,8 @@
printRelrReloc(R);
break;
}
- std::vector<Elf_Rel> RelrRels =
- unwrapOrError(this->FileName, Obj->decode_relrs(Relrs));
- for (const Elf_Rel &R : RelrRels)
+
+ for (const Elf_Rel &R : Obj->decode_relrs(Relrs))
printRelReloc(Obj, SecNdx, SymTab, R, ++RelNdx);
break;
}
@@ -6426,9 +6423,7 @@
if (DynRelrRegion.Size > 0) {
Elf_Relr_Range Relrs = this->dumper()->dyn_relrs();
- std::vector<Elf_Rel> RelrRels =
- unwrapOrError(this->FileName, Obj->decode_relrs(Relrs));
- for (const Elf_Rel &R : RelrRels)
+ for (const Elf_Rel &R : Obj->decode_relrs(Relrs))
printDynamicRelocation(Obj, R);
}
if (DynPLTRelRegion.EntSize == sizeof(Elf_Rela))
Index: llvm/lib/Object/ELF.cpp
===================================================================
--- llvm/lib/Object/ELF.cpp
+++ llvm/lib/Object/ELF.cpp
@@ -278,7 +278,7 @@
}
template <class ELFT>
-Expected<std::vector<typename ELFT::Rel>>
+std::vector<typename ELFT::Rel>
ELFFile<ELFT>::decode_relrs(Elf_Relr_Range relrs) const {
// This function decodes the contents of an SHT_RELR packed relocation
// section.
Index: llvm/include/llvm/Object/ELF.h
===================================================================
--- llvm/include/llvm/Object/ELF.h
+++ llvm/include/llvm/Object/ELF.h
@@ -203,7 +203,7 @@
return getSectionContentsAsArray<Elf_Relr>(Sec);
}
- Expected<std::vector<Elf_Rel>> decode_relrs(Elf_Relr_Range relrs) const;
+ std::vector<Elf_Rel> decode_relrs(Elf_Relr_Range relrs) const;
Expected<std::vector<Elf_Rela>> android_relas(const Elf_Shdr *Sec) const;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85302.283221.patch
Type: text/x-patch
Size: 2739 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200805/5461a237/attachment.bin>
More information about the llvm-commits
mailing list