From 28bec63a7e95493f681a305c1a6e3b367835d814 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 30 Jun 2015 15:33:44 +0000 Subject: [PATCH] Fix the name of the iterator functions to match the coding standards. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241074 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Object/ELF.h | 70 ++++++++++++++-------------- include/llvm/Object/ELFObjectFile.h | 26 +++++------ tools/llvm-objdump/ELFDump.cpp | 6 +-- tools/llvm-readobj/ARMEHABIPrinter.h | 6 +-- tools/llvm-readobj/ELFDumper.cpp | 36 +++++++------- tools/obj2yaml/elf2yaml.cpp | 7 ++- 6 files changed, 75 insertions(+), 76 deletions(-) diff --git a/include/llvm/Object/ELF.h b/include/llvm/Object/ELF.h index 4c9cacd7e51..7953dba164f 100644 --- a/include/llvm/Object/ELF.h +++ b/include/llvm/Object/ELF.h @@ -264,27 +264,27 @@ public: 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)) @@ -292,7 +292,7 @@ public: return reinterpret_cast(DynSymRegion.Addr); } - const Elf_Sym *end_dynamic_symbols() const { + const Elf_Sym *dynamic_symbol_end() const { if (!DynSymRegion.Addr) return nullptr; return reinterpret_cast( @@ -300,17 +300,17 @@ public: } 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, @@ -318,23 +318,23 @@ public: 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)); } @@ -342,12 +342,12 @@ public: /// \brief Iterate over program header table. typedef ELFEntityIterator 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 + @@ -478,7 +478,7 @@ ELFFile::getSection(const Elf_Sym *symb) const { template const typename ELFFile::Elf_Sym * ELFFile::getSymbol(uint32_t Index) const { - return &*(begin_symbols() + Index); + return &*(symbol_begin() + Index); } template @@ -692,8 +692,8 @@ ELFFile::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; @@ -704,15 +704,15 @@ ELFFile::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 && @@ -751,20 +751,20 @@ uint64_t ELFFile::getSymbolIndex(const Elf_Sym *Sym) const { } template -typename ELFFile::Elf_Shdr_Iter ELFFile::begin_sections() const { +typename ELFFile::Elf_Shdr_Iter ELFFile::section_begin() const { return Elf_Shdr_Iter(Header->e_shentsize, (const char *)base() + Header->e_shoff); } template -typename ELFFile::Elf_Shdr_Iter ELFFile::end_sections() const { +typename ELFFile::Elf_Shdr_Iter ELFFile::section_end() const { return Elf_Shdr_Iter(Header->e_shentsize, (const char *)base() + Header->e_shoff + (getNumSections() * Header->e_shentsize)); } template -const typename ELFFile::Elf_Sym *ELFFile::begin_symbols() const { +const typename ELFFile::Elf_Sym *ELFFile::symbol_begin() const { if (!dot_symtab_sec) return nullptr; if (dot_symtab_sec->sh_entsize != sizeof(Elf_Sym)) @@ -773,7 +773,7 @@ const typename ELFFile::Elf_Sym *ELFFile::begin_symbols() const { } template -const typename ELFFile::Elf_Sym *ELFFile::end_symbols() const { +const typename ELFFile::Elf_Sym *ELFFile::symbol_end() const { if (!dot_symtab_sec) return nullptr; return reinterpret_cast(base() + dot_symtab_sec->sh_offset + @@ -782,7 +782,7 @@ const typename ELFFile::Elf_Sym *ELFFile::end_symbols() const { template typename ELFFile::Elf_Dyn_Iter -ELFFile::begin_dynamic_table() const { +ELFFile::dynamic_table_begin() const { if (DynamicRegion.Addr) return Elf_Dyn_Iter(DynamicRegion.EntSize, (const char *)DynamicRegion.Addr); @@ -791,14 +791,14 @@ ELFFile::begin_dynamic_table() const { template typename ELFFile::Elf_Dyn_Iter -ELFFile::end_dynamic_table(bool NULLEnd) const { +ELFFile::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; diff --git a/include/llvm/Object/ELFObjectFile.h b/include/llvm/Object/ELFObjectFile.h index e689dc2a34e..7623ea4e097 100644 --- a/include/llvm/Object/ELFObjectFile.h +++ b/include/llvm/Object/ELFObjectFile.h @@ -490,7 +490,7 @@ uint32_t ELFObjectFile::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) { @@ -617,7 +617,7 @@ template relocation_iterator ELFObjectFile::section_rel_begin(DataRefImpl Sec) const { DataRefImpl RelData; - uintptr_t SHT = reinterpret_cast(EF.begin_sections().get()); + uintptr_t SHT = reinterpret_cast(EF.section_begin().get()); RelData.d.a = (Sec.p - SHT) / EF.getHeader()->e_shentsize; RelData.d.b = 0; return relocation_iterator(RelocationRef(RelData, this)); @@ -627,7 +627,7 @@ template relocation_iterator ELFObjectFile::section_rel_end(DataRefImpl Sec) const { DataRefImpl RelData; - uintptr_t SHT = reinterpret_cast(EF.begin_sections().get()); + uintptr_t SHT = reinterpret_cast(EF.section_begin().get()); const Elf_Shdr *S = reinterpret_cast(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) @@ -678,10 +678,10 @@ ELFObjectFile::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; } @@ -782,42 +782,42 @@ ELFObjectFile::ELFObjectFile(MemoryBufferRef Object, std::error_code &EC) template basic_symbol_iterator ELFObjectFile::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 basic_symbol_iterator ELFObjectFile::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 elf_symbol_iterator ELFObjectFile::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 elf_symbol_iterator ELFObjectFile::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 section_iterator ELFObjectFile::section_begin() const { - return section_iterator(SectionRef(toDRI(EF.begin_sections()), this)); + return section_iterator(SectionRef(toDRI(EF.section_begin()), this)); } template section_iterator ELFObjectFile::section_end() const { - return section_iterator(SectionRef(toDRI(EF.end_sections()), this)); + return section_iterator(SectionRef(toDRI(EF.section_end()), this)); } template StringRef ELFObjectFile::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; diff --git a/tools/llvm-objdump/ELFDump.cpp b/tools/llvm-objdump/ELFDump.cpp index 9c091a410d8..2d0d7d7db0f 100644 --- a/tools/llvm-objdump/ELFDump.cpp +++ b/tools/llvm-objdump/ELFDump.cpp @@ -24,9 +24,9 @@ using namespace llvm::object; template void printProgramHeaders(const ELFFile *o) { typedef ELFFile 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 "; diff --git a/tools/llvm-readobj/ARMEHABIPrinter.h b/tools/llvm-readobj/ARMEHABIPrinter.h index 7fbe792d296..9e13e385538 100644 --- a/tools/llvm-readobj/ARMEHABIPrinter.h +++ b/tools/llvm-readobj/ARMEHABIPrinter.h @@ -365,10 +365,10 @@ PrinterContext::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(IndexTableOffset)) { typename object::ELFFile::Elf_Rela RelA; @@ -527,7 +527,7 @@ void PrinterContext::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); diff --git a/tools/llvm-readobj/ELFDumper.cpp b/tools/llvm-readobj/ELFDumper.cpp index c185e2944f0..513db8f321d 100644 --- a/tools/llvm-readobj/ELFDumper.cpp +++ b/tools/llvm-readobj/ELFDumper.cpp @@ -616,8 +616,8 @@ void ELFDumper::printSections() { ListScope SectionsD(W, "Sections"); int SectionIndex = -1; - for (typename ELFO::Elf_Shdr_Iter SecI = Obj->begin_sections(), - SecE = Obj->end_sections(); + for (typename ELFO::Elf_Shdr_Iter SecI = Obj->section_begin(), + SecE = Obj->section_end(); SecI != SecE; ++SecI) { ++SectionIndex; @@ -665,8 +665,8 @@ void ELFDumper::printRelocations() { ListScope D(W, "Relocations"); int SectionNumber = -1; - for (typename ELFO::Elf_Shdr_Iter SecI = Obj->begin_sections(), - SecE = Obj->end_sections(); + for (typename ELFO::Elf_Shdr_Iter SecI = Obj->section_begin(), + SecE = Obj->section_end(); SecI != SecE; ++SecI) { ++SectionNumber; @@ -689,14 +689,14 @@ template void ELFDumper::printDynamicRelocations() { W.startLine() << "Dynamic Relocations {\n"; W.indent(); - for (typename ELFO::Elf_Rela_Iter RelI = Obj->begin_dyn_rela(), - RelE = Obj->end_dyn_rela(); - RelI != RelE; ++RelI) { + for (typename ELFO::Elf_Rela_Iter RelI = Obj->dyn_rela_begin(), + RelE = Obj->dyn_rela_end(); + RelI != RelE; ++RelI) { SmallString<32> RelocName; Obj->getRelocationTypeName(RelI->getType(Obj->isMips64EL()), RelocName); StringRef SymbolName; uint32_t SymIndex = RelI->getSymbol(Obj->isMips64EL()); - const typename ELFO::Elf_Sym *Sym = Obj->begin_dynamic_symbols() + SymIndex; + const typename ELFO::Elf_Sym *Sym = Obj->dynamic_symbol_begin() + SymIndex; SymbolName = errorOrDefault(Obj->getSymbolName(Sym, true)); if (opts::ExpandRelocs) { DictScope Group(W, "Relocation"); @@ -722,8 +722,8 @@ template void ELFDumper::printRelocations(const Elf_Shdr *Sec) { switch (Sec->sh_type) { case ELF::SHT_REL: - for (typename ELFO::Elf_Rel_Iter RI = Obj->begin_rel(Sec), - RE = Obj->end_rel(Sec); + for (typename ELFO::Elf_Rel_Iter RI = Obj->rel_begin(Sec), + RE = Obj->rel_end(Sec); RI != RE; ++RI) { typename ELFO::Elf_Rela Rela; Rela.r_offset = RI->r_offset; @@ -733,8 +733,8 @@ void ELFDumper::printRelocations(const Elf_Shdr *Sec) { } break; case ELF::SHT_RELA: - for (typename ELFO::Elf_Rela_Iter RI = Obj->begin_rela(Sec), - RE = Obj->end_rela(Sec); + for (typename ELFO::Elf_Rela_Iter RI = Obj->rela_begin(Sec), + RE = Obj->rela_end(Sec); RI != RE; ++RI) { printRelocation(Sec, *RI); } @@ -1099,9 +1099,9 @@ template void ELFDumper::printProgramHeaders() { ListScope L(W, "ProgramHeaders"); - for (typename ELFO::Elf_Phdr_Iter PI = Obj->begin_program_headers(), - PE = Obj->end_program_headers(); - PI != PE; ++PI) { + for (typename ELFO::Elf_Phdr_Iter PI = Obj->program_header_begin(), + PE = Obj->program_header_end(); + PI != PE; ++PI) { DictScope P(W, "ProgramHeader"); W.printHex ("Type", getElfSegmentType(Obj->getHeader()->e_machine, PI->p_type), @@ -1129,7 +1129,7 @@ template <> void ELFDumper>::printAttributes() { } DictScope BA(W, "BuildAttributes"); - for (ELFO::Elf_Shdr_Iter SI = Obj->begin_sections(), SE = Obj->end_sections(); + for (ELFO::Elf_Shdr_Iter SI = Obj->section_begin(), SE = Obj->section_end(); SI != SE; ++SI) { if (SI->sh_type != ELF::SHT_ARM_ATTRIBUTES) continue; @@ -1204,8 +1204,8 @@ void MipsGOTParser::parseGOT(const Elf_Shdr &GOTShdr) { return; } - const Elf_Sym *DynSymBegin = Obj->begin_dynamic_symbols(); - const Elf_Sym *DynSymEnd = Obj->end_dynamic_symbols(); + const Elf_Sym *DynSymBegin = Obj->dynamic_symbol_begin(); + const Elf_Sym *DynSymEnd = Obj->dynamic_symbol_end(); std::size_t DynSymTotal = std::size_t(std::distance(DynSymBegin, DynSymEnd)); if (DtGotSym > DynSymTotal) { diff --git a/tools/obj2yaml/elf2yaml.cpp b/tools/obj2yaml/elf2yaml.cpp index e738945b4bd..db384b05085 100644 --- a/tools/obj2yaml/elf2yaml.cpp +++ b/tools/obj2yaml/elf2yaml.cpp @@ -115,7 +115,7 @@ ErrorOr ELFDumper::dump() { // Dump symbols bool IsFirstSym = true; - for (auto SI = Obj.begin_symbols(), SE = Obj.end_symbols(); SI != SE; ++SI) { + for (auto SI = Obj.symbol_begin(), SE = Obj.symbol_end(); SI != SE; ++SI) { if (IsFirstSym) { IsFirstSym = false; continue; @@ -248,8 +248,7 @@ ELFDumper::dumpRelSection(const Elf_Shdr *Shdr) { if (std::error_code EC = dumpCommonRelocationSection(Shdr, *S)) return EC; - for (auto RI = Obj.begin_rel(Shdr), RE = Obj.end_rel(Shdr); RI != RE; - ++RI) { + for (auto RI = Obj.rel_begin(Shdr), RE = Obj.rel_end(Shdr); RI != RE; ++RI) { ELFYAML::Relocation R; if (std::error_code EC = dumpRelocation(Shdr, &*RI, R)) return EC; @@ -268,7 +267,7 @@ ELFDumper::dumpRelaSection(const Elf_Shdr *Shdr) { if (std::error_code EC = dumpCommonRelocationSection(Shdr, *S)) return EC; - for (auto RI = Obj.begin_rela(Shdr), RE = Obj.end_rela(Shdr); RI != RE; + for (auto RI = Obj.rela_begin(Shdr), RE = Obj.rela_end(Shdr); RI != RE; ++RI) { ELFYAML::Relocation R; if (std::error_code EC = dumpRelocation(Shdr, &*RI, R)) -- 2.34.1