[llvm] r265403 - Use ArrayRef for contiguous areas in ELF. NFC.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 5 07:47:23 PDT 2016
Author: rafael
Date: Tue Apr 5 09:47:22 2016
New Revision: 265403
URL: http://llvm.org/viewvc/llvm-project?rev=265403&view=rev
Log:
Use ArrayRef for contiguous areas in ELF. NFC.
This just simplifies the code a bit. More so in lld.
Modified:
llvm/trunk/include/llvm/Object/ELF.h
llvm/trunk/include/llvm/Object/ELFTypes.h
llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
Modified: llvm/trunk/include/llvm/Object/ELF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELF.h?rev=265403&r1=265402&r2=265403&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELF.h (original)
+++ llvm/trunk/include/llvm/Object/ELF.h Tue Apr 5 09:47:22 2016
@@ -112,7 +112,7 @@ public:
const Elf_Shdr *section_begin() const;
const Elf_Shdr *section_end() const;
Elf_Shdr_Range sections() const {
- return make_range(section_begin(), section_end());
+ return makeArrayRef(section_begin(), section_end());
}
const Elf_Sym *symbol_begin(const Elf_Shdr *Sec) const {
@@ -131,7 +131,7 @@ public:
return symbol_begin(Sec) + Size / sizeof(Elf_Sym);
}
Elf_Sym_Range symbols(const Elf_Shdr *Sec) const {
- return make_range(symbol_begin(Sec), symbol_end(Sec));
+ return makeArrayRef(symbol_begin(Sec), symbol_end(Sec));
}
const Elf_Rela *rela_begin(const Elf_Shdr *sec) const {
@@ -148,7 +148,7 @@ public:
}
Elf_Rela_Range relas(const Elf_Shdr *Sec) const {
- return make_range(rela_begin(Sec), rela_end(Sec));
+ return makeArrayRef(rela_begin(Sec), rela_end(Sec));
}
const Elf_Rel *rel_begin(const Elf_Shdr *sec) const {
@@ -165,7 +165,7 @@ public:
}
Elf_Rel_Range rels(const Elf_Shdr *Sec) const {
- return make_range(rel_begin(Sec), rel_end(Sec));
+ return makeArrayRef(rel_begin(Sec), rel_end(Sec));
}
/// \brief Iterate over program header table.
@@ -180,7 +180,7 @@ public:
}
const Elf_Phdr_Range program_headers() const {
- return make_range(program_header_begin(), program_header_end());
+ return makeArrayRef(program_header_begin(), program_header_end());
}
uint64_t getNumSections() const;
Modified: llvm/trunk/include/llvm/Object/ELFTypes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELFTypes.h?rev=265403&r1=265402&r2=265403&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELFTypes.h (original)
+++ llvm/trunk/include/llvm/Object/ELFTypes.h Tue Apr 5 09:47:22 2016
@@ -59,12 +59,12 @@ public:
typedef Elf_Versym_Impl<ELFType<E, Is64>> Versym;
typedef Elf_Hash_Impl<ELFType<E, Is64>> Hash;
typedef Elf_GnuHash_Impl<ELFType<E, Is64>> GnuHash;
- typedef iterator_range<const Dyn *> DynRange;
- typedef iterator_range<const Shdr *> ShdrRange;
- typedef iterator_range<const Sym *> SymRange;
- typedef iterator_range<const Rel *> RelRange;
- typedef iterator_range<const Rela *> RelaRange;
- typedef iterator_range<const Phdr *> PhdrRange;
+ typedef ArrayRef<Dyn> DynRange;
+ typedef ArrayRef<Shdr> ShdrRange;
+ typedef ArrayRef<Sym> SymRange;
+ typedef ArrayRef<Rel> RelRange;
+ typedef ArrayRef<Rela> RelaRange;
+ typedef ArrayRef<Phdr> PhdrRange;
typedef packed<uint16_t> Half;
typedef packed<uint32_t> Word;
Modified: llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/ELFDumper.cpp?rev=265403&r1=265402&r2=265403&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/ELFDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/ELFDumper.cpp Tue Apr 5 09:47:22 2016
@@ -82,7 +82,7 @@ struct DynRegionInfo {
/// \brief Size of each entity in the region.
uint64_t EntSize;
- template <typename Type> iterator_range<const Type *> getAsRange() const {
+ template <typename Type> ArrayRef<Type> getAsArrayRef() const {
const Type *Start = reinterpret_cast<const Type *>(Addr);
if (!Start)
return {Start, Start};
@@ -215,11 +215,11 @@ private:
public:
Elf_Dyn_Range dynamic_table() const {
- return DynamicTable.getAsRange<Elf_Dyn>();
+ return DynamicTable.getAsArrayRef<Elf_Dyn>();
}
Elf_Sym_Range dynamic_symbols() const {
- return DynSymRegion.getAsRange<Elf_Sym>();
+ return DynSymRegion.getAsArrayRef<Elf_Sym>();
}
Elf_Rel_Range dyn_rels() const;
@@ -1349,12 +1349,12 @@ void ELFDumper<ELFT>::parseDynamicTable(
template <typename ELFT>
typename ELFDumper<ELFT>::Elf_Rel_Range ELFDumper<ELFT>::dyn_rels() const {
- return DynRelRegion.getAsRange<Elf_Rel>();
+ return DynRelRegion.getAsArrayRef<Elf_Rel>();
}
template <typename ELFT>
typename ELFDumper<ELFT>::Elf_Rela_Range ELFDumper<ELFT>::dyn_relas() const {
- return DynRelaRegion.getAsRange<Elf_Rela>();
+ return DynRelaRegion.getAsArrayRef<Elf_Rela>();
}
template<class ELFT>
@@ -2906,11 +2906,11 @@ void GNUStyle<ELFT>::printDynamicRelocat
}
if (DynPLTRelRegion.EntSize == sizeof(Elf_Rela)) {
printRelocHeader(OS, ELFT::Is64Bits, true);
- for (const Elf_Rela &Rela : DynPLTRelRegion.getAsRange<Elf_Rela>())
+ for (const Elf_Rela &Rela : DynPLTRelRegion.getAsArrayRef<Elf_Rela>())
printDynamicRelocation(Obj, Rela, true);
} else {
printRelocHeader(OS, ELFT::Is64Bits, false);
- for (const Elf_Rel &Rel : DynPLTRelRegion.getAsRange<Elf_Rel>()) {
+ for (const Elf_Rel &Rel : DynPLTRelRegion.getAsArrayRef<Elf_Rel>()) {
Elf_Rela Rela;
Rela.r_offset = Rel.r_offset;
Rela.r_info = Rel.r_info;
@@ -3226,10 +3226,10 @@ void LLVMStyle<ELFT>::printDynamicReloca
printDynamicRelocation(Obj, Rela);
}
if (DynPLTRelRegion.EntSize == sizeof(Elf_Rela))
- for (const Elf_Rela &Rela : DynPLTRelRegion.getAsRange<Elf_Rela>())
+ for (const Elf_Rela &Rela : DynPLTRelRegion.getAsArrayRef<Elf_Rela>())
printDynamicRelocation(Obj, Rela);
else
- for (const Elf_Rel &Rel : DynPLTRelRegion.getAsRange<Elf_Rel>()) {
+ for (const Elf_Rel &Rel : DynPLTRelRegion.getAsArrayRef<Elf_Rel>()) {
Elf_Rela Rela;
Rela.r_offset = Rel.r_offset;
Rela.r_info = Rel.r_info;
More information about the llvm-commits
mailing list