summaryrefslogtreecommitdiff
path: root/lib/DebugInfo
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2014-03-13 13:52:54 +0000
committerAlexey Samsonov <samsonov@google.com>2014-03-13 13:52:54 +0000
commitb920dfe02b4fb88bafa64ab85800c00faba47f5d (patch)
treea65cfaf7f9f3c04d04f8cf33f842fc683daae575 /lib/DebugInfo
parentf8909fa1406eba023f9fadfa7e8182630d3ea14a (diff)
downloadllvm-b920dfe02b4fb88bafa64ab85800c00faba47f5d.tar.gz
llvm-b920dfe02b4fb88bafa64ab85800c00faba47f5d.tar.bz2
llvm-b920dfe02b4fb88bafa64ab85800c00faba47f5d.tar.xz
[C++11] Introduce ObjectFile::sections().
Summary: This adds ObjectFile::section_iterator_range, that allows to write range-based for-loops running over all sections of a given file. Several files from lib/ are converted to the new interface. Similar fixes should be applied to a variety of llvm-* tools. Reviewers: rafael Reviewed By: rafael CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D3069 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203799 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/DebugInfo')
-rw-r--r--lib/DebugInfo/DWARFContext.cpp32
1 files changed, 15 insertions, 17 deletions
diff --git a/lib/DebugInfo/DWARFContext.cpp b/lib/DebugInfo/DWARFContext.cpp
index 94935e2568..8a245a0301 100644
--- a/lib/DebugInfo/DWARFContext.cpp
+++ b/lib/DebugInfo/DWARFContext.cpp
@@ -605,16 +605,14 @@ static bool consumeCompressedDebugSectionHeader(StringRef &data,
return true;
}
-DWARFContextInMemory::DWARFContextInMemory(object::ObjectFile *Obj) :
- IsLittleEndian(Obj->isLittleEndian()),
- AddressSize(Obj->getBytesInAddress()) {
- for (object::section_iterator i = Obj->section_begin(),
- e = Obj->section_end();
- i != e; ++i) {
+DWARFContextInMemory::DWARFContextInMemory(object::ObjectFile *Obj)
+ : IsLittleEndian(Obj->isLittleEndian()),
+ AddressSize(Obj->getBytesInAddress()) {
+ for (const SectionRef &Section : Obj->sections()) {
StringRef name;
- i->getName(name);
+ Section.getName(name);
StringRef data;
- i->getContents(data);
+ Section.getContents(data);
name = name.substr(name.find_first_not_of("._")); // Skip . and _ prefixes.
@@ -634,7 +632,7 @@ DWARFContextInMemory::DWARFContextInMemory(object::ObjectFile *Obj) :
UncompressedSections.push_back(std::move(UncompressedSection));
}
- StringRef *Section =
+ StringRef *SectionData =
StringSwitch<StringRef *>(name)
.Case("debug_info", &InfoSection.Data)
.Case("debug_abbrev", &AbbrevSection)
@@ -656,8 +654,8 @@ DWARFContextInMemory::DWARFContextInMemory(object::ObjectFile *Obj) :
.Case("debug_addr", &AddrSection)
// Any more debug info sections go here.
.Default(0);
- if (Section) {
- *Section = data;
+ if (SectionData) {
+ *SectionData = data;
if (name == "debug_ranges") {
// FIXME: Use the other dwo range section when we emit it.
RangeDWOSection = data;
@@ -665,12 +663,12 @@ DWARFContextInMemory::DWARFContextInMemory(object::ObjectFile *Obj) :
} else if (name == "debug_types") {
// Find debug_types data by section rather than name as there are
// multiple, comdat grouped, debug_types sections.
- TypesSections[*i].Data = data;
+ TypesSections[Section].Data = data;
} else if (name == "debug_types.dwo") {
- TypesDWOSections[*i].Data = data;
+ TypesDWOSections[Section].Data = data;
}
- section_iterator RelocatedSection = i->getRelocatedSection();
+ section_iterator RelocatedSection = Section.getRelocatedSection();
if (RelocatedSection == Obj->section_end())
continue;
@@ -698,11 +696,11 @@ DWARFContextInMemory::DWARFContextInMemory(object::ObjectFile *Obj) :
continue;
}
- if (i->relocation_begin() != i->relocation_end()) {
+ if (Section.relocation_begin() != Section.relocation_end()) {
uint64_t SectionSize;
RelocatedSection->getSize(SectionSize);
- for (object::relocation_iterator reloc_i = i->relocation_begin(),
- reloc_e = i->relocation_end();
+ for (object::relocation_iterator reloc_i = Section.relocation_begin(),
+ reloc_e = Section.relocation_end();
reloc_i != reloc_e; ++reloc_i) {
uint64_t Address;
reloc_i->getOffset(Address);