<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/104765>104765</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
"vtt" missing in SubroutineType
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
mgschossmann
</td>
</tr>
</table>
<pre>
When compiling following source, clang creates a virtual destructor for `A` with an artificial `vtt` argument. The `DILocalVariable` for `vtt` correctly has `arg: 2`.
However, the field `types` of the `DISubroutineType` for this virtual destructor seems to miss the additional parameter, as it only has two members and thus represents a function with only one parameter.
Source:
``` C
struct B {
virtual ~B() {}
};
struct A : virtual B {
};
A a;
```
LLVM-IR:
``` llvm
[...]
!5 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "A", file: !3, line: 5, size: 64, flags: DIFlagTypePassByReference | DIFlagNonTrivial, elements: !6, vtableHolder: !8, identifier: "_ZTS1A")
[...]
!34 = !DISubroutineType(types: !35)
!35 = !{null, !36}
!36 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !5, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
[...]
!70 = distinct !DISubprogram(name: "~A", linkageName: "_ZN1AD2Ev", scope: !5, file: !3, line: 5, type: !34, scopeLine: 5, flags: DIFlagArtificial | DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, declaration: !44, retainedNodes: !38)
!71 = !DILocalVariable(name: "this", arg: 1, scope: !70, type: !40, flags: DIFlagArtificial | DIFlagObjectPointer)
!72 = !DILocation(line: 0, scope: !70)
!73 = !DILocalVariable(name: "vtt", arg: 2, scope: !70, type: !74, flags: DIFlagArtificial)
!74 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !75, size: 64)
!75 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64)
[...]
```
I generated the IR using clang 19.1.0-rc2 on `x86_64-unknown-linux-gnu`.
DWARF generated from this IR is not affected and includes all formal parameters.
The issue seems to be that in `ItaniumCXXABI::addImplicitStructorParams`, the parameter is added, but in `CGDebugInfo::getOrCreateMethodType` another type array is read to create the `DISubroutineType`.
https://github.com/llvm/llvm-project/blob/d033ae172d1c5a85fd09c36e23608a9241ea2990/clang/lib/CodeGen/ItaniumCXXABI.cpp#L1870-L1890
https://github.com/llvm/llvm-project/blob/d033ae172d1c5a85fd09c36e23608a9241ea2990/clang/lib/CodeGen/CGDebugInfo.cpp#L1938-L1946
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMVk1v2zwS_jX0hbAhUZ8--OCPdWsgTYMkaIteAkocSdxSpEBSTrOH_vYFKfkr8Wb7ou_hBQzbHJLPPPNwyBlqDK8lwAIlK5RsJrS3jdKLtjZlo4xpqZSTQrGXxdcGJC5V23HBZY0rJYR6dv-M6nUJiKxxKaiscamBWjCY4j3XtqcCMzBW96VVGldKY5QGS5QG-JnbBlOJqba84iWnwk3trXWTVNd9C9LO8GMDzr7Z3aiSii9Uc1oIcGtGsHFHqbSG0ooX3FDj7FTXKFpigtJghoINCpYf1TPsQTuutgFccRDMrbQvHRiHoSo_4d099IVWveUSHl-6oz_bcHMtMAPQGmwVbrkxHoQyxi1XkgrcUU1bsINnajC3WMmRqH1WuIW2AG0wlQzbpjdYQ6fBgLROxqqXpQMaBPMblYQT6Bjc8P0wnEY0DlEaDB-8HgwDYbzCKFsNlmM0v1aI5IjM_VS2GQGyDYpW5x5GhCV24h72nuG93bHE9GQ5EDpfcHPz5dN0d3-FtRD7drQlq9lshpIDLxImGEUbzLixXJYWIxJudmvVdspwO5wZyS31ObD5-vS4_PA0UO81PFk_vcaStk4sjAhZIkKcqeJiNIWRGwsu_ThxA8P_4wdp7JcKWhuPv9sKWjufd9SY1cs9VKBBloBRth5nb5V81HzPqXBbQYBLbzN6Sp1tb11mf1SCgR7tubNzBtJdkYOVPH1_fAgHvvP_pU4Ue3m8Kq9SmeRDwo9BJ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