mirror of
https://github.com/intel/llvm.git
synced 2026-01-14 03:50:17 +08:00
[LLDB][NFC] Remove DWARFASTParserClang as friend from SymbolFileDWARF (#70157)
This effectively moves a few functions from protected to public. In any case, for the sake of having a cleaner SymbolFileDWARF API, it's better if it's not a friend of a one of its consumers, DWARFASTParserClang. Another effect of this change is that I can use SymbolFileDWARF for the out-of-tree mojo dwarf parser, which relies on pretty much the same functions that DWARFASTParserClang needs from SymbolFileDWARF.
This commit is contained in:
@@ -834,9 +834,9 @@ TypeSP DWARFASTParserClang::ParseEnum(const SymbolContext &sc,
|
||||
|
||||
CompilerType enumerator_clang_type;
|
||||
CompilerType clang_type;
|
||||
clang_type =
|
||||
CompilerType(m_ast.weak_from_this(),
|
||||
dwarf->GetForwardDeclDieToClangType().lookup(die.GetDIE()));
|
||||
clang_type = CompilerType(
|
||||
m_ast.weak_from_this(),
|
||||
dwarf->GetForwardDeclDIEToCompilerType().lookup(die.GetDIE()));
|
||||
if (!clang_type) {
|
||||
if (attrs.type.IsValid()) {
|
||||
Type *enumerator_type =
|
||||
@@ -1764,9 +1764,9 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc,
|
||||
assert(tag_decl_kind != -1);
|
||||
(void)tag_decl_kind;
|
||||
bool clang_type_was_created = false;
|
||||
clang_type =
|
||||
CompilerType(m_ast.weak_from_this(),
|
||||
dwarf->GetForwardDeclDieToClangType().lookup(die.GetDIE()));
|
||||
clang_type = CompilerType(
|
||||
m_ast.weak_from_this(),
|
||||
dwarf->GetForwardDeclDIEToCompilerType().lookup(die.GetDIE()));
|
||||
if (!clang_type) {
|
||||
clang::DeclContext *decl_ctx =
|
||||
GetClangDeclContextContainingDIE(die, nullptr);
|
||||
@@ -1896,16 +1896,16 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc,
|
||||
// the SymbolFile virtual function
|
||||
// "SymbolFileDWARF::CompleteType(Type *)" When the definition
|
||||
// needs to be defined.
|
||||
assert(!dwarf->GetForwardDeclClangTypeToDie().count(
|
||||
assert(!dwarf->GetForwardDeclCompilerTypeToDIE().count(
|
||||
ClangUtil::RemoveFastQualifiers(clang_type)
|
||||
.GetOpaqueQualType()) &&
|
||||
"Type already in the forward declaration map!");
|
||||
// Can't assume m_ast.GetSymbolFile() is actually a
|
||||
// SymbolFileDWARF, it can be a SymbolFileDWARFDebugMap for Apple
|
||||
// binaries.
|
||||
dwarf->GetForwardDeclDieToClangType()[die.GetDIE()] =
|
||||
dwarf->GetForwardDeclDIEToCompilerType()[die.GetDIE()] =
|
||||
clang_type.GetOpaqueQualType();
|
||||
dwarf->GetForwardDeclClangTypeToDie().try_emplace(
|
||||
dwarf->GetForwardDeclCompilerTypeToDIE().try_emplace(
|
||||
ClangUtil::RemoveFastQualifiers(clang_type).GetOpaqueQualType(),
|
||||
*die.GetDIERef());
|
||||
m_ast.SetHasExternalStorage(clang_type.GetOpaqueQualType(), true);
|
||||
|
||||
@@ -1532,11 +1532,11 @@ Type *SymbolFileDWARF::ResolveTypeUID(const DWARFDIE &die,
|
||||
// This function is used when SymbolFileDWARFDebugMap owns a bunch of
|
||||
// SymbolFileDWARF objects to detect if this DWARF file is the one that can
|
||||
// resolve a compiler_type.
|
||||
bool SymbolFileDWARF::HasForwardDeclForClangType(
|
||||
bool SymbolFileDWARF::HasForwardDeclForCompilerType(
|
||||
const CompilerType &compiler_type) {
|
||||
CompilerType compiler_type_no_qualifiers =
|
||||
ClangUtil::RemoveFastQualifiers(compiler_type);
|
||||
if (GetForwardDeclClangTypeToDie().count(
|
||||
if (GetForwardDeclCompilerTypeToDIE().count(
|
||||
compiler_type_no_qualifiers.GetOpaqueQualType())) {
|
||||
return true;
|
||||
}
|
||||
@@ -1564,9 +1564,9 @@ bool SymbolFileDWARF::CompleteType(CompilerType &compiler_type) {
|
||||
// We have a struct/union/class/enum that needs to be fully resolved.
|
||||
CompilerType compiler_type_no_qualifiers =
|
||||
ClangUtil::RemoveFastQualifiers(compiler_type);
|
||||
auto die_it = GetForwardDeclClangTypeToDie().find(
|
||||
auto die_it = GetForwardDeclCompilerTypeToDIE().find(
|
||||
compiler_type_no_qualifiers.GetOpaqueQualType());
|
||||
if (die_it == GetForwardDeclClangTypeToDie().end()) {
|
||||
if (die_it == GetForwardDeclCompilerTypeToDIE().end()) {
|
||||
// We have already resolved this type...
|
||||
return true;
|
||||
}
|
||||
@@ -1577,7 +1577,7 @@ bool SymbolFileDWARF::CompleteType(CompilerType &compiler_type) {
|
||||
// declaration map in case anyone child members or other types require this
|
||||
// type to get resolved. The type will get resolved when all of the calls
|
||||
// to SymbolFileDWARF::ResolveClangOpaqueTypeDefinition are done.
|
||||
GetForwardDeclClangTypeToDie().erase(die_it);
|
||||
GetForwardDeclCompilerTypeToDIE().erase(die_it);
|
||||
|
||||
Type *type = GetDIEToType().lookup(dwarf_die.GetDIE());
|
||||
|
||||
|
||||
@@ -83,7 +83,6 @@ public:
|
||||
friend class DWARFCompileUnit;
|
||||
friend class DWARFDIE;
|
||||
friend class DWARFASTParser;
|
||||
friend class ::DWARFASTParserClang;
|
||||
|
||||
// Static Functions
|
||||
static void Initialize();
|
||||
@@ -138,7 +137,6 @@ public:
|
||||
|
||||
size_t ParseVariablesForContext(const SymbolContext &sc) override;
|
||||
|
||||
Type *ResolveTypeUID(lldb::user_id_t type_uid) override;
|
||||
std::optional<ArrayInfo>
|
||||
GetDynamicArrayInfoForUID(lldb::user_id_t type_uid,
|
||||
const ExecutionContext *exe_ctx) override;
|
||||
@@ -225,7 +223,7 @@ public:
|
||||
DWARFDIE
|
||||
GetDeclContextDIEContainingDIE(const DWARFDIE &die);
|
||||
|
||||
bool HasForwardDeclForClangType(const CompilerType &compiler_type);
|
||||
bool HasForwardDeclForCompilerType(const CompilerType &compiler_type);
|
||||
|
||||
CompileUnit *GetCompUnitForDWARFCompUnit(DWARFCompileUnit &dwarf_cu);
|
||||
|
||||
@@ -325,14 +323,46 @@ public:
|
||||
m_file_index = file_index;
|
||||
}
|
||||
|
||||
protected:
|
||||
typedef llvm::DenseMap<const DWARFDebugInfoEntry *, Type *> DIEToTypePtr;
|
||||
typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb::VariableSP>
|
||||
DIEToVariableSP;
|
||||
|
||||
virtual DIEToTypePtr &GetDIEToType() { return m_die_to_type; }
|
||||
|
||||
typedef llvm::DenseMap<const DWARFDebugInfoEntry *,
|
||||
lldb::opaque_compiler_type_t>
|
||||
DIEToClangType;
|
||||
typedef llvm::DenseMap<lldb::opaque_compiler_type_t, DIERef> ClangTypeToDIE;
|
||||
DIEToCompilerType;
|
||||
|
||||
virtual DIEToCompilerType &GetForwardDeclDIEToCompilerType() {
|
||||
return m_forward_decl_die_to_compiler_type;
|
||||
}
|
||||
|
||||
typedef llvm::DenseMap<lldb::opaque_compiler_type_t, DIERef>
|
||||
CompilerTypeToDIE;
|
||||
|
||||
virtual CompilerTypeToDIE &GetForwardDeclCompilerTypeToDIE() {
|
||||
return m_forward_decl_compiler_type_to_die;
|
||||
}
|
||||
|
||||
virtual UniqueDWARFASTTypeMap &GetUniqueDWARFASTTypeMap();
|
||||
|
||||
bool ClassOrStructIsVirtual(const DWARFDIE &die);
|
||||
|
||||
SymbolFileDWARFDebugMap *GetDebugMapSymfile();
|
||||
|
||||
virtual lldb::TypeSP
|
||||
FindDefinitionTypeForDWARFDeclContext(const DWARFDIE &die);
|
||||
|
||||
virtual lldb::TypeSP FindCompleteObjCDefinitionTypeForDIE(
|
||||
const DWARFDIE &die, ConstString type_name, bool must_be_implementation);
|
||||
|
||||
Type *ResolveTypeUID(lldb::user_id_t type_uid) override;
|
||||
|
||||
Type *ResolveTypeUID(const DWARFDIE &die, bool assert_not_being_parsed);
|
||||
|
||||
Type *ResolveTypeUID(const DIERef &die_ref);
|
||||
|
||||
protected:
|
||||
typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb::VariableSP>
|
||||
DIEToVariableSP;
|
||||
|
||||
SymbolFileDWARF(const SymbolFileDWARF &) = delete;
|
||||
const SymbolFileDWARF &operator=(const SymbolFileDWARF &) = delete;
|
||||
@@ -371,10 +401,6 @@ protected:
|
||||
bool ParseSupportFiles(DWARFUnit &dwarf_cu, const lldb::ModuleSP &module,
|
||||
FileSpecList &support_files);
|
||||
|
||||
Type *ResolveTypeUID(const DWARFDIE &die, bool assert_not_being_parsed);
|
||||
|
||||
Type *ResolveTypeUID(const DIERef &die_ref);
|
||||
|
||||
lldb::VariableSP ParseVariableDIE(const SymbolContext &sc,
|
||||
const DWARFDIE &die,
|
||||
const lldb::addr_t func_low_pc);
|
||||
@@ -402,8 +428,6 @@ protected:
|
||||
DIEArray MergeBlockAbstractParameters(const DWARFDIE &block_die,
|
||||
DIEArray &&variable_dies);
|
||||
|
||||
bool ClassOrStructIsVirtual(const DWARFDIE &die);
|
||||
|
||||
// Given a die_offset, figure out the symbol context representing that die.
|
||||
bool ResolveFunction(const DWARFDIE &die, bool include_inlines,
|
||||
SymbolContextList &sc_list);
|
||||
@@ -415,12 +439,6 @@ protected:
|
||||
void ResolveFunctionAndBlock(lldb::addr_t file_vm_addr, bool lookup_block,
|
||||
SymbolContext &sc);
|
||||
|
||||
virtual lldb::TypeSP
|
||||
FindDefinitionTypeForDWARFDeclContext(const DWARFDIE &die);
|
||||
|
||||
virtual lldb::TypeSP FindCompleteObjCDefinitionTypeForDIE(
|
||||
const DWARFDIE &die, ConstString type_name, bool must_be_implementation);
|
||||
|
||||
Symbol *GetObjCClassSymbol(ConstString objc_class_name);
|
||||
|
||||
lldb::TypeSP GetTypeForDIE(const DWARFDIE &die,
|
||||
@@ -430,8 +448,6 @@ protected:
|
||||
m_debug_map_module_wp = module_sp;
|
||||
}
|
||||
|
||||
SymbolFileDWARFDebugMap *GetDebugMapSymfile();
|
||||
|
||||
DWARFDIE
|
||||
FindBlockContainingSpecification(const DIERef &func_die_ref,
|
||||
dw_offset_t spec_block_die_offset);
|
||||
@@ -440,8 +456,6 @@ protected:
|
||||
FindBlockContainingSpecification(const DWARFDIE &die,
|
||||
dw_offset_t spec_block_die_offset);
|
||||
|
||||
virtual UniqueDWARFASTTypeMap &GetUniqueDWARFASTTypeMap();
|
||||
|
||||
bool DIEDeclContextsMatch(const DWARFDIE &die1, const DWARFDIE &die2);
|
||||
|
||||
bool ClassContainsSelector(const DWARFDIE &class_die, ConstString selector);
|
||||
@@ -473,18 +487,8 @@ protected:
|
||||
|
||||
void UpdateExternalModuleListIfNeeded();
|
||||
|
||||
virtual DIEToTypePtr &GetDIEToType() { return m_die_to_type; }
|
||||
|
||||
virtual DIEToVariableSP &GetDIEToVariable() { return m_die_to_variable_sp; }
|
||||
|
||||
virtual DIEToClangType &GetForwardDeclDieToClangType() {
|
||||
return m_forward_decl_die_to_clang_type;
|
||||
}
|
||||
|
||||
virtual ClangTypeToDIE &GetForwardDeclClangTypeToDie() {
|
||||
return m_forward_decl_clang_type_to_die;
|
||||
}
|
||||
|
||||
void BuildCuTranslationTable();
|
||||
std::optional<uint32_t> GetDWARFUnitIndex(uint32_t cu_idx);
|
||||
|
||||
@@ -528,8 +532,8 @@ protected:
|
||||
UniqueDWARFASTTypeMap m_unique_ast_type_map;
|
||||
DIEToTypePtr m_die_to_type;
|
||||
DIEToVariableSP m_die_to_variable_sp;
|
||||
DIEToClangType m_forward_decl_die_to_clang_type;
|
||||
ClangTypeToDIE m_forward_decl_clang_type_to_die;
|
||||
DIEToCompilerType m_forward_decl_die_to_compiler_type;
|
||||
CompilerTypeToDIE m_forward_decl_compiler_type_to_die;
|
||||
llvm::DenseMap<dw_offset_t, FileSpecList> m_type_unit_support_files;
|
||||
std::vector<uint32_t> m_lldb_cu_to_dwarf_unit;
|
||||
/// DWARF does not provide a good way for traditional (concatenating) linkers
|
||||
|
||||
@@ -803,7 +803,7 @@ bool SymbolFileDWARFDebugMap::CompleteType(CompilerType &compiler_type) {
|
||||
bool success = false;
|
||||
if (compiler_type) {
|
||||
ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
|
||||
if (oso_dwarf->HasForwardDeclForClangType(compiler_type)) {
|
||||
if (oso_dwarf->HasForwardDeclForCompilerType(compiler_type)) {
|
||||
oso_dwarf->CompleteType(compiler_type);
|
||||
success = true;
|
||||
return true;
|
||||
|
||||
@@ -99,14 +99,14 @@ SymbolFileDWARF::DIEToVariableSP &SymbolFileDWARFDwo::GetDIEToVariable() {
|
||||
return GetBaseSymbolFile().GetDIEToVariable();
|
||||
}
|
||||
|
||||
SymbolFileDWARF::DIEToClangType &
|
||||
SymbolFileDWARFDwo::GetForwardDeclDieToClangType() {
|
||||
return GetBaseSymbolFile().GetForwardDeclDieToClangType();
|
||||
SymbolFileDWARF::DIEToCompilerType &
|
||||
SymbolFileDWARFDwo::GetForwardDeclDIEToCompilerType() {
|
||||
return GetBaseSymbolFile().GetForwardDeclDIEToCompilerType();
|
||||
}
|
||||
|
||||
SymbolFileDWARF::ClangTypeToDIE &
|
||||
SymbolFileDWARFDwo::GetForwardDeclClangTypeToDie() {
|
||||
return GetBaseSymbolFile().GetForwardDeclClangTypeToDie();
|
||||
SymbolFileDWARF::CompilerTypeToDIE &
|
||||
SymbolFileDWARFDwo::GetForwardDeclCompilerTypeToDIE() {
|
||||
return GetBaseSymbolFile().GetForwardDeclCompilerTypeToDIE();
|
||||
}
|
||||
|
||||
void SymbolFileDWARFDwo::GetObjCMethods(
|
||||
|
||||
@@ -56,9 +56,9 @@ protected:
|
||||
|
||||
DIEToVariableSP &GetDIEToVariable() override;
|
||||
|
||||
DIEToClangType &GetForwardDeclDieToClangType() override;
|
||||
DIEToCompilerType &GetForwardDeclDIEToCompilerType() override;
|
||||
|
||||
ClangTypeToDIE &GetForwardDeclClangTypeToDie() override;
|
||||
CompilerTypeToDIE &GetForwardDeclCompilerTypeToDIE() override;
|
||||
|
||||
UniqueDWARFASTTypeMap &GetUniqueDWARFASTTypeMap() override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user