Skip to content

Commit

Permalink
Fix the name of the iterator functions to match the coding standards.
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241074 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
espindola committed Jun 30, 2015
1 parent e8ff062 commit 28bec63
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 76 deletions.
70 changes: 35 additions & 35 deletions include/llvm/Object/ELF.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,90 +264,90 @@ class ELFFile {
Header->getDataEncoding() == ELF::ELFDATA2LSB;
}

Elf_Shdr_Iter begin_sections() const;
Elf_Shdr_Iter end_sections() const;
Elf_Shdr_Iter section_begin() const;
Elf_Shdr_Iter section_end() const;
Elf_Shdr_Range sections() const {
return make_range(begin_sections(), end_sections());
return make_range(section_begin(), section_end());
}

const Elf_Sym *begin_symbols() const;
const Elf_Sym *end_symbols() const;
const Elf_Sym *symbol_begin() const;
const Elf_Sym *symbol_end() const;
Elf_Sym_Range symbols() const {
return make_range(begin_symbols(), end_symbols());
return make_range(symbol_begin(), symbol_end());
}

Elf_Dyn_Iter begin_dynamic_table() const;
Elf_Dyn_Iter dynamic_table_begin() const;
/// \param NULLEnd use one past the first DT_NULL entry as the end instead of
/// the section size.
Elf_Dyn_Iter end_dynamic_table(bool NULLEnd = false) const;
Elf_Dyn_Iter dynamic_table_end(bool NULLEnd = false) const;
Elf_Dyn_Range dynamic_table(bool NULLEnd = false) const {
return make_range(begin_dynamic_table(), end_dynamic_table(NULLEnd));
return make_range(dynamic_table_begin(), dynamic_table_end(NULLEnd));
}

