<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/99744>99744</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Extra implicit 'this' parameter entry when emitting a DW_TAG_subprogram with an explicit object parameter
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Michael137
</td>
</tr>
</table>
<pre>
```
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.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVl1v4jgU_TXm5WqQcUI-HvJAS5mt1GlXO6wq7UtknBviHcdGtlPKv185oXyVshOh1m18zz3n3BMH7pxca8SCTO_IdD7inW-MLX5I0XBUk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