[llvm] 6ae5b9e - [llvm-readobj] - Make decode_relrs() don't return Expected<>. NFCI.
Georgii Rymar via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 5 07:06:31 PDT 2020
Author: Georgii Rymar
Date: 2020-08-05T17:05:47+03:00
New Revision: 6ae5b9e40587f5586e2970ca717797b68c34758d
URL: https://github.com/llvm/llvm-project/commit/6ae5b9e40587f5586e2970ca717797b68c34758d
DIFF: https://github.com/llvm/llvm-project/commit/6ae5b9e40587f5586e2970ca717797b68c34758d.diff
LOG: [llvm-readobj] - Make decode_relrs() don't return Expected<>. NFCI.
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.
Differential revision: https://reviews.llvm.org/D85302
Added:
Modified:
llvm/include/llvm/Object/ELF.h
llvm/lib/Object/ELF.cpp
llvm/tools/llvm-readobj/ELFDumper.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Object/ELF.h b/llvm/include/llvm/Object/ELF.h
index 0080d0ba58f3..35d2456f7ce2 100644
--- a/llvm/include/llvm/Object/ELF.h
+++ b/llvm/include/llvm/Object/ELF.h
@@ -203,7 +203,7 @@ class ELFFile {
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;
diff --git a/llvm/lib/Object/ELF.cpp b/llvm/lib/Object/ELF.cpp
index 7a675944bb44..0e06af92d64b 100644
--- a/llvm/lib/Object/ELF.cpp
+++ b/llvm/lib/Object/ELF.cpp
@@ -278,7 +278,7 @@ StringRef llvm::object::getELFSectionTypeName(uint32_t Machine, unsigned Type) {
}
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.
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index 78d47b540ab6..54b2d67421d0 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -3779,7 +3779,7 @@ template <class ELFT> void GNUStyle<ELFT>::printRelocations(const ELFO *Obj) {
} 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 @@ void GNUStyle<ELFT>::printDynamicRelocations(const ELFO *Obj) {
<< " 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 @@ void DumpStyle<ELFT>::printRelocationsHelper(const ELFFile<ELFT> *Obj,
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 @@ void LLVMStyle<ELFT>::printDynamicRelocations(const ELFO *Obj) {
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))
More information about the llvm-commits
mailing list