jankratochvil created this revision. jankratochvil added a reviewer: labath. jankratochvil added a project: LLDB. Herald added a subscriber: JDevlieghere. jankratochvil requested review of this revision. Herald added a reviewer: jdoerfert. Herald added a subscriber: sstefan1.
Only `SymbolFileDWARF::ParseCompileUnit` creates a `CompileUnit` and it uses `DWARFCompileUnit` for that. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D89165 Files: 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 @@ -346,7 +346,7 @@ lldb::CompUnitSP ParseCompileUnit(DWARFCompileUnit &dwarf_cu); - virtual DWARFUnit * + virtual DWARFCompileUnit * GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit); DWARFUnit *GetNextUnparsedDWARFCompileUnit(DWARFUnit *prev_cu); Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -632,8 +632,7 @@ return *m_info; } -DWARFUnit * -SymbolFileDWARF::GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit) { +DWARFCompileUnit *SymbolFileDWARF::GetDWARFCompileUnit(CompileUnit *comp_unit) { if (!comp_unit) return nullptr; @@ -641,7 +640,9 @@ DWARFUnit *dwarf_cu = DebugInfo().GetUnitAtIndex(comp_unit->GetID()); if (dwarf_cu && dwarf_cu->GetUserData() == nullptr) dwarf_cu->SetUserData(comp_unit); - return dwarf_cu; + + // It must be DWARFCompileUnit when it created a CompileUnit. + return llvm::cast_or_null<DWARFCompileUnit>(dwarf_cu); } DWARFDebugRanges *SymbolFileDWARF::GetDebugRanges() { @@ -1599,8 +1600,7 @@ llvm::Optional<uint64_t> SymbolFileDWARF::GetDWOId() { if (GetNumCompileUnits() == 1) { if (auto comp_unit = GetCompileUnitAtIndex(0)) - if (DWARFCompileUnit *cu = llvm::dyn_cast_or_null<DWARFCompileUnit>( - GetDWARFCompileUnit(comp_unit.get()))) + if (DWARFCompileUnit *cu = GetDWARFCompileUnit(comp_unit.get())) if (DWARFDebugInfoEntry *cu_die = cu->DIE().GetDIE()) if (uint64_t dwo_id = ::GetDWOId(*cu, *cu_die)) return dwo_id;
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -346,7 +346,7 @@ lldb::CompUnitSP ParseCompileUnit(DWARFCompileUnit &dwarf_cu); - virtual DWARFUnit * + virtual DWARFCompileUnit * GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit); DWARFUnit *GetNextUnparsedDWARFCompileUnit(DWARFUnit *prev_cu); Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -632,8 +632,7 @@ return *m_info; } -DWARFUnit * -SymbolFileDWARF::GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit) { +DWARFCompileUnit *SymbolFileDWARF::GetDWARFCompileUnit(CompileUnit *comp_unit) { if (!comp_unit) return nullptr; @@ -641,7 +640,9 @@ DWARFUnit *dwarf_cu = DebugInfo().GetUnitAtIndex(comp_unit->GetID()); if (dwarf_cu && dwarf_cu->GetUserData() == nullptr) dwarf_cu->SetUserData(comp_unit); - return dwarf_cu; + + // It must be DWARFCompileUnit when it created a CompileUnit. + return llvm::cast_or_null<DWARFCompileUnit>(dwarf_cu); } DWARFDebugRanges *SymbolFileDWARF::GetDebugRanges() { @@ -1599,8 +1600,7 @@ llvm::Optional<uint64_t> SymbolFileDWARF::GetDWOId() { if (GetNumCompileUnits() == 1) { if (auto comp_unit = GetCompileUnitAtIndex(0)) - if (DWARFCompileUnit *cu = llvm::dyn_cast_or_null<DWARFCompileUnit>( - GetDWARFCompileUnit(comp_unit.get()))) + if (DWARFCompileUnit *cu = GetDWARFCompileUnit(comp_unit.get())) if (DWARFDebugInfoEntry *cu_die = cu->DIE().GetDIE()) if (uint64_t dwo_id = ::GetDWOId(*cu, *cu_die)) return dwo_id;
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits