Author: Zequan Wu Date: 2024-05-30T13:05:29-04:00 New Revision: 3d9d48523977af3590f7dd0edfd258454cb9e9cf
URL: https://github.com/llvm/llvm-project/commit/3d9d48523977af3590f7dd0edfd258454cb9e9cf DIFF: https://github.com/llvm/llvm-project/commit/3d9d48523977af3590f7dd0edfd258454cb9e9cf.diff LOG: [lldb][DWARF] Fix adding children to clang type that hasn't started definition. (#93839) This fixes https://github.com/llvm/llvm-project/pull/92328#issuecomment-2139339444 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 <michaelbuc...@gmail.com> Added: Modified: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp Removed: ################################################################################ diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index e0b1b430b266f..dc4cfc96b86f0 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -2232,6 +2232,10 @@ bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE &die, // For objective C we don't start the definition when the class is // created. TypeSystemClang::StartTagDeclarationDefinition(clang_type); + } else { + assert(clang_type.IsBeingDefined() && + "Trying to complete a definition without a prior call to " + "StartTagDeclarationDefinition."); } AccessType default_accessibility = eAccessNone; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp b/lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp index 4762356034cab..3d201e96f92c3 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp @@ -13,12 +13,18 @@ using namespace lldb_private::dwarf; using namespace lldb_private::plugin::dwarf; +static bool IsStructOrClassTag(llvm::dwarf::Tag Tag) { + return Tag == llvm::dwarf::Tag::DW_TAG_class_type || + Tag == llvm::dwarf::Tag::DW_TAG_structure_type; +} + UniqueDWARFASTType *UniqueDWARFASTTypeList::Find( const DWARFDIE &die, const lldb_private::Declaration &decl, const int32_t byte_size, bool is_forward_declaration) { for (UniqueDWARFASTType &udt : m_collection) { // Make sure the tags match - if (udt.m_die.Tag() == die.Tag()) { + if (udt.m_die.Tag() == die.Tag() || (IsStructOrClassTag(udt.m_die.Tag()) && + IsStructOrClassTag(die.Tag()))) { // If they are not both definition DIEs or both declaration DIEs, then // don't check for byte size and declaration location, because declaration // DIEs usually don't have those info. @@ -39,7 +45,9 @@ UniqueDWARFASTType *UniqueDWARFASTTypeList::Find( while (!done && match && parent_arg_die && parent_pos_die) { const dw_tag_t parent_arg_tag = parent_arg_die.Tag(); const dw_tag_t parent_pos_tag = parent_pos_die.Tag(); - if (parent_arg_tag == parent_pos_tag) { + if (parent_arg_tag == parent_pos_tag || + (IsStructOrClassTag(parent_arg_tag) && + IsStructOrClassTag(parent_pos_tag))) { switch (parent_arg_tag) { case DW_TAG_class_type: case DW_TAG_structure_type: _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits