Skip to content

Commit 64f1fda

Browse files
committed
[lldb][NFCI] Redefine dw_attr_t typedef with llvm::dwarf::Attribute
Similar to dw_form_t, dw_attr_t is typedef'd to be a uint16_t. LLVM defines their type `llvm::dwarf::Attribute` as an enum backed by a uint16_t. Switching to the LLVM type buys us type checking and the requirement of explicit casts. Differential Revision: https://reviews.llvm.org/D150299
1 parent 2ee4dda commit 64f1fda

File tree

5 files changed

+8
-2
lines changed

5 files changed

+8
-2
lines changed

lldb/include/lldb/Core/dwarf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace dwarf {
2121
}
2222
}
2323

24-
typedef uint16_t dw_attr_t;
24+
typedef llvm::dwarf::Attribute dw_attr_t;
2525
typedef llvm::dwarf::Form dw_form_t;
2626
typedef llvm::dwarf::Tag dw_tag_t;
2727
typedef uint64_t dw_addr_t; // Dwarf address define that must be big enough for

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,8 @@ ParsedDWARFTypeAttributes::ParsedDWARFTypeAttributes(const DWARFDIE &die) {
274274
if (!attributes.ExtractFormValueAtIndex(i, form_value))
275275
continue;
276276
switch (attr) {
277+
default:
278+
break;
277279
case DW_AT_abstract_origin:
278280
abstract_origin = form_value;
279281
break;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ DWARFAbbreviationDeclaration::extract(const DWARFDataExtractor &data,
4040
m_has_children = data.GetU8(offset_ptr);
4141

4242
while (data.ValidOffset(*offset_ptr)) {
43-
dw_attr_t attr = data.GetULEB128(offset_ptr);
43+
auto attr = static_cast<dw_attr_t>(data.GetULEB128(offset_ptr));
4444
auto form = static_cast<dw_form_t>(data.GetULEB128(offset_ptr));
4545

4646
// This is the last attribute for this abbrev decl, but there may still be

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,8 @@ void DWARFUnit::AddUnitDIE(const DWARFDebugInfoEntry &cu_die) {
391391
if (!attributes.ExtractFormValueAtIndex(i, form_value))
392392
continue;
393393
switch (attr) {
394+
default:
395+
break;
394396
case DW_AT_loclists_base:
395397
SetLoclistsBase(form_value.Unsigned());
396398
break;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,8 @@ void ManualDWARFIndex::IndexUnitImpl(DWARFUnit &unit,
239239
dw_attr_t attr = attributes.AttributeAtIndex(i);
240240
DWARFFormValue form_value;
241241
switch (attr) {
242+
default:
243+
break;
242244
case DW_AT_name:
243245
if (attributes.ExtractFormValueAtIndex(i, form_value))
244246
name = form_value.AsCString();

0 commit comments

Comments
 (0)