Skip to content

Commit 3d9d485

Browse files
ZequanWuMichael137
andauthored
[lldb][DWARF] Fix adding children to clang type that hasn't started definition. (#93839)
This fixes #92328 (comment) by not differentiating `DW_TAG_class_type` and `DW_TAG_structure_type` in `UniqueDWARFASTTypeList`, because it's possible that DIE for a type is `DW_TAG_class_type` in one CU but is `DW_TAG_structure_type` in a different CU. --------- Co-authored-by: Michael Buch <[email protected]>
1 parent f6c8e7d commit 3d9d485

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2232,6 +2232,10 @@ bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE &die,
22322232
// For objective C we don't start the definition when the class is
22332233
// created.
22342234
TypeSystemClang::StartTagDeclarationDefinition(clang_type);
2235+
} else {
2236+
assert(clang_type.IsBeingDefined() &&
2237+
"Trying to complete a definition without a prior call to "
2238+
"StartTagDeclarationDefinition.");
22352239
}
22362240

22372241
AccessType default_accessibility = eAccessNone;

lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,18 @@
1313
using namespace lldb_private::dwarf;
1414
using namespace lldb_private::plugin::dwarf;
1515

16+
static bool IsStructOrClassTag(llvm::dwarf::Tag Tag) {
17+
return Tag == llvm::dwarf::Tag::DW_TAG_class_type ||
18+
Tag == llvm::dwarf::Tag::DW_TAG_structure_type;
19+
}
20+
1621
UniqueDWARFASTType *UniqueDWARFASTTypeList::Find(
1722
const DWARFDIE &die, const lldb_private::Declaration &decl,
1823
const int32_t byte_size, bool is_forward_declaration) {
1924
for (UniqueDWARFASTType &udt : m_collection) {
2025
// Make sure the tags match
21-
if (udt.m_die.Tag() == die.Tag()) {
26+
if (udt.m_die.Tag() == die.Tag() || (IsStructOrClassTag(udt.m_die.Tag()) &&
27+
IsStructOrClassTag(die.Tag()))) {
2228
// If they are not both definition DIEs or both declaration DIEs, then
2329
// don't check for byte size and declaration location, because declaration
2430
// DIEs usually don't have those info.
@@ -39,7 +45,9 @@ UniqueDWARFASTType *UniqueDWARFASTTypeList::Find(
3945
while (!done && match && parent_arg_die && parent_pos_die) {
4046
const dw_tag_t parent_arg_tag = parent_arg_die.Tag();
4147
const dw_tag_t parent_pos_tag = parent_pos_die.Tag();
42-
if (parent_arg_tag == parent_pos_tag) {
48+
if (parent_arg_tag == parent_pos_tag ||
49+
(IsStructOrClassTag(parent_arg_tag) &&
50+
IsStructOrClassTag(parent_pos_tag))) {
4351
switch (parent_arg_tag) {
4452
case DW_TAG_class_type:
4553
case DW_TAG_structure_type:

0 commit comments

Comments
 (0)