================
@@ -12,20 +12,143 @@
//===----------------------------------------------------------------------===//
#include "DWARFASTParserFortran.h"
+#include "DWARFDIE.h"
+#include "DWARFDebugInfo.h"
+#include "DWARFDeclContext.h"
+#include "DWARFDefines.h"
+#include "LogChannelDWARF.h"
+#include "SymbolFileDWARF.h"
+#include "SymbolFileDWARFDebugMap.h"
+#include "UniqueDWARFASTType.h"
+
+#include "lldb/Symbol/CompileUnit.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/ValueObject/ValueObject.h"
using namespace lldb;
using namespace lldb_private;
+using namespace lldb_private::plugin::dwarf;
+using namespace llvm::dwarf;
-DWARFASTParserFortran::DWARFASTParserFortran()
- : lldb_private::plugin::dwarf::DWARFASTParser(Kind::DWARFASTParserFortran)
{
-}
+DWARFASTParserFortran::DWARFASTParserFortran(
+ lldb_private::TypeSystemFortran &m_ast)
+ : lldb_private::plugin::dwarf::DWARFASTParser(Kind::DWARFASTParserFortran),
+ m_ast(m_ast) {}
DWARFASTParserFortran::~DWARFASTParserFortran() {}
+TypeSP DWARFASTParserFortran::UpdateSymbolContextScopeForType(
+ const SymbolContext &sc, const DWARFDIE &die, TypeSP type_sp) {
+ if (!type_sp)
+ return type_sp;
+
+ DWARFDIE sc_parent_die = SymbolFileDWARF::GetParentSymbolContextDIE(die);
+ dw_tag_t sc_parent_tag = sc_parent_die.Tag();
+
+ SymbolContextScope *symbol_context_scope = nullptr;
+ if (sc_parent_tag == DW_TAG_compile_unit ||
+ sc_parent_tag == DW_TAG_partial_unit) {
+ symbol_context_scope = sc.comp_unit;
+ } else if (sc.function != nullptr && sc_parent_die) {
+ symbol_context_scope =
+ sc.function->GetBlock(true).FindBlockByID(sc_parent_die.GetID());
+ if (symbol_context_scope == nullptr)
+ symbol_context_scope = sc.function;
+ } else {
+ symbol_context_scope = sc.module_sp.get();
+ }
+
+ if (symbol_context_scope != nullptr)
+ type_sp->SetSymbolContextScope(symbol_context_scope);
+ return type_sp;
+}
+
lldb::TypeSP DWARFASTParserFortran::ParseTypeFromDWARF(
const lldb_private::SymbolContext &sc,
const lldb_private::plugin::dwarf::DWARFDIE &die, bool *type_is_new_ptr) {
- return lldb::TypeSP();
+ TypeSP type_sp;
+ if (type_is_new_ptr)
+ *type_is_new_ptr = false;
+ Log *log = GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
+
+ if (die) {
+ SymbolFileDWARF *dwarf = die.GetDWARF();
+ if (log) {
+ dwarf->GetObjectFile()->GetModule()->LogMessage(
+ log,
+ "DWARFASTParserFortran::ParseTypeFromDWARF (die = 0x%8.8x) %s name"
+ "= "
+ "'%s')",
+ die.GetOffset(), plugin::dwarf::DW_TAG_value_to_name(die.Tag()),
+ die.GetName());
+ }
+ Type *type_ptr = dwarf->GetDIEToType().lookup(die.GetDIE());
+ if (!type_ptr) {
+ if (type_is_new_ptr)
+ *type_is_new_ptr = true;
+
+ const dw_tag_t tag = die.Tag();
+ ConstString type_name;
+ const char *type_name_cstr = nullptr;
+ CompilerType compiler_type;
+ DWARFAttributes attributes;
+ DWARFFormValue form_value;
+ Declaration decl;
+ uint32_t encoding = 0;
+ switch (tag) {
----------------
tarunprabhu wrote:
Do you anticipate handling other tags here in the future? If not, we can
probably just use an `if` instead of a `switch`.
https://github.com/llvm/llvm-project/pull/223406
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits