Skip to content

Commit e3325e7

Browse files
committed
Fix test suite failures.
1 parent 04f9d9e commit e3325e7

File tree

1 file changed

+43
-27
lines changed

1 file changed

+43
-27
lines changed

llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp

Lines changed: 43 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,28 +1609,42 @@ unsigned DWARFVerifier::verifyNameIndexEntries(
16091609
continue;
16101610
}
16111611
std::optional<uint64_t> UnitOffset;
1612-
if (CUIndex)
1613-
UnitOffset = NI.getCUOffset(*CUIndex);
1614-
else if (TUIndex) {
1612+
if (TUIndex) {
1613+
// We have a local or foreign type unit.
16151614
if (*TUIndex >= NumLocalTUs) {
1615+
// This is a foreign type unit, we will find the right type unit by
1616+
// type unit signature later in this function.
1617+
16161618
// Foreign type units must have a valid CU index, either from a
16171619
// DW_IDX_comp_unit attribute value or from the .debug_names table only
16181620
// having a single compile unit. We need the originating compile unit
16191621
// because foreign type units can come from any .dwo file, yet only one
16201622
// copy of the type unit will end up in the .dwp file.
1621-
ErrorCategory.Report(
1622-
"Name Index entry contains foreign TU index with invalid CU index",
1623-
[&]() {
1624-
error() << formatv(
1625-
"Name Index @ {0:x}: Entry @ {1:x} contains an "
1626-
"foreign TU index ({2}) with no CU index.\n",
1627-
NI.getUnitOffset(), EntryID, *TUIndex);
1628-
});
1629-
++NumErrors;
1630-
continue;
1623+
if (CUIndex) {
1624+
// We need the local skeleton unit offset for the code below.
1625+
UnitOffset = NI.getCUOffset(*CUIndex);
1626+
} else {
1627+
ErrorCategory.Report(
1628+
"Name Index entry contains foreign TU index with invalid CU "
1629+
"index",
1630+
[&]() {
1631+
error() << formatv(
1632+
"Name Index @ {0:x}: Entry @ {1:x} contains an "
1633+
"foreign TU index ({2}) with no CU index.\n",
1634+
NI.getUnitOffset(), EntryID, *TUIndex);
1635+
});
1636+
++NumErrors;
1637+
continue;
1638+
}
1639+
} else {
1640+
// Local type unit, get the DWARF unit offset for the type unit.
1641+
UnitOffset = NI.getLocalTUOffset(*TUIndex);
16311642
}
1632-
UnitOffset = NI.getLocalTUOffset(*TUIndex);
1643+
} else if (CUIndex) {
1644+
// Local CU entry, get the DWARF unit offset for the CU.
1645+
UnitOffset = NI.getCUOffset(*CUIndex);
16331646
}
1647+
16341648
if (!UnitOffset)
16351649
continue;
16361650
// For split DWARF entries we need to make sure we find the non skeleton
@@ -1965,20 +1979,22 @@ unsigned DWARFVerifier::verifyDebugNames(const DWARFSection &AccelSection,
19651979
for (const std::unique_ptr<DWARFUnit> &U : DCtx.info_section_units()) {
19661980
if (const DWARFDebugNames::NameIndex *NI =
19671981
AccelTable.getCUOrTUNameIndex(U->getOffset())) {
1968-
DWARFCompileUnit *CU = cast<DWARFCompileUnit>(U.get());
1969-
if (CU && CU->getDWOId()) {
1970-
DWARFDie CUDie = CU->getUnitDIE(true);
1971-
DWARFDie NonSkeletonUnitDie =
1972-
CUDie.getDwarfUnit()->getNonSkeletonUnitDIE(false);
1973-
if (CUDie != NonSkeletonUnitDie) {
1974-
for (const DWARFDebugInfoEntry &Die :
1975-
NonSkeletonUnitDie.getDwarfUnit()->dies())
1976-
NumErrors += verifyNameIndexCompleteness(
1977-
DWARFDie(NonSkeletonUnitDie.getDwarfUnit(), &Die), *NI);
1982+
DWARFCompileUnit *CU = dyn_cast<DWARFCompileUnit>(U.get());
1983+
if (CU) {
1984+
if (CU->getDWOId()) {
1985+
DWARFDie CUDie = CU->getUnitDIE(true);
1986+
DWARFDie NonSkeletonUnitDie =
1987+
CUDie.getDwarfUnit()->getNonSkeletonUnitDIE(false);
1988+
if (CUDie != NonSkeletonUnitDie) {
1989+
for (const DWARFDebugInfoEntry &Die :
1990+
NonSkeletonUnitDie.getDwarfUnit()->dies())
1991+
NumErrors += verifyNameIndexCompleteness(
1992+
DWARFDie(NonSkeletonUnitDie.getDwarfUnit(), &Die), *NI);
1993+
}
1994+
} else {
1995+
for (const DWARFDebugInfoEntry &Die : CU->dies())
1996+
NumErrors += verifyNameIndexCompleteness(DWARFDie(CU, &Die), *NI);
19781997
}
1979-
} else {
1980-
for (const DWARFDebugInfoEntry &Die : CU->dies())
1981-
NumErrors += verifyNameIndexCompleteness(DWARFDie(CU, &Die), *NI);
19821998
}
19831999
}
19842000
}

0 commit comments

Comments
 (0)