[PATCH] D66352: Debug Info: Support for DW_AT_export_symbols for anonymous structs

Paul Robinson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 20 09:54:49 PDT 2019


probinson added a comment.

Looking at the dwarfstd.org examples, without the flag (e.g., for DWARF v4) we should emit something like this:

  <1> DW_TAG_struct_type
          DW_AT_name "A"
    <2> DW_TAG_struct_type
            // no DW_AT_name
        <3> DW_TAG_member
              DW_AT_name "x"
              DW_AT_type (int)
    <4> DW_TAG_struct_type
            // no DW_AT_name
        <5> DW_TAG_member
              DW_AT_name "y"
              DW_AT_type (int)
    <6> DW_TAG_member // this is A's member for the anonymous struct
            // no DW_AT_name
            DW_AT_type <2>
    <7> DW_TAG_member // this is A's member for the unnamed struct
            DW_AT_name "C"
            DW_AT_type <4>

which means the way the consumer knows to promote the members of `<2>` to the scope of `<1>` is that its only reference (from `<6>`) is via a member that is unnamed, and it knows NOT to promote the members of `<4>` because the reference to it is from a member that IS named.

Seems cleaner to flag the struct in v5, especially as it has essentially zero size cost (DW_AT_export_names would use DW_FORM_flag_present).

I'm aware that other languages can have different lookup rules, some of which really can't be expressed in DWARF and the consumer has to Just Know, if it's the kind of consumer that is expected to do name lookups.  And the consumer also has to be ready to do the more complicated thing for earlier DWARF versions that don't have the flag.  But if we have the flag, it seems like we ought to make use of it here.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66352/new/

https://reviews.llvm.org/D66352





More information about the llvm-commits mailing list