[Lldb-commits] [lldb] 64f1fda - [lldb][NFCI] Redefine dw_attr_t typedef with llvm::dwarf::Attribute
Alex Langford via lldb-commits
lldb-commits at lists.llvm.org
Fri May 12 11:58:58 PDT 2023
Author: Alex Langford
Date: 2023-05-12T11:58:50-07:00
New Revision: 64f1fda29e2dd133c84f23474e29de02d7ed392d
URL: https://github.com/llvm/llvm-project/commit/64f1fda29e2dd133c84f23474e29de02d7ed392d
DIFF: https://github.com/llvm/llvm-project/commit/64f1fda29e2dd133c84f23474e29de02d7ed392d.diff
LOG: [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
Added:
Modified:
lldb/include/lldb/Core/dwarf.h
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
Removed:
################################################################################
diff --git a/lldb/include/lldb/Core/dwarf.h b/lldb/include/lldb/Core/dwarf.h
index 6fcf2f8cc0c78..e162a090ba7c9 100644
--- a/lldb/include/lldb/Core/dwarf.h
+++ b/lldb/include/lldb/Core/dwarf.h
@@ -21,7 +21,7 @@ namespace dwarf {
}
}
-typedef uint16_t dw_attr_t;
+typedef llvm::dwarf::Attribute dw_attr_t;
typedef llvm::dwarf::Form dw_form_t;
typedef llvm::dwarf::Tag dw_tag_t;
typedef uint64_t dw_addr_t; // Dwarf address define that must be big enough for
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 53068823ceac9..b8a517100524d 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -274,6 +274,8 @@ ParsedDWARFTypeAttributes::ParsedDWARFTypeAttributes(const DWARFDIE &die) {
if (!attributes.ExtractFormValueAtIndex(i, form_value))
continue;
switch (attr) {
+ default:
+ break;
case DW_AT_abstract_origin:
abstract_origin = form_value;
break;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp
index 5bd3b23dc95fe..8dd47e6da8d5f 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp
@@ -40,7 +40,7 @@ DWARFAbbreviationDeclaration::extract(const DWARFDataExtractor &data,
m_has_children = data.GetU8(offset_ptr);
while (data.ValidOffset(*offset_ptr)) {
- dw_attr_t attr = data.GetULEB128(offset_ptr);
+ auto attr = static_cast<dw_attr_t>(data.GetULEB128(offset_ptr));
auto form = static_cast<dw_form_t>(data.GetULEB128(offset_ptr));
// This is the last attribute for this abbrev decl, but there may still be
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
index 91be5e5b7bb6f..8e2e04d4176a0 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -391,6 +391,8 @@ void DWARFUnit::AddUnitDIE(const DWARFDebugInfoEntry &cu_die) {
if (!attributes.ExtractFormValueAtIndex(i, form_value))
continue;
switch (attr) {
+ default:
+ break;
case DW_AT_loclists_base:
SetLoclistsBase(form_value.Unsigned());
break;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
index 79cbb1059349a..9be005ea06d52 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -239,6 +239,8 @@ void ManualDWARFIndex::IndexUnitImpl(DWARFUnit &unit,
dw_attr_t attr = attributes.AttributeAtIndex(i);
DWARFFormValue form_value;
switch (attr) {
+ default:
+ break;
case DW_AT_name:
if (attributes.ExtractFormValueAtIndex(i, form_value))
name = form_value.AsCString();
More information about the lldb-commits
mailing list