Skip to content

Commit f0cf444

Browse files
[llvm][DebugNames] Implement supportsIdxParent query
1 parent b922242 commit f0cf444

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ class DWARFDebugNames : public DWARFAcceleratorTable {
557557
uint64_t StringOffsetsBase;
558558
uint64_t EntryOffsetsBase;
559559
uint64_t EntriesBase;
560+
bool HasIdxParent = false;
560561

561562
void dumpCUs(ScopedPrinter &W) const;
562563
void dumpLocalTUs(ScopedPrinter &W) const;
@@ -770,6 +771,13 @@ class DWARFDebugNames : public DWARFAcceleratorTable {
770771
/// Return the Name Index covering the compile unit at CUOffset, or nullptr if
771772
/// there is no Name Index covering that unit.
772773
const NameIndex *getCUNameIndex(uint64_t CUOffset);
774+
775+
/// Returns true if all the NameIndices in this table provide IDX_parent
776+
/// capabilities.
777+
bool supportsIdxParent() const {
778+
return all_of(NameIndices,
779+
[](const NameIndex &Idx) { return Idx.HasIdxParent; });
780+
}
773781
};
774782

775783
/// If `Name` is the name of a templated function that includes template

llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,13 +578,18 @@ Error DWARFDebugNames::NameIndex::extract() {
578578
"Section too small: cannot read abbreviations.");
579579

580580
EntriesBase = Offset + Hdr.AbbrevTableSize;
581+
HasIdxParent = false;
582+
auto IsIdxParent = [](auto IdxFormPair) {
583+
return IdxFormPair.Index == dwarf::Index::DW_IDX_parent;
584+
};
581585

582586
for (;;) {
583587
auto AbbrevOr = extractAbbrev(&Offset);
584588
if (!AbbrevOr)
585589
return AbbrevOr.takeError();
586590
if (isSentinel(*AbbrevOr))
587591
return Error::success();
592+
HasIdxParent |= any_of(AbbrevOr->Attributes, IsIdxParent);
588593

589594
if (!Abbrevs.insert(std::move(*AbbrevOr)).second)
590595
return createStringError(errc::invalid_argument,

0 commit comments

Comments
 (0)