This is an archive of the discontinued LLVM Phabricator instance.

Emit the DW_AT_type for a C++ static member definition if it is more specific than the one in its DW_AT_specification.
ClosedPublic

Authored by aprantl on Nov 7 2016, 1:16 PM.

Details

Summary

If a static member is an array, the translation unit containing the member definition may have a more specific type (including its length) than TUs only seeing the class declaration. This patch adds a DW_AT_type to the member's DW_TAG_variable in addition to the DW_AT_specification in these cases. The member type in the DW_AT_specification still shows the more generic type (without the length) to avoid defeating type uniquing.

The DWARF standard discourages “duplicating” a DW_AT_type in a member variable definition but doesn’t explicitly forbid it.
Having the more specific type (with the array length) available is what allows the debugger to print the contents of a static array member variable.

rdar://problem/28706946

Diff Detail

Event Timeline

aprantl updated this revision to Diff 77085.Nov 7 2016, 1:16 PM
aprantl retitled this revision from to Emit the DW_AT_type for a C++ static member definition if it is more specific than the one in its DW_AT_specification..
aprantl updated this object.
aprantl added reviewers: dblaikie, echristo, probinson.
aprantl added a subscriber: jingham.
probinson edited edge metadata.Nov 7 2016, 2:31 PM

I think it makes sense to put the more explicit type on the definition. Same deal as putting the more explicit return type on the definition of an 'auto' member function.

test/DebugInfo/X86/static_member_array.ll
22

The subrange must be a child of the array_type, so you should also CHECK-NOT: NULL here.

32

CHECK-NOT: NULL here too

34

No DW_TAG or NULL between the subrange_type and the count.

35

Don't need this CHECK: NULL at the end.

dblaikie accepted this revision.Nov 8 2016, 1:01 PM
dblaikie edited edge metadata.

Looks good - Paul's suggestions sound right too.

This revision is now accepted and ready to land.Nov 8 2016, 1:01 PM
aprantl closed this revision.Nov 8 2016, 2:21 PM

Thanks! r286302.