Skip to content

Commit

Permalink
[lldb][NFC] Move DWARFASTParserClang::GetTypeForDIE to DWARFASTParser
Browse files Browse the repository at this point in the history
  • Loading branch information
augusto2112 committed Oct 24, 2023
1 parent b081da5 commit 040c4f4
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 27 deletions.
25 changes: 25 additions & 0 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "DWARFASTParser.h"
#include "DWARFAttribute.h"
#include "DWARFDIE.h"
#include "SymbolFileDWARF.h"

#include "lldb/Core/ValueObject.h"
#include "lldb/Symbol/SymbolFile.h"
Expand Down Expand Up @@ -100,6 +101,30 @@ DWARFASTParser::ParseChildArrayInfo(const DWARFDIE &parent_die,
return array_info;
}

Type *DWARFASTParser::GetTypeForDIE(const DWARFDIE &die) {
if (!die)
return nullptr;

SymbolFileDWARF *dwarf = die.GetDWARF();
if (!dwarf)
return nullptr;

DWARFAttributes attributes = die.GetAttributes();
if (attributes.Size() == 0)
return nullptr;

DWARFFormValue type_die_form;
for (size_t i = 0; i < attributes.Size(); ++i) {
dw_attr_t attr = attributes.AttributeAtIndex(i);
DWARFFormValue form_value;

if (attr == DW_AT_type && attributes.ExtractFormValueAtIndex(i, form_value))
return dwarf->ResolveTypeUID(form_value.Reference(), true);
}

return nullptr;
}

AccessType
DWARFASTParser::GetAccessTypeFromDWARF(uint32_t dwarf_accessibility) {
switch (dwarf_accessibility) {
Expand Down
3 changes: 3 additions & 0 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ class DWARFASTParser {
ParseChildArrayInfo(const DWARFDIE &parent_die,
const ExecutionContext *exe_ctx = nullptr);

lldb_private::Type *
GetTypeForDIE(const lldb_private::plugin::dwarf::DWARFDIE &die);

static lldb::AccessType GetAccessTypeFromDWARF(uint32_t dwarf_accessibility);
};
} // namespace dwarf
Expand Down
24 changes: 0 additions & 24 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3292,30 +3292,6 @@ size_t DWARFASTParserClang::ParseChildParameters(
return arg_idx;
}

Type *DWARFASTParserClang::GetTypeForDIE(const DWARFDIE &die) {
if (!die)
return nullptr;

SymbolFileDWARF *dwarf = die.GetDWARF();
if (!dwarf)
return nullptr;

DWARFAttributes attributes = die.GetAttributes();
if (attributes.Size() == 0)
return nullptr;

DWARFFormValue type_die_form;
for (size_t i = 0; i < attributes.Size(); ++i) {
dw_attr_t attr = attributes.AttributeAtIndex(i);
DWARFFormValue form_value;

if (attr == DW_AT_type && attributes.ExtractFormValueAtIndex(i, form_value))
return dwarf->ResolveTypeUID(form_value.Reference(), true);
}

return nullptr;
}

clang::Decl *DWARFASTParserClang::GetClangDeclForDIE(const DWARFDIE &die) {
if (!die)
return nullptr;
Expand Down
3 changes: 0 additions & 3 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,6 @@ class DWARFASTParserClang : public lldb_private::plugin::dwarf::DWARFASTParser {
const lldb_private::plugin::dwarf::DWARFDIE &die,
ParsedDWARFTypeAttributes &attrs);

lldb_private::Type *
GetTypeForDIE(const lldb_private::plugin::dwarf::DWARFDIE &die);

clang::Decl *
GetClangDeclForDIE(const lldb_private::plugin::dwarf::DWARFDIE &die);

Expand Down

0 comments on commit 040c4f4

Please sign in to comment.