diff options
author | Alexey Samsonov <samsonov@google.com> | 2014-03-14 14:22:49 +0000 |
---|---|---|
committer | Alexey Samsonov <samsonov@google.com> | 2014-03-14 14:22:49 +0000 |
commit | aa4d29571c832c1fc706f047e3ee099a133b179b (patch) | |
tree | 5c24ba4009faa1bd85f515783fc3861abadc7522 /llvm/lib | |
parent | 68627942069e29129a685fba09104cf32fbc8298 (diff) | |
download | bcm5719-llvm-aa4d29571c832c1fc706f047e3ee099a133b179b.tar.gz bcm5719-llvm-aa4d29571c832c1fc706f047e3ee099a133b179b.zip |
[C++11] Introduce SectionRef::relocations() to use range-based loops
Reviewers: rafael
Reviewed By: rafael
CC: llvm-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D3077
llvm-svn: 203927
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/DebugInfo/DWARFContext.cpp | 14 | ||||
-rw-r--r-- | llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp | 13 | ||||
-rw-r--r-- | llvm/lib/MC/MCObjectSymbolizer.cpp | 12 |
3 files changed, 16 insertions, 23 deletions
diff --git a/llvm/lib/DebugInfo/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARFContext.cpp index 8a245a0301d..0afe6ef6e13 100644 --- a/llvm/lib/DebugInfo/DWARFContext.cpp +++ b/llvm/lib/DebugInfo/DWARFContext.cpp @@ -699,26 +699,24 @@ DWARFContextInMemory::DWARFContextInMemory(object::ObjectFile *Obj) if (Section.relocation_begin() != Section.relocation_end()) { uint64_t SectionSize; RelocatedSection->getSize(SectionSize); - for (object::relocation_iterator reloc_i = Section.relocation_begin(), - reloc_e = Section.relocation_end(); - reloc_i != reloc_e; ++reloc_i) { + for (const RelocationRef &Reloc : Section.relocations()) { uint64_t Address; - reloc_i->getOffset(Address); + Reloc.getOffset(Address); uint64_t Type; - reloc_i->getType(Type); + Reloc.getType(Type); uint64_t SymAddr = 0; // ELF relocations may need the symbol address if (Obj->isELF()) { - object::symbol_iterator Sym = reloc_i->getSymbol(); + object::symbol_iterator Sym = Reloc.getSymbol(); Sym->getAddress(SymAddr); } object::RelocVisitor V(Obj->getFileFormatName()); // The section address is always 0 for debug sections. - object::RelocToApply R(V.visit(Type, *reloc_i, 0, SymAddr)); + object::RelocToApply R(V.visit(Type, Reloc, 0, SymAddr)); if (V.error()) { SmallString<32> Name; - error_code ec(reloc_i->getTypeName(Name)); + error_code ec(Reloc.getTypeName(Name)); if (ec) { errs() << "Aaaaaa! Nameless relocation! Aaaaaa!\n"; } diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp index 723a790b87e..5d6a2c0f123 100644 --- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp +++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp @@ -166,9 +166,7 @@ ObjectImage* RuntimeDyldImpl::loadObject(ObjectImage *InputObject) { StubMap Stubs; section_iterator RelocatedSection = SI->getRelocatedSection(); - for (relocation_iterator I = SI->relocation_begin(), - E = SI->relocation_end(); - I != E; ++I) { + for (const RelocationRef &Reloc : SI->relocations()) { // If it's the first relocation in this section, find its SectionID if (IsFirstRelocation) { bool IsCode = false; @@ -179,7 +177,7 @@ ObjectImage* RuntimeDyldImpl::loadObject(ObjectImage *InputObject) { IsFirstRelocation = false; } - processRelocationRef(SectionID, *I, *Obj, LocalSections, LocalSymbols, + processRelocationRef(SectionID, Reloc, *Obj, LocalSections, LocalSymbols, Stubs); } } @@ -306,13 +304,12 @@ unsigned RuntimeDyldImpl::computeSectionStubBufSize(ObjectImage &Obj, if (!(RelSecI == Section)) continue; - for (relocation_iterator I = SI->relocation_begin(), - E = SI->relocation_end(); - I != E; ++I) { + for (const RelocationRef &Reloc : SI->relocations()) { + (void)Reloc; StubBufSize += StubSize; } } - + // Get section data size and alignment uint64_t Alignment64; uint64_t DataSize; diff --git a/llvm/lib/MC/MCObjectSymbolizer.cpp b/llvm/lib/MC/MCObjectSymbolizer.cpp index 4548a7d4251..ee2d9553ecb 100644 --- a/llvm/lib/MC/MCObjectSymbolizer.cpp +++ b/llvm/lib/MC/MCObjectSymbolizer.cpp @@ -263,9 +263,7 @@ void MCObjectSymbolizer::buildRelocationByAddrMap() { RelSecI->isRequiredForExecution(RequiredForExec); if (RequiredForExec == false || Size == 0) continue; - for (relocation_iterator RI = Section.relocation_begin(), - RE = Section.relocation_end(); - RI != RE; ++RI) { + for (const RelocationRef &Reloc : Section.relocations()) { // FIXME: libObject is inconsistent regarding error handling. The // overwhelming majority of methods always return object_error::success, // and assert for simple errors.. Here, ELFObjectFile::getRelocationOffset @@ -277,18 +275,18 @@ void MCObjectSymbolizer::buildRelocationByAddrMap() { if (ELFObj == 0) break; if (ELFObj->getELFFile()->getHeader()->e_type == ELF::ET_REL) { - RI->getOffset(Offset); + Reloc.getOffset(Offset); Offset += StartAddr; } else { - RI->getAddress(Offset); + Reloc.getAddress(Offset); } } else { - RI->getOffset(Offset); + Reloc.getOffset(Offset); Offset += StartAddr; } // At a specific address, only keep the first relocation. if (AddrToReloc.find(Offset) == AddrToReloc.end()) - AddrToReloc[Offset] = *RI; + AddrToReloc[Offset] = Reloc; } } } |