Skip to content

Commit 11f77d3

Browse files
committed
[lldb][NFC] Move DWARFASTParserClang::GetTypeForDIE to DWARFASTParser
(cherry picked from commit 040c4f4) (cherry picked from commit fd6891f75c7692a6baab6b25bb70860530ac2088)
1 parent 6e058c7 commit 11f77d3

File tree

4 files changed

+28
-26
lines changed

4 files changed

+28
-26
lines changed

lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "DWARFASTParser.h"
1010
#include "DWARFAttribute.h"
1111
#include "DWARFDIE.h"
12+
#include "SymbolFileDWARF.h"
1213

1314
#include "lldb/Core/ValueObject.h"
1415
#include "lldb/Symbol/SymbolFile.h"
@@ -99,6 +100,30 @@ DWARFASTParser::ParseChildArrayInfo(const DWARFDIE &parent_die,
99100
return array_info;
100101
}
101102

103+
Type *DWARFASTParser::GetTypeForDIE(const DWARFDIE &die) {
104+
if (!die)
105+
return nullptr;
106+
107+
SymbolFileDWARF *dwarf = die.GetDWARF();
108+
if (!dwarf)
109+
return nullptr;
110+
111+
DWARFAttributes attributes = die.GetAttributes();
112+
if (attributes.Size() == 0)
113+
return nullptr;
114+
115+
DWARFFormValue type_die_form;
116+
for (size_t i = 0; i < attributes.Size(); ++i) {
117+
dw_attr_t attr = attributes.AttributeAtIndex(i);
118+
DWARFFormValue form_value;
119+
120+
if (attr == DW_AT_type && attributes.ExtractFormValueAtIndex(i, form_value))
121+
return dwarf->ResolveTypeUID(form_value.Reference(), true);
122+
}
123+
124+
return nullptr;
125+
}
126+
102127
AccessType
103128
DWARFASTParser::GetAccessTypeFromDWARF(uint32_t dwarf_accessibility) {
104129
switch (dwarf_accessibility) {

lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ class DWARFASTParser {
6363
ParseChildArrayInfo(const DWARFDIE &parent_die,
6464
const lldb_private::ExecutionContext *exe_ctx = nullptr);
6565

66+
lldb_private::Type *
67+
GetTypeForDIE(const lldb_private::plugin::dwarf::DWARFDIE &die);
68+
6669
static lldb::AccessType GetAccessTypeFromDWARF(uint32_t dwarf_accessibility);
6770
};
6871

lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3181,30 +3181,6 @@ size_t DWARFASTParserClang::ParseChildParameters(
31813181
return arg_idx;
31823182
}
31833183

3184-
Type *DWARFASTParserClang::GetTypeForDIE(const DWARFDIE &die) {
3185-
if (!die)
3186-
return nullptr;
3187-
3188-
SymbolFileDWARF *dwarf = die.GetDWARF();
3189-
if (!dwarf)
3190-
return nullptr;
3191-
3192-
DWARFAttributes attributes = die.GetAttributes();
3193-
if (attributes.Size() == 0)
3194-
return nullptr;
3195-
3196-
DWARFFormValue type_die_form;
3197-
for (size_t i = 0; i < attributes.Size(); ++i) {
3198-
dw_attr_t attr = attributes.AttributeAtIndex(i);
3199-
DWARFFormValue form_value;
3200-
3201-
if (attr == DW_AT_type && attributes.ExtractFormValueAtIndex(i, form_value))
3202-
return dwarf->ResolveTypeUID(form_value.Reference(), true);
3203-
}
3204-
3205-
return nullptr;
3206-
}
3207-
32083184
clang::Decl *DWARFASTParserClang::GetClangDeclForDIE(const DWARFDIE &die) {
32093185
if (!die)
32103186
return nullptr;

lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,6 @@ class DWARFASTParserClang : public DWARFASTParser {
180180
const DWARFDIE &die,
181181
ParsedDWARFTypeAttributes &attrs);
182182

183-
lldb_private::Type *GetTypeForDIE(const DWARFDIE &die);
184-
185183
clang::Decl *GetClangDeclForDIE(const DWARFDIE &die);
186184

187185
clang::DeclContext *GetClangDeclContextForDIE(const DWARFDIE &die);

0 commit comments

Comments
 (0)