diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -489,6 +489,10 @@ llvm::DenseMap m_type_unit_support_files; std::vector m_lldb_cu_to_dwarf_unit; + + typedef std::pair DeclContextToOffsetKey; + typedef std::map DeclContextToOffsetMap; + DeclContextToOffsetMap m_decl_context_to_offset_map; }; #endif // SymbolFileDWARF_SymbolFileDWARF_h_ diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -1209,11 +1209,17 @@ DWARFASTParser *ast_parser = type_system->GetDWARFParser(); std::vector decl_ctx_die_list = ast_parser->GetDIEForDeclContext(decl_ctx); + DeclContextToOffsetKey offset_key = + std::make_pair(decl_ctx.GetOpaqueDeclContext(), type_system); + uint32_t &offset = m_decl_context_to_offset_map[offset_key]; - for (DWARFDIE decl_ctx_die : decl_ctx_die_list) - for (DWARFDIE decl = decl_ctx_die.GetFirstChild(); decl; + for (auto decl_ctx_die_it = decl_ctx_die_list.begin() + offset; + decl_ctx_die_it != decl_ctx_die_list.end(); ++decl_ctx_die_it) + for (DWARFDIE decl = decl_ctx_die_it->GetFirstChild(); decl; decl = decl.GetSibling()) ast_parser->GetDeclForUIDFromDWARF(decl); + + offset = decl_ctx_die_list.size(); } user_id_t SymbolFileDWARF::GetUID(DIERef ref) {