Author: Michael Buch
Date: 2025-07-03T10:28:38+01:00
New Revision: 58d84a615e9180eeff583a9d30033ba21343550d

URL: 
https://github.com/llvm/llvm-project/commit/58d84a615e9180eeff583a9d30033ba21343550d
DIFF: 
https://github.com/llvm/llvm-project/commit/58d84a615e9180eeff583a9d30033ba21343550d.diff

LOG: [lldb][DWARF][NFC] Reduce scope of ref_addr_size variable (#146557)

Follow-up to
https://github.com/llvm/llvm-project/pull/145645#discussion_r2174948997

There's no need for this variable to be declared at the function-level.
We reset it in all the cases where it's used anyway.

This patch just inlines the usage of the variable entirely.

Added: 
    

Modified: 
    lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
index 2e98e3c33acaf..767cda634f973 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
@@ -36,7 +36,6 @@ bool DWARFFormValue::ExtractValue(const DWARFDataExtractor 
&data,
   bool indirect = false;
   bool is_block = false;
   m_value.data = nullptr;
-  uint8_t ref_addr_size;
   // Read the value for the form into value and follow and DW_FORM_indirect
   // instances we run into
   do {
@@ -78,8 +77,8 @@ bool DWARFFormValue::ExtractValue(const DWARFDataExtractor 
&data,
     case DW_FORM_line_strp:
     case DW_FORM_sec_offset:
       assert(m_unit);
-      ref_addr_size = m_unit->GetFormParams().getDwarfOffsetByteSize();
-      m_value.uval = data.GetMaxU64(offset_ptr, ref_addr_size);
+      m_value.uval = data.GetMaxU64(
+          offset_ptr, m_unit->GetFormParams().getDwarfOffsetByteSize());
       break;
     case DW_FORM_addrx1:
     case DW_FORM_strx1:
@@ -121,8 +120,8 @@ bool DWARFFormValue::ExtractValue(const DWARFDataExtractor 
&data,
       break;
     case DW_FORM_ref_addr:
       assert(m_unit);
-      ref_addr_size = m_unit->GetFormParams().getRefAddrByteSize();
-      m_value.uval = data.GetMaxU64(offset_ptr, ref_addr_size);
+      m_value.uval = data.GetMaxU64(
+          offset_ptr, m_unit->GetFormParams().getRefAddrByteSize());
       break;
     case DW_FORM_indirect:
       m_form = static_cast<dw_form_t>(data.GetULEB128(offset_ptr));
@@ -208,7 +207,6 @@ bool DWARFFormValue::SkipValue(dw_form_t form,
                                const DWARFDataExtractor &debug_info_data,
                                lldb::offset_t *offset_ptr,
                                const DWARFUnit *unit) {
-  uint8_t ref_addr_size;
   switch (form) {
   // Blocks if inlined data that have a length field and the data bytes inlined
   // in the .debug_info
@@ -247,8 +245,7 @@ bool DWARFFormValue::SkipValue(dw_form_t form,
   case DW_FORM_ref_addr:
     assert(unit); // Unit must be valid for DW_FORM_ref_addr objects or we will
                   // get this wrong
-    ref_addr_size = unit->GetFormParams().getRefAddrByteSize();
-    *offset_ptr += ref_addr_size;
+    *offset_ptr += unit->GetFormParams().getRefAddrByteSize();
     return true;
 
   // 0 bytes values (implied from DW_FORM)
@@ -284,8 +281,7 @@ bool DWARFFormValue::SkipValue(dw_form_t form,
     case DW_FORM_strp:
     case DW_FORM_line_strp:
       assert(unit);
-      ref_addr_size = unit->GetFormParams().getDwarfOffsetByteSize();
-      *offset_ptr += ref_addr_size;
+      *offset_ptr += unit->GetFormParams().getDwarfOffsetByteSize();
       return true;
 
     // 4 byte values


        
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to