From 96545db374c2c495d9f791324601b5ae2514b46f Mon Sep 17 00:00:00 2001 From: Paul Robinson Date: Thu, 2 Aug 2018 19:29:38 +0000 Subject: [PATCH] [DebugInfo/DWARF] Remove redundant iterator type. NFC llvm-svn: 338759 --- .../llvm/DebugInfo/DWARF/DWARFContext.h | 47 ++++++++++++------- llvm/lib/DebugInfo/DWARF/DWARFContext.cpp | 45 ++++++++---------- llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp | 4 +- 3 files changed, 51 insertions(+), 45 deletions(-) diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h index 96e77d95e551..fc398bdf2629 100644 --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h @@ -132,49 +132,60 @@ public: bool verify(raw_ostream &OS, DIDumpOptions DumpOpts = {}) override; - using cu_iterator_range = DWARFUnitVector::iterator_range; - using tu_iterator_range = DWARFUnitVector::iterator_range; + using unit_iterator_range = DWARFUnitVector::iterator_range; /// Get units from .debug_info in this context. - cu_iterator_range info_section_units() { + unit_iterator_range info_section_units() { parseNormalUnits(); - return cu_iterator_range(NormalUnits.begin(), - NormalUnits.begin() + - NormalUnits.getNumInfoUnits()); + return unit_iterator_range(NormalUnits.begin(), + NormalUnits.begin() + + NormalUnits.getNumInfoUnits()); } /// Get units from .debug_types in this context. - tu_iterator_range types_section_units() { + unit_iterator_range types_section_units() { parseNormalUnits(); - return tu_iterator_range( + return unit_iterator_range( NormalUnits.begin() + NormalUnits.getNumInfoUnits(), NormalUnits.end()); } /// Get compile units in this context. - cu_iterator_range compile_units() { return info_section_units(); } + unit_iterator_range compile_units() { return info_section_units(); } /// Get type units in this context. - tu_iterator_range type_units() { return types_section_units(); } + unit_iterator_range type_units() { return types_section_units(); } + + /// Get all normal compile/type units in this context. + unit_iterator_range normal_units() { + parseNormalUnits(); + return unit_iterator_range(NormalUnits.begin(), NormalUnits.end()); + } /// Get units from .debug_info..dwo in the DWO context. - cu_iterator_range dwo_info_section_units() { + unit_iterator_range dwo_info_section_units() { parseDWOUnits(); - return cu_iterator_range(DWOUnits.begin(), - DWOUnits.begin() + DWOUnits.getNumInfoUnits()); + return unit_iterator_range(DWOUnits.begin(), + DWOUnits.begin() + DWOUnits.getNumInfoUnits()); } /// Get units from .debug_types.dwo in the DWO context. - tu_iterator_range dwo_types_section_units() { + unit_iterator_range dwo_types_section_units() { parseDWOUnits(); - return tu_iterator_range(DWOUnits.begin() + DWOUnits.getNumInfoUnits(), - DWOUnits.end()); + return unit_iterator_range(DWOUnits.begin() + DWOUnits.getNumInfoUnits(), + DWOUnits.end()); } /// Get compile units in the DWO context. - cu_iterator_range dwo_compile_units() { return dwo_info_section_units(); } + unit_iterator_range dwo_compile_units() { return dwo_info_section_units(); } /// Get type units in the DWO context. - tu_iterator_range dwo_type_units() { return dwo_types_section_units(); } + unit_iterator_range dwo_type_units() { return dwo_types_section_units(); } + + /// Get all units in the DWO context. + unit_iterator_range dwo_units() { + parseDWOUnits(); + return unit_iterator_range(DWOUnits.begin(), DWOUnits.end()); + } /// Get the number of compile units in this context. unsigned getNumCompileUnits() { diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp index 683da0664221..f00141ca91cb 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp @@ -99,13 +99,10 @@ using ContributionCollection = // Collect all the contributions to the string offsets table from all units, // sort them by their starting offsets and remove duplicates. static ContributionCollection -collectContributionData(DWARFContext::cu_iterator_range CUs, - DWARFContext::tu_iterator_range TUs) { +collectContributionData(DWARFContext::unit_iterator_range Units) { ContributionCollection Contributions; - for (const auto &CU : CUs) - Contributions.push_back(CU->getStringOffsetsTableContribution()); - for (const auto &TU : TUs) - Contributions.push_back(TU->getStringOffsetsTableContribution()); + for (const auto &U : Units) + Contributions.push_back(U->getStringOffsetsTableContribution()); // Sort the contributions so that any invalid ones are placed at // the start of the contributions vector. This way they are reported // first. @@ -134,9 +131,8 @@ collectContributionData(DWARFContext::cu_iterator_range CUs, static void dumpDWARFv5StringOffsetsSection( raw_ostream &OS, StringRef SectionName, const DWARFObject &Obj, const DWARFSection &StringOffsetsSection, StringRef StringSection, - DWARFContext::cu_iterator_range CUs, DWARFContext::tu_iterator_range TUs, - bool LittleEndian) { - auto Contributions = collectContributionData(CUs, TUs); + DWARFContext::unit_iterator_range Units, bool LittleEndian) { + auto Contributions = collectContributionData(Units); DWARFDataExtractor StrOffsetExt(Obj, StringOffsetsSection, LittleEndian, 0); DataExtractor StrData(StringSection, LittleEndian, 0); uint64_t SectionSize = StringOffsetsSection.Data.size(); @@ -217,15 +213,14 @@ static void dumpStringOffsetsSection(raw_ostream &OS, StringRef SectionName, const DWARFObject &Obj, const DWARFSection &StringOffsetsSection, StringRef StringSection, - DWARFContext::cu_iterator_range CUs, - DWARFContext::tu_iterator_range TUs, + DWARFContext::unit_iterator_range Units, bool LittleEndian, unsigned MaxVersion) { // If we have at least one (compile or type) unit with DWARF v5 or greater, // we assume that the section is formatted like a DWARF v5 string offsets // section. if (MaxVersion >= 5) dumpDWARFv5StringOffsetsSection(OS, SectionName, Obj, StringOffsetsSection, - StringSection, CUs, TUs, LittleEndian); + StringSection, Units, LittleEndian); else { DataExtractor strOffsetExt(StringOffsetsSection.Data, LittleEndian, 0); uint32_t offset = 0; @@ -340,14 +335,14 @@ void DWARFContext::dump( getDebugAbbrevDWO()->dump(OS); auto dumpDebugInfo = [&](bool IsExplicit, const char *Name, - DWARFSection Section, cu_iterator_range CUs) { + DWARFSection Section, unit_iterator_range Units) { if (shouldDump(IsExplicit, Name, DIDT_ID_DebugInfo, Section.Data)) { if (DumpOffset) getDIEForOffset(DumpOffset.getValue()) .dump(OS, 0, DumpOpts.noImplicitRecursion()); else - for (const auto &CU : CUs) - CU->dump(OS, DumpOpts); + for (const auto &U : Units) + U->dump(OS, DumpOpts); } }; dumpDebugInfo(Explicit, ".debug_info", DObj->getInfoSection(), @@ -355,15 +350,15 @@ void DWARFContext::dump( dumpDebugInfo(ExplicitDWO, ".debug_info.dwo", DObj->getInfoDWOSection(), dwo_info_section_units()); - auto dumpDebugType = [&](const char *Name, tu_iterator_range TUs) { + auto dumpDebugType = [&](const char *Name, unit_iterator_range Units) { OS << '\n' << Name << " contents:\n"; DumpOffset = DumpOffsets[DIDT_ID_DebugTypes]; - for (const auto &TU : TUs) + for (const auto &U : Units) if (DumpOffset) - TU->getDIEForOffset(*DumpOffset) + U->getDIEForOffset(*DumpOffset) .dump(OS, 0, DumpOpts.noImplicitRecursion()); else - TU->dump(OS, DumpOpts); + U->dump(OS, DumpOpts); }; if ((DumpType & DIDT_DebugTypes)) { if (Explicit || getNumTypeUnits()) @@ -546,14 +541,14 @@ void DWARFContext::dump( DObj->getStringOffsetSection().Data)) dumpStringOffsetsSection(OS, "debug_str_offsets", *DObj, DObj->getStringOffsetSection(), - DObj->getStringSection(), compile_units(), - type_units(), isLittleEndian(), getMaxVersion()); + DObj->getStringSection(), normal_units(), + isLittleEndian(), getMaxVersion()); if (shouldDump(ExplicitDWO, ".debug_str_offsets.dwo", DIDT_ID_DebugStrOffsets, DObj->getStringOffsetDWOSection().Data)) - dumpStringOffsetsSection( - OS, "debug_str_offsets.dwo", *DObj, DObj->getStringOffsetDWOSection(), - DObj->getStringDWOSection(), dwo_compile_units(), dwo_type_units(), - isLittleEndian(), getMaxVersion()); + dumpStringOffsetsSection(OS, "debug_str_offsets.dwo", *DObj, + DObj->getStringOffsetDWOSection(), + DObj->getStringDWOSection(), dwo_units(), + isLittleEndian(), getMaxVersion()); if (shouldDump(Explicit, ".gnu_index", DIDT_ID_GdbIndex, DObj->getGdbIndexSection())) { diff --git a/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp b/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp index d75f33906098..e3fa5c3d7413 100644 --- a/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp +++ b/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp @@ -282,7 +282,8 @@ using HandlerFn = std::function &Names, - DWARFContext::cu_iterator_range CUs, raw_ostream &OS) { + DWARFContext::unit_iterator_range CUs, + raw_ostream &OS) { for (const auto &CU : CUs) for (const auto &Entry : CU->dies()) { DWARFDie Die = {CU.get(), &Entry}; @@ -306,7 +307,6 @@ static void filterByName(const StringSet<> &Names, Die.dump(OS, 0, getDumpOpts()); } } - } static void getDies(DWARFContext &DICtx, const AppleAcceleratorTable &Accel,