================
@@ -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.
----------------
labath 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.

That would also be true with the implementation which puts the most specific 
attribute first (the code could ignore the second instance, like you do now), 
although keeping recurse option might still be nice for performance reasons (if 
we know we don't need to recurse, we can skip doing that).

> I was thinking we just make DWARFAttributes hold a SmallSet (or SetVector) 
> 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)

For small values a SmallSet *is* a vector with a linear search for matching 
keys. It might work. I don't know if this will be a problem, I'm just saying it 
*could* be.

https://github.com/llvm/llvm-project/pull/123089
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to