diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -517,6 +517,14 @@ return UpdateSymbolContextScopeForType(sc, die, type_sp); } +namespace { +lldb::user_id_t getUIDHelper(SymbolFileDWARF &dwarf, const DWARFBaseDIE &die) { + const std::optional &ref = die.GetDIERef(); + return ref ? DIERef(dwarf.GetID(), ref->section(), ref->die_offset()).get_id() + : LLDB_INVALID_UID; +} +} // namespace + lldb::TypeSP DWARFASTParserClang::ParseTypeModifier(const SymbolContext &sc, const DWARFDIE &die, @@ -731,10 +739,11 @@ } } - type_sp = dwarf->MakeType( - die.GetID(), attrs.name, attrs.byte_size, nullptr, - dwarf->GetUID(attrs.type.Reference()), encoding_data_type, &attrs.decl, - clang_type, resolve_state, TypePayloadClang(GetOwningClangModule(die))); + type_sp = dwarf->MakeType(die.GetID(), attrs.name, attrs.byte_size, nullptr, + getUIDHelper(*dwarf, attrs.type.Reference()), + encoding_data_type, &attrs.decl, clang_type, + resolve_state, + TypePayloadClang(GetOwningClangModule(die))); dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get(); return type_sp; @@ -835,7 +844,7 @@ LinkDeclContextToDIE(TypeSystemClang::GetDeclContextForType(clang_type), die); type_sp = dwarf->MakeType(die.GetID(), attrs.name, attrs.byte_size, nullptr, - dwarf->GetUID(attrs.type.Reference()), + getUIDHelper(*dwarf, attrs.type.Reference()), Type::eEncodingIsUID, &attrs.decl, clang_type, Type::ResolveState::Forward, TypePayloadClang(GetOwningClangModule(die))); @@ -1334,10 +1343,10 @@ m_ast.CreateArrayType(array_element_type, 0, attrs.is_vector); } ConstString empty_name; - TypeSP type_sp = - dwarf->MakeType(die.GetID(), empty_name, array_element_bit_stride / 8, - nullptr, dwarf->GetUID(type_die), Type::eEncodingIsUID, - &attrs.decl, clang_type, Type::ResolveState::Full); + TypeSP type_sp = dwarf->MakeType( + die.GetID(), empty_name, array_element_bit_stride / 8, nullptr, + getUIDHelper(*dwarf, type_die), Type::eEncodingIsUID, &attrs.decl, + clang_type, Type::ResolveState::Full); type_sp->SetEncodingType(element_type); const clang::Type *type = ClangUtil::GetQualType(clang_type).getTypePtr(); m_ast.SetMetadataAsUserID(type, die.GetID()); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp @@ -70,8 +70,10 @@ } lldb::user_id_t DWARFBaseDIE::GetID() const { - if (IsValid()) - return GetDWARF()->GetUID(*this); + const std::optional &ref = this->GetDIERef(); + if (ref) + return DIERef(GetID(), ref->section(), ref->die_offset()).get_id(); + return LLDB_INVALID_UID; } 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 @@ -265,16 +265,6 @@ DWARFDIE GetDIE(lldb::user_id_t uid); - lldb::user_id_t GetUID(const DWARFBaseDIE &die) { - return GetUID(die.GetDIERef()); - } - - lldb::user_id_t GetUID(const std::optional &ref) { - return ref ? GetUID(*ref) : LLDB_INVALID_UID; - } - - lldb::user_id_t GetUID(DIERef ref); - std::shared_ptr GetDwoSymbolFileForCompileUnit(DWARFUnit &dwarf_cu, const DWARFDebugInfoEntry &cu_die); 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 @@ -1404,10 +1404,6 @@ decl_ctx); } -user_id_t SymbolFileDWARF::GetUID(DIERef ref) { - return DIERef(GetID(), ref.section(), ref.die_offset()).get_id(); -} - std::optional SymbolFileDWARF::DecodeUID(lldb::user_id_t uid) { // This method can be called without going through the symbol vendor so we @@ -3601,8 +3597,10 @@ return nullptr; } + const std::optional &ref = type_die_form.Reference().GetDIERef(); auto type_sp = std::make_shared( - *this, GetUID(type_die_form.Reference())); + *this, ref ? DIERef(GetID(), ref->section(), ref->die_offset()).get_id() + : LLDB_INVALID_UID); if (use_type_size_for_value && type_sp->GetType()) { DWARFExpression *location = location_list.GetMutableExpressionAtAddress();