ayermolo created this revision. Herald added a reviewer: shafik. Herald added subscribers: hoy, modimo, wenlei. Herald added a project: All. ayermolo requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits.
Removed the GetUID API to make it explicit that ID creation goes through DIERef. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D142775 Files: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ 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<DIERef> &ref) { - return ref ? GetUID(*ref) : LLDB_INVALID_UID; - } - - lldb::user_id_t GetUID(DIERef ref); - std::shared_ptr<SymbolFileDWARFDwo> GetDwoSymbolFileForCompileUnit(DWARFUnit &dwarf_cu, const DWARFDebugInfoEntry &cu_die); Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ 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::DecodedUID> 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<DIERef> &ref = type_die_form.Reference().GetDIERef(); auto type_sp = std::make_shared<SymbolFileType>( - *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(); Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp +++ 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<DIERef> &ref = this->GetDIERef(); + if (ref) + return DIERef(GetID(), ref->section(), ref->die_offset()).get_id(); + return LLDB_INVALID_UID; } Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ 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<DIERef> &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());
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits