[Lldb-commits] [lldb] DRAFT: [lldb][DWARFASTParserClang] Remove old workaround (PR #160132)

Michael Buch via lldb-commits lldb-commits at lists.llvm.org
Mon Sep 29 04:37:19 PDT 2025


https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/160132

>From 1c07ed2746fd7867350b19204bf5feea7522124d Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Mon, 22 Sep 2025 16:02:35 +0100
Subject: [PATCH] Init

---
 .../SymbolFile/DWARF/DWARFASTParserClang.cpp  | 45 ++++---------------
 1 file changed, 9 insertions(+), 36 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index f1e73d73a733b..8f52242fd387d 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -3126,42 +3126,15 @@ void DWARFASTParserClang::ParseSingleMember(
   if (!member_clang_type.IsCompleteType())
     member_clang_type.GetCompleteType();
 
-  {
-    // Older versions of clang emit the same DWARF for array[0] and array[1]. If
-    // the current field is at the end of the structure, then there is
-    // definitely no room for extra elements and we override the type to
-    // array[0]. This was fixed by f454dfb6b5af.
-    CompilerType member_array_element_type;
-    uint64_t member_array_size;
-    bool member_array_is_incomplete;
-
-    if (member_clang_type.IsArrayType(&member_array_element_type,
-                                      &member_array_size,
-                                      &member_array_is_incomplete) &&
-        !member_array_is_incomplete) {
-      uint64_t parent_byte_size =
-          parent_die.GetAttributeValueAsUnsigned(DW_AT_byte_size, UINT64_MAX);
-
-      // If the attrs.member_byte_offset is still set to UINT32_MAX this means
-      // that the DW_TAG_member didn't have a DW_AT_data_member_location, so
-      // don't emit an error if this is the case.
-      if (attrs.member_byte_offset != UINT32_MAX &&
-          attrs.member_byte_offset >= parent_byte_size) {
-        if (member_array_size != 1 &&
-            (member_array_size != 0 ||
-             attrs.member_byte_offset > parent_byte_size)) {
-          module_sp->ReportError(
-              "{0:x8}: DW_TAG_member '{1}' refers to type {2:x16}"
-              " which extends beyond the bounds of {3:x8}",
-              die.GetID(), attrs.name,
-              attrs.encoding_form.Reference().GetOffset(), parent_die.GetID());
-        }
-
-        member_clang_type =
-            m_ast.CreateArrayType(member_array_element_type, 0, false);
-      }
-    }
-  }
+  if (attrs.member_byte_offset != UINT32_MAX &&
+      attrs.member_byte_offset >= parent_byte_size &&
+      llvm::expectedToOptional(member_clang_type.GetByteSize(nullptr))
+              .value_or(0) > 0)
+    module_sp->ReportError("{0:x8}: DW_TAG_member '{1}' refers to type {2:x16}"
+                           " which extends beyond the bounds of {3:x8}",
+                           die.GetID(), attrs.name,
+                           attrs.encoding_form.Reference().GetOffset(),
+                           parent_die.GetID());
 
   TypeSystemClang::RequireCompleteType(member_clang_type);
 



More information about the lldb-commits mailing list