Skip to content

Extra implicit 'this' parameter entry when emitting a DW_TAG_subprogram with an explicit object parameter #99744

Closed
@Michael137

Description

@Michael137
struct Foo {                      
    template <class Self>         
    void func(this Self&& self) {}
};                                
                                  
int main() {                      
    Foo{}.func();                 
}                                 

The above will currently produce following DWARF:

DW_TAG_structure_type
  DW_AT_name      ("Foo")
  DW_TAG_subprogram
    DW_AT_name    ("func<Foo>")
    DW_AT_declaration     (true)
    DW_AT_external        (true)
    DW_TAG_template_type_parameter
      DW_AT_type  (0x0000000000000034 "Foo")
      DW_AT_name  ("Self")
    DW_TAG_formal_parameter
      DW_AT_type  (0x0000000000000051 "Foo *")
      DW_AT_artificial    (true)
    DW_TAG_formal_parameter
      DW_AT_type  (0x0000000000000056 "Foo &&")
    NULL
  NULL

DW_TAG_subprogram
  DW_AT_specification     (0x000000000000003a "_ZNH3Foo4funcIS_EEvOT_")
  DW_TAG_formal_parameter
    DW_AT_location        (DW_OP_fbreg +8)
    DW_AT_name    ("self")
    DW_AT_type    (0x0000000000000056 "Foo &&")
  DW_TAG_template_type_parameter
    DW_AT_type    (0x0000000000000034 "Foo")
    DW_AT_name    ("Self")

Note how the declaration of func has 2 DW_TAG_formal_parameter entries, one for the explicit object parameter self and (erroneously) another for the implicit object parameter this. The definition only has the explicit object parameter.

Looks like CGDebugInfo::getOrCreateInstanceMethodType would need to account for the fact that an explicit object parameter may exist, in which case we don't want to create the implicit artificial this parameter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions