Skip to content

Commit 040c4f4

Browse files
committed
[lldb][NFC] Move DWARFASTParserClang::GetTypeForDIE to DWARFASTParser
1 parent b081da5 commit 040c4f4

File tree

4 files changed

+28
-27
lines changed

4 files changed

+28
-27
lines changed

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

+25
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"
@@ -100,6 +101,30 @@ DWARFASTParser::ParseChildArrayInfo(const DWARFDIE &parent_die,
100101
return array_info;
101102
}
102103

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

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

+3
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ class DWARFASTParser {
6161
ParseChildArrayInfo(const DWARFDIE &parent_die,
6262
const ExecutionContext *exe_ctx = nullptr);
6363

64+
lldb_private::Type *
65+
GetTypeForDIE(const lldb_private::plugin::dwarf::DWARFDIE &die);
66+
6467
static lldb::AccessType GetAccessTypeFromDWARF(uint32_t dwarf_accessibility);
6568
};
6669
} // namespace dwarf

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

-24
Original file line numberDiff line numberDiff line change
@@ -3292,30 +3292,6 @@ size_t DWARFASTParserClang::ParseChildParameters(
32923292
return arg_idx;
32933293
}
32943294

3295-
Type *DWARFASTParserClang::GetTypeForDIE(const DWARFDIE &die) {
3296-
if (!die)
3297-
return nullptr;
3298-
3299-
SymbolFileDWARF *dwarf = die.GetDWARF();
3300-
if (!dwarf)
3301-
return nullptr;
3302-
3303-
DWARFAttributes attributes = die.GetAttributes();
3304-
if (attributes.Size() == 0)
3305-
return nullptr;
3306-
3307-
DWARFFormValue type_die_form;
3308-
for (size_t i = 0; i < attributes.Size(); ++i) {
3309-
dw_attr_t attr = attributes.AttributeAtIndex(i);
3310-
DWARFFormValue form_value;
3311-
3312-
if (attr == DW_AT_type && attributes.ExtractFormValueAtIndex(i, form_value))
3313-
return dwarf->ResolveTypeUID(form_value.Reference(), true);
3314-
}
3315-
3316-
return nullptr;
3317-
}
3318-
33193295
clang::Decl *DWARFASTParserClang::GetClangDeclForDIE(const DWARFDIE &die) {
33203296
if (!die)
33213297
return nullptr;

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

-3
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,6 @@ class DWARFASTParserClang : public lldb_private::plugin::dwarf::DWARFASTParser {
199199
const lldb_private::plugin::dwarf::DWARFDIE &die,
200200
ParsedDWARFTypeAttributes &attrs);
201201

202-
lldb_private::Type *
203-
GetTypeForDIE(const lldb_private::plugin::dwarf::DWARFDIE &die);
204-
205202
clang::Decl *
206203
GetClangDeclForDIE(const lldb_private::plugin::dwarf::DWARFDIE &die);
207204

0 commit comments

Comments
 (0)