[lld] r207953 - [ELF] Use a range based access to the ELFFile's sections collection.
Simon Atanasyan
simon at atanasyan.com
Mon May 5 00:17:40 PDT 2014
Author: atanasyan
Date: Mon May 5 02:17:40 2014
New Revision: 207953
URL: http://llvm.org/viewvc/llvm-project?rev=207953&view=rev
Log:
[ELF] Use a range based access to the ELFFile's sections collection.
No functional changes.
Modified:
lld/trunk/lib/ReaderWriter/ELF/ELFFile.h
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFile.h
Modified: lld/trunk/lib/ReaderWriter/ELF/ELFFile.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFFile.h?rev=207953&r1=207952&r2=207953&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ELFFile.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ELFFile.h Mon May 5 02:17:40 2014
@@ -465,47 +465,44 @@ template <class ELFT> error_code ELFFile
// the contents to the RelocationReferences map.
// Record the number of relocs to guess at preallocating the buffer.
uint64_t totalRelocs = 0;
- for (auto sit = _objFile->begin_sections(), sie = _objFile->end_sections();
- sit != sie; ++sit) {
- const Elf_Shdr *section = &*sit;
-
- if (isIgnoredSection(section))
+ for (const Elf_Shdr §ion : _objFile->sections()) {
+ if (isIgnoredSection(§ion))
continue;
- if (isMergeableStringSection(section)) {
- _mergeStringSections.push_back(section);
+ if (isMergeableStringSection(§ion)) {
+ _mergeStringSections.push_back(§ion);
continue;
}
// Create a sectionSymbols entry for every progbits section.
- if ((section->sh_type == llvm::ELF::SHT_PROGBITS) ||
- (section->sh_type == llvm::ELF::SHT_INIT_ARRAY) ||
- (section->sh_type == llvm::ELF::SHT_FINI_ARRAY))
- _sectionSymbols[section];
+ if ((section.sh_type == llvm::ELF::SHT_PROGBITS) ||
+ (section.sh_type == llvm::ELF::SHT_INIT_ARRAY) ||
+ (section.sh_type == llvm::ELF::SHT_FINI_ARRAY))
+ _sectionSymbols[§ion];
- if (section->sh_type == llvm::ELF::SHT_RELA) {
- auto sHdr = _objFile->getSection(section->sh_info);
+ if (section.sh_type == llvm::ELF::SHT_RELA) {
+ auto sHdr = _objFile->getSection(section.sh_info);
auto sectionName = _objFile->getSectionName(sHdr);
if (error_code ec = sectionName.getError())
return ec;
- auto rai(_objFile->begin_rela(section));
- auto rae(_objFile->end_rela(section));
+ auto rai(_objFile->begin_rela(§ion));
+ auto rae(_objFile->end_rela(§ion));
_relocationAddendReferences[*sectionName] = make_range(rai, rae);
totalRelocs += std::distance(rai, rae);
}
- if (section->sh_type == llvm::ELF::SHT_REL) {
- auto sHdr = _objFile->getSection(section->sh_info);
+ if (section.sh_type == llvm::ELF::SHT_REL) {
+ auto sHdr = _objFile->getSection(section.sh_info);
auto sectionName = _objFile->getSectionName(sHdr);
if (error_code ec = sectionName.getError())
return ec;
- auto ri(_objFile->begin_rel(section));
- auto re(_objFile->end_rel(section));
+ auto ri(_objFile->begin_rel(§ion));
+ auto re(_objFile->end_rel(§ion));
_relocationReferences[*sectionName] = make_range(ri, re);
totalRelocs += std::distance(ri, re);
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFile.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFile.h?rev=207953&r1=207952&r2=207953&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFile.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFile.h Mon May 5 02:17:40 2014
@@ -136,13 +136,11 @@ private:
error_code readRegInfo() {
typedef llvm::object::Elf_RegInfo<ELFT> Elf_RegInfo;
- for (auto sit = this->_objFile->begin_sections(),
- sie = this->_objFile->end_sections();
- sit != sie; ++sit) {
- if (sit->sh_type != llvm::ELF::SHT_MIPS_REGINFO)
+ for (const Elf_Shdr §ion : this->_objFile->sections()) {
+ if (section.sh_type != llvm::ELF::SHT_MIPS_REGINFO)
continue;
- auto contents = this->getSectionContents(&*sit);
+ auto contents = this->getSectionContents(§ion);
if (error_code ec = contents.getError())
return ec;
More information about the llvm-commits
mailing list