const Elf_Sym *begin_dynamic_symbols() const {
const Elf_Sym *dynamic_symbol_begin() const {
if (!DynSymRegion.Addr)
return nullptr;
if (DynSymRegion.EntSize != sizeof(Elf_Sym))
report_fatal_error("Invalid symbol size");
return reinterpret_cast<const Elf_Sym *>(DynSymRegion.Addr);
}

const Elf_Sym *end_dynamic_symbols() const {
const Elf_Sym *dynamic_symbol_end() const {
if (!DynSymRegion.Addr)
return nullptr;
return reinterpret_cast<const Elf_Sym *>(
((const char *)DynSymRegion.Addr + DynSymRegion.Size));
}

Elf_Sym_Range dynamic_symbols() const {
return make_range(begin_dynamic_symbols(), end_dynamic_symbols());
return make_range(dynamic_symbol_begin(), dynamic_symbol_end());
}

Elf_Rela_Iter begin_dyn_rela() const {
Elf_Rela_Iter dyn_rela_begin() const {
if (DynRelaRegion.Addr)
return Elf_Rela_Iter(DynRelaRegion.EntSize,
(const char *)DynRelaRegion.Addr);
return Elf_Rela_Iter(0, nullptr);
}

Elf_Rela_Iter end_dyn_rela() const {
Elf_Rela_Iter dyn_rela_end() const {
if (DynRelaRegion.Addr)
return Elf_Rela_Iter(
DynRelaRegion.EntSize,
(const char *)DynRelaRegion.Addr + DynRelaRegion.Size);
return Elf_Rela_Iter(0, nullptr);
}

Elf_Rela_Iter begin_rela(const Elf_Shdr *sec) const {
Elf_Rela_Iter rela_begin(const Elf_Shdr *sec) const {
return Elf_Rela_Iter(sec->sh_entsize,
(const char *)(base() + sec->sh_offset));
}

Elf_Rela_Iter end_rela(const Elf_Shdr *sec) const {
Elf_Rela_Iter rela_end(const Elf_Shdr *sec) const {
return Elf_Rela_Iter(
sec->sh_entsize,
(const char *)(base() + sec->sh_offset + sec->sh_size));
}

Elf_Rel_Iter begin_rel(const Elf_Shdr *sec) const {
Elf_Rel_Iter rel_begin(const Elf_Shdr *sec) const {
return Elf_Rel_Iter(sec->sh_entsize,
(const char *)(base() + sec->sh_offset));
}

Elf_Rel_Iter end_rel(const Elf_Shdr *sec) const {
Elf_Rel_Iter rel_end(const Elf_Shdr *sec) const {
return Elf_Rel_Iter(sec->sh_entsize,
(const char *)(base() + sec->sh_offset + sec->sh_size));
}

/// \brief Iterate over program header table.
typedef ELFEntityIterator<const Elf_Phdr> Elf_Phdr_Iter;

Elf_Phdr_Iter begin_program_headers() const {
Elf_Phdr_Iter program_header_begin() const {
return Elf_Phdr_Iter(Header->e_phentsize,
(const char*)base() + Header->e_phoff);
}

Elf_Phdr_Iter end_program_headers() const {
Elf_Phdr_Iter program_header_end() const {
return Elf_Phdr_Iter(Header->e_phentsize,
(const char*)base() +
Header->e_phoff +
Expand Down Expand Up @@ -478,7 +478,7 @@ ELFFile<ELFT>::getSection(const Elf_Sym *symb) const {
template <class ELFT>
const typename ELFFile<ELFT>::Elf_Sym *
ELFFile<ELFT>::getSymbol(uint32_t Index) const {
return &*(begin_symbols() + Index);
return &*(symbol_begin() + Index);
}

template <class ELFT>
Expand Down Expand Up @@ -692,8 +692,8 @@ ELFFile<ELFT>::ELFFile(StringRef Object, std::error_code &EC)
}

// Scan program headers.
for (Elf_Phdr_Iter PhdrI = begin_program_headers(),
PhdrE = end_program_headers();
for (Elf_Phdr_Iter PhdrI = program_header_begin(),
PhdrE = program_header_end();
PhdrI != PhdrE; ++PhdrI) {
if (PhdrI->p_type == ELF::PT_DYNAMIC) {
DynamicRegion.Addr = base() + PhdrI->p_offset;
Expand All @@ -704,15 +704,15 @@ ELFFile<ELFT>::ELFFile(StringRef Object, std::error_code &EC)
}

// Scan dynamic table.
for (Elf_Dyn_Iter DynI = begin_dynamic_table(), DynE = end_dynamic_table();
DynI != DynE; ++DynI) {
for (Elf_Dyn_Iter DynI = dynamic_table_begin(), DynE = dynamic_table_end();
DynI != DynE; ++DynI) {
switch (DynI->d_tag) {
case ELF::DT_RELA: {
uint64_t VBase = 0;
const uint8_t *FBase = nullptr;
for (Elf_Phdr_Iter PhdrI = begin_program_headers(),
PhdrE = end_program_headers();
PhdrI != PhdrE; ++PhdrI) {
for (Elf_Phdr_Iter PhdrI = program_header_begin(),
PhdrE = program_header_end();
PhdrI != PhdrE; ++PhdrI) {
if (PhdrI->p_type != ELF::PT_LOAD)
continue;
if (DynI->getPtr() >= PhdrI->p_vaddr &&
Expand Down Expand Up @@ -751,20 +751,20 @@ uint64_t ELFFile<ELFT>::getSymbolIndex(const Elf_Sym *Sym) const {
}

template <class ELFT>
typename ELFFile<ELFT>::Elf_Shdr_Iter ELFFile<ELFT>::begin_sections() const {
typename ELFFile<ELFT>::Elf_Shdr_Iter ELFFile<ELFT>::section_begin() const {
return Elf_Shdr_Iter(Header->e_shentsize,
(const char *)base() + Header->e_shoff);
}

template <class ELFT>
typename ELFFile<ELFT>::Elf_Shdr_Iter ELFFile<ELFT>::end_sections() const {
typename ELFFile<ELFT>::Elf_Shdr_Iter ELFFile<ELFT>::section_end() const {
return Elf_Shdr_Iter(Header->e_shentsize,
(const char *)base() + Header->e_shoff +
(getNumSections() * Header->e_shentsize));
}

template <class ELFT>
const typename ELFFile<ELFT>::Elf_Sym *ELFFile<ELFT>::begin_symbols() const {
const typename ELFFile<ELFT>::Elf_Sym *ELFFile<ELFT>::symbol_begin() const {
if (!dot_symtab_sec)
return nullptr;
if (dot_symtab_sec->sh_entsize != sizeof(Elf_Sym))
Expand All @@ -773,7 +773,7 @@ const typename ELFFile<ELFT>::Elf_Sym *ELFFile<ELFT>::begin_symbols() const {
}

template <class ELFT>
const typename ELFFile<ELFT>::Elf_Sym *ELFFile<ELFT>::end_symbols() const {
const typename ELFFile<ELFT>::Elf_Sym *ELFFile<ELFT>::symbol_end() const {
if (!dot_symtab_sec)
return nullptr;
return reinterpret_cast<const Elf_Sym *>(base() + dot_symtab_sec->sh_offset +
Expand All @@ -782,7 +782,7 @@ const typename ELFFile<ELFT>::Elf_Sym *ELFFile<ELFT>::end_symbols() const {

template <class ELFT>
typename ELFFile<ELFT>::Elf_Dyn_Iter
ELFFile<ELFT>::begin_dynamic_table() const {
ELFFile<ELFT>::dynamic_table_begin() const {
if (DynamicRegion.Addr)
return Elf_Dyn_Iter(DynamicRegion.EntSize,
(const char *)DynamicRegion.Addr);
Expand All @@ -791,14 +791,14 @@ ELFFile<ELFT>::begin_dynamic_table() const {

template <class ELFT>
typename ELFFile<ELFT>::Elf_Dyn_Iter
ELFFile<ELFT>::end_dynamic_table(bool NULLEnd) const {
ELFFile<ELFT>::dynamic_table_end(bool NULLEnd) const {
if (!DynamicRegion.Addr)
return Elf_Dyn_Iter(0, nullptr);
Elf_Dyn_Iter Ret(DynamicRegion.EntSize,
(const char *)DynamicRegion.Addr + DynamicRegion.Size);

if (NULLEnd) {
Elf_Dyn_Iter Start = begin_dynamic_table();
Elf_Dyn_Iter Start = dynamic_table_begin();
while (Start != Ret && Start->getTag() != ELF::DT_NULL)
++Start;

Expand Down
26 changes: 13 additions & 13 deletions include/llvm/Object/ELFObjectFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ uint32_t ELFObjectFile<ELFT>::getSymbolFlags(DataRefImpl Sym) const {
Result |= SymbolRef::SF_Absolute;

if (ESym->getType() == ELF::STT_FILE || ESym->getType() == ELF::STT_SECTION ||
ESym == EF.begin_symbols() || ESym == EF.begin_dynamic_symbols())
ESym == EF.symbol_begin() || ESym == EF.dynamic_symbol_begin())
Result |= SymbolRef::SF_FormatSpecific;

if (EF.getHeader()->e_machine == ELF::EM_ARM) {
Expand Down Expand Up @@ -617,7 +617,7 @@ template <class ELFT>
relocation_iterator
ELFObjectFile<ELFT>::section_rel_begin(DataRefImpl Sec) const {
DataRefImpl RelData;
uintptr_t SHT = reinterpret_cast<uintptr_t>(EF.begin_sections().get());
uintptr_t SHT = reinterpret_cast<uintptr_t>(EF.section_begin().get());
RelData.d.a = (Sec.p - SHT) / EF.getHeader()->e_shentsize;
RelData.d.b = 0;
return relocation_iterator(RelocationRef(RelData, this));
Expand All @@ -627,7 +627,7 @@ template <class ELFT>
relocation_iterator
ELFObjectFile<ELFT>::section_rel_end(DataRefImpl Sec) const {
DataRefImpl RelData;
uintptr_t SHT = reinterpret_cast<uintptr_t>(EF.begin_sections().get());
uintptr_t SHT = reinterpret_cast<uintptr_t>(EF.section_begin().get());
const Elf_Shdr *S = reinterpret_cast<const Elf_Shdr *>(Sec.p);
RelData.d.a = (Sec.p - SHT) / EF.getHeader()->e_shentsize;
if (S->sh_type != ELF::SHT_RELA && S->sh_type != ELF::SHT_REL)
Expand Down Expand Up @@ -678,10 +678,10 @@ ELFObjectFile<ELFT>::getRelocationSymbol(DataRefImpl Rel) const {
default:
report_fatal_error("Invalid symbol table section type!");
case ELF::SHT_SYMTAB:
SymbolData = toDRI(EF.begin_symbols() + symbolIdx, false);
SymbolData = toDRI(EF.symbol_begin() + symbolIdx, false);
break;
case ELF::SHT_DYNSYM:
SymbolData = toDRI(EF.begin_dynamic_symbols() + symbolIdx, true);
SymbolData = toDRI(EF.dynamic_symbol_begin() + symbolIdx, true);
break;
}

Expand Down Expand Up @@ -782,42 +782,42 @@ ELFObjectFile<ELFT>::ELFObjectFile(MemoryBufferRef Object, std::error_code &EC)

template <class ELFT>
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_begin_impl() const {
DataRefImpl Sym = toDRI(EF.begin_symbols(), false);
DataRefImpl Sym = toDRI(EF.symbol_begin(), false);
return basic_symbol_iterator(SymbolRef(Sym, this));
}

template <class ELFT>
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_end_impl() const {
DataRefImpl Sym = toDRI(EF.end_symbols(), false);
DataRefImpl Sym = toDRI(EF.symbol_end(), false);
return basic_symbol_iterator(SymbolRef(Sym, this));
}

template <class ELFT>
elf_symbol_iterator ELFObjectFile<ELFT>::dynamic_symbol_begin() const {
DataRefImpl Sym = toDRI(EF.begin_dynamic_symbols(), true);
DataRefImpl Sym = toDRI(EF.dynamic_symbol_begin(), true);
return symbol_iterator(SymbolRef(Sym, this));
}

template <class ELFT>
elf_symbol_iterator ELFObjectFile<ELFT>::dynamic_symbol_end() const {
DataRefImpl Sym = toDRI(EF.end_dynamic_symbols(), true);
DataRefImpl Sym = toDRI(EF.dynamic_symbol_end(), true);
return symbol_iterator(SymbolRef(Sym, this));
}

template <class ELFT>
section_iterator ELFObjectFile<ELFT>::section_begin() const {
return section_iterator(SectionRef(toDRI(EF.begin_sections()), this));
return section_iterator(SectionRef(toDRI(EF.section_begin()), this));
}

template <class ELFT>
section_iterator ELFObjectFile<ELFT>::section_end() const {
return section_iterator(SectionRef(toDRI(EF.end_sections()), this));
return section_iterator(SectionRef(toDRI(EF.section_end()), this));
}

template <class ELFT>
StringRef ELFObjectFile<ELFT>::getLoadName() const {
Elf_Dyn_Iter DI = EF.begin_dynamic_table();
Elf_Dyn_Iter DE = EF.end_dynamic_table();
Elf_Dyn_Iter DI = EF.dynamic_table_begin();
Elf_Dyn_Iter DE = EF.dynamic_table_end();

while (DI != DE && DI->getTag() != ELF::DT_SONAME)
++DI;
Expand Down
6 changes: 3 additions & 3 deletions tools/llvm-objdump/ELFDump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ using namespace llvm::object;
template <class ELFT> void printProgramHeaders(const ELFFile<ELFT> *o) {
typedef ELFFile<ELFT> ELFO;
outs() << "Program Header:\n";
for (typename ELFO::Elf_Phdr_Iter pi = o->begin_program_headers(),
pe = o->end_program_headers();
pi != pe; ++pi) {
for (typename ELFO::Elf_Phdr_Iter pi = o->program_header_begin(),
pe = o->program_header_end();
pi != pe; ++pi) {
switch (pi->p_type) {
case ELF::PT_LOAD:
outs() << " LOAD ";
Expand Down
6 changes: 3 additions & 3 deletions tools/llvm-readobj/ARMEHABIPrinter.h
Original file line number Diff line number Diff line change
Expand Up @@ -365,10 +365,10 @@ PrinterContext<ET>::FindExceptionTable(unsigned IndexSectionIndex,
/// handling table. Use this symbol to recover the actual exception handling
/// table.

for (Elf_Shdr_iterator SI = ELF->begin_sections(), SE = ELF->end_sections();
for (Elf_Shdr_iterator SI = ELF->section_begin(), SE = ELF->section_end();
SI != SE; ++SI) {
if (SI->sh_type == ELF::SHT_REL && SI->sh_info == IndexSectionIndex) {
for (Elf_Rel_iterator RI = ELF->begin_rel(&*SI), RE = ELF->end_rel(&*SI);
for (Elf_Rel_iterator RI = ELF->rel_begin(&*SI), RE = ELF->rel_end(&*SI);
RI != RE; ++RI) {
if (RI->r_offset == static_cast<unsigned>(IndexTableOffset)) {
typename object::ELFFile<ET>::Elf_Rela RelA;
Expand Down Expand Up @@ -527,7 +527,7 @@ void PrinterContext<ET>::PrintUnwindInformation() const {
DictScope UI(SW, "UnwindInformation");

int SectionIndex = 0;
for (Elf_Shdr_iterator SI = ELF->begin_sections(), SE = ELF->end_sections();
for (Elf_Shdr_iterator SI = ELF->section_begin(), SE = ELF->section_end();
SI != SE; ++SI, ++SectionIndex) {
if (SI->sh_type == ELF::SHT_ARM_EXIDX) {
const Elf_Shdr *IT = &(*SI);
Expand Down
Loading

0 comments on commit 28bec63

Please sign in to comment.