Made a new abstract class named "DWARFASTParser" which lives in "source/Plugins/SymbolFile/DWARF":
class DWARFASTParser
{
public:
virtual ~DWARFASTParser() {}
virtual lldb::TypeSP
ParseTypeFromDWARF (const lldb_private::SymbolContext& sc,
const DWARFDIE &die,
lldb_private::Log *log,
bool *type_is_new_ptr) = 0;
virtual lldb_private::Function *
ParseFunctionFromDWARF (const lldb_private::SymbolContext& sc,
const DWARFDIE &die) = 0;
virtual bool
CompleteTypeFromDWARF (const DWARFDIE &die,
lldb_private::Type *type,
lldb_private::CompilerType &clang_type) = 0;
virtual lldb_private::CompilerDeclContext
GetDeclContextForUIDFromDWARF (const DWARFDIE &die) = 0;
virtual lldb_private::CompilerDeclContext
GetDeclContextContainingUIDFromDWARF (const DWARFDIE &die) = 0;
};
We have one subclass named DWARFASTParserClang that implements all of the clang specific AST type parsing. This keeps all DWARF parsing in the DWARF plug-in. Moved all of the DWARF parsing code that was in ClangASTContext over into DWARFASTParserClang.
lldb_private::TypeSystem classes no longer have any DWARF parsing functions in them, but they can hand out a DWARFASTParser:
virtual DWARFASTParser *
GetDWARFParser ()
{
return nullptr;
}
This keeps things clean and makes for easy merging when we have different AST's for different languages.
llvm-svn: 246242
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 38dc94f..aabb09d 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -57,6 +57,7 @@
#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/CPPLanguageRuntime.h"
+#include "DWARFASTParser.h"
#include "DWARFCompileUnit.h"
#include "DWARFDebugAbbrev.h"
#include "DWARFDebugAranges.h"
@@ -1014,7 +1015,9 @@
if (type_system)
{
- return type_system->ParseFunctionFromDWARF(sc, die);
+ DWARFASTParser *dwarf_ast = type_system->GetDWARFParser();
+ if (dwarf_ast)
+ return dwarf_ast->ParseFunctionFromDWARF(sc, die);
}
}
return nullptr;
@@ -1381,9 +1384,9 @@
DWARFDIE die = debug_info->GetDIE(type_uid);
if (die)
{
- TypeSystem *type_system = die.GetTypeSystem();
- if (type_system)
- return type_system->GetDeclContextForUIDFromDWARF(die);
+ DWARFASTParser *dwarf_ast = die.GetDWARFParser();
+ if (dwarf_ast)
+ return dwarf_ast->GetDeclContextForUIDFromDWARF(die);
}
}
}
@@ -1401,9 +1404,9 @@
DWARFDIE die = debug_info->GetDIE(type_uid);
if (die)
{
- TypeSystem *type_system = die.GetTypeSystem();
- if (type_system)
- return type_system->GetDeclContextContainingUIDFromDWARF(die);
+ DWARFASTParser *dwarf_ast = die.GetDWARFParser();
+ if (dwarf_ast)
+ return dwarf_ast->GetDeclContextContainingUIDFromDWARF(die);
}
}
}
@@ -1521,10 +1524,9 @@
DWARFAttributes attributes;
- TypeSystem *type_system = dwarf_die.GetTypeSystem();
-
- if (type_system)
- return type_system->CompleteTypeFromDWARF (dwarf_die, type, clang_type);
+ DWARFASTParser *dwarf_ast = dwarf_die.GetDWARFParser();
+ if (dwarf_ast)
+ return dwarf_ast->CompleteTypeFromDWARF (dwarf_die, type, clang_type);
return false;
}
@@ -2144,11 +2146,10 @@
if (parent_decl_ctx)
{
- TypeSystem *type_system = die.GetTypeSystem();
-
- if (type_system)
+ DWARFASTParser *dwarf_ast = die.GetDWARFParser();
+ if (dwarf_ast)
{
- CompilerDeclContext actual_parent_decl_ctx = type_system->GetDeclContextContainingUIDFromDWARF (die);
+ CompilerDeclContext actual_parent_decl_ctx = dwarf_ast->GetDeclContextContainingUIDFromDWARF (die);
if (!actual_parent_decl_ctx || actual_parent_decl_ctx != *parent_decl_ctx)
continue;
}
@@ -2414,11 +2415,10 @@
if (die)
{
- TypeSystem *type_system = die.GetTypeSystem();
-
- if (type_system)
+ DWARFASTParser *dwarf_ast = die.GetDWARFParser();
+ if (dwarf_ast)
{
- CompilerDeclContext actual_decl_ctx = type_system->GetDeclContextContainingUIDFromDWARF (die);
+ CompilerDeclContext actual_decl_ctx = dwarf_ast->GetDeclContextContainingUIDFromDWARF (die);
if (actual_decl_ctx)
return actual_decl_ctx == *decl_ctx;
}
@@ -2967,11 +2967,10 @@
if (!DIEInDeclContext (parent_decl_ctx, die))
continue; // The containing decl contexts don't match
- TypeSystem *type_system = die.GetTypeSystem();
-
- if (type_system)
+ DWARFASTParser *dwarf_ast = die.GetDWARFParser();
+ if (dwarf_ast)
{
- namespace_decl_ctx = type_system->GetDeclContextForUIDFromDWARF (die);
+ namespace_decl_ctx = dwarf_ast->GetDeclContextForUIDFromDWARF (die);
if (namespace_decl_ctx)
break;
}
@@ -3525,13 +3524,17 @@
if (type_system)
{
- Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO);
- type_sp = type_system->ParseTypeFromDWARF (sc, die, log, type_is_new_ptr);
- if (type_sp)
+ DWARFASTParser *dwarf_ast = type_system->GetDWARFParser();
+ if (dwarf_ast)
{
- TypeList* type_list = GetTypeList();
- if (type_list)
- type_list->Insert(type_sp);
+ Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO);
+ type_sp = dwarf_ast->ParseTypeFromDWARF (sc, die, log, type_is_new_ptr);
+ if (type_sp)
+ {
+ TypeList* type_list = GetTypeList();
+ if (type_list)
+ type_list->Insert(type_sp);
+ }
}
}
}