[Lldb-commits] [lldb] [LLDB][NativePDB] Add non-overlapping fields in root struct (PR #166243)

via lldb-commits lldb-commits at lists.llvm.org
Wed Nov 5 02:36:59 PST 2025


================
@@ -462,8 +466,23 @@ void UdtRecordCompleter::Record::ConstructRecord() {
       }
       if (iter->second.empty())
         continue;
-      parent = iter->second.back();
-      iter->second.pop_back();
+
+      // If the new fields come after the already added ones
+      // without overlap, go back to the root.
+      if (iter->first <= offset && is_last_end_offset(iter)) {
+        if (record.kind == Member::Struct)
+          parent = &record;
+        else {
+          lldbassert(record.kind == Member::Union &&
+                     "Current record must be a union");
+          lldbassert(!record.fields.empty());
----------------
Nerixyz wrote:

These asserts should fall under 
> An assertion should be placed to assert invariants that the developer is convinced will always hold, regardless what an end-user does with LLDB.

The first assert holds because we only ever get here for unions and structs. The fields should never be empty, because at this point, the offset is larger than the starting one / if the fields were empty, `offset == start_offset`.

https://github.com/llvm/llvm-project/pull/166243


More information about the lldb-commits mailing list