Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

C++ Debug info should reference DW_TAG_template_type_parameter #26553

Open Quuxplusone opened 8 years ago

Quuxplusone commented 8 years ago
Bugzilla Link PR26553
Status NEW
Importance P normal
Reported by Adrian Prantl (aprantl@apple.com)
Reported on 2016-02-09 16:02:58 -0800
Last modified on 2016-02-09 20:02:43 -0800
Version trunk
Hardware PC All
CC aprantl@apple.com, clayborg@gmail.com, compnerd@compnerd.org, dblaikie@gmail.com, echristo@gmail.com, llvm-bugs@lists.llvm.org, paul_robinson@playstation.sony.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
The DWARF standard recommends the debug info for the following snippet:

Figure D.50: C++ template example #1: source
// C++ source
//
template <class T> struct wrapper {
  T comp;
};
wrapper<int> obj;

to be emitted as:

! DWARF description
!
11$: DW_TAG_structure_type
        DW_AT_name("wrapper")
12$:    DW_TAG_template_type_parameter
            DW_AT_name("T")
            DW_AT_type(reference to "int")
13$:    DW_TAG_member
            DW_AT_name("comp")
            DW_AT_type(reference to 12$)
                       ^^^^^^^^^^^^^^^^
                         The type of comp is T.
14$: DW_TAG_variable
        DW_AT_name("obj")
        DW_AT_type(reference to 11$)

what clang r260113 is actually emitting is

0x00000034:     TAG_structure_type [3] *
                 AT_name( "wrapper<int>" )
                 AT_byte_size( 0x04 )
                 AT_decl_file( "/private/tmp/template.cpp" )
                 AT_decl_line( 4 )

0x0000003c:         TAG_member [4]
                     AT_name( "comp" )
                     AT_type( {0x00000054} ( int ) )
                                            ^^^^^
                                             The type of comp is int.

                     AT_decl_file( "/private/tmp/template.cpp" )
                     AT_decl_line( 5 )
                     AT_data_member_location( +0 )

0x0000004a:         TAG_template_type_parameter [5]
                     AT_type( {0x00000054} ( int ) )
                     AT_name( "T" )

0x00000053:         NULL

0x00000054:     TAG_base_type [6]
                 AT_name( "int" )
                 AT_encoding( DW_ATE_signed )
                 AT_byte_size( 0x04 )
Quuxplusone commented 8 years ago

Would be somewhat nice to have (not sure I've seen anyone complain about it though) but probably a bit of work to plumb through to make DW_TAG_template_type_parameter a valid type in the DIType hierarchy somewhere.

(GCC 4.8 does the same thing as Clang, so far as I can tell)