[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Don't overwrite DW_AT_object_pointer of definition with that of a declaration (PR #123089)

Michael Buch via lldb-commits lldb-commits at lists.llvm.org
Thu Jan 16 03:49:33 PST 2025


================
@@ -377,7 +377,12 @@ ParsedDWARFTypeAttributes::ParsedDWARFTypeAttributes(const DWARFDIE &die) {
       break;
 
     case DW_AT_object_pointer:
-      object_pointer = form_value.Reference();
+      // GetAttributes follows DW_AT_specification.
+      // DW_TAG_subprogram definitions and declarations may both
+      // have a DW_AT_object_pointer. Don't overwrite the one
+      // we parsed for the definition with the one from the declaration.
----------------
Michael137 wrote:

The nice thing about omitting the second attribute is that I *think* we could get rid of the `Recurse` argument. Because the only caller that sets `Recurse` to `No` is to avoid possibly overwriting `DW_AT_low_pc` with the one from the declaration. Though haven't thought about this aspect too much yet.

> I am slightly concerned about the performance impact (I guess you'd have to iterate through the list to see if the attribute is not already there)

I was thinking we just make `DWARFAttributes` hold a `SmallSet` instead of a `SmallVector`. And `Append` will only ever insert a single entry (the only caller that `Appends` is currently `GetAttributes`, so if we fix iteration order then making it a set will ensure we only see the attribute of the most specific DIE)

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


More information about the lldb-commits mailing list