<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/134549>134549</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
DebugInfo: preferred_name causes DIDerivedType node to be emitted twice
</td>
</tr>
<tr>
<th>Labels</th>
<td>
debuginfo
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
mizvekov
</td>
</tr>
</table>
<pre>
This is a problem isolated from one of our own test cases: `clang/test/CodeGen/preferred_name.cpp`
The test expectation captures this, but there is no acknowledgement the bug exists.
Reduced repro: https://godbolt.org/z/dn9hs87ev
```C++
template <class T> struct Foo;
template <class T> using Bar = Foo<T>;
template <class T>
struct [[clang::preferred_name(Bar<short>)]] Foo {};
Bar<short> barShort;
```
Reduced output:
```
!6 = !DIDerivedType(tag: DW_TAG_typedef, name: "Bar<short>", file: !5, line: 2, baseType: !7)
!7 = !DIDerivedType(tag: DW_TAG_typedef, name: "Bar<short>", file: !5, line: 2, baseType: !8)
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzEVEuvozYU_jWHzdFExuAQFixIKKPZtpG6vDL4JLhjMPIj9_HrK5P0qrlSux3JEljnfP4efkjv9XUhakAcQXSZjGGyrpn1x41-2ls2WPXenCftUXuUuDo7GJpRe2tkIIUXZ2e0C6G9oI0O7euCgXzAUXryULQIezYauVyB96kAvD9ZRd9pAd6vji7kHKmXRc60G9cV9gxYC6w9T3RfiN5WGoMM2i44yjVERx7DpD3wEw4xYJjIUZK3WJTjz8W-GlJXmmnZajjEK9Kb9sHv7kv_TiqOpNDR6mySOIWwJq3Ae-D91arBmrCzLmn-AN6rpZ78oaJbwu_ZfZyAH9NgbaB5TWkgFKfRSO_xDMVv6IOLY8DeWij-py16vVzxKB1C0d27T6lwB_0nDlj7INh27njPuGihaJ9TBX44SgfFyU_WhYTkNYgOxEaGUB2h6j7JnltxkO6P-__x396fc7QxrDEk7i8tPN9vpoDn3Y-OnL6ROr-vSVKQSSx2f76c2-8v4X0lRZe0o5vkdGw4_yqbp_pFm0c9F2lu9LLNt-IgPW0E94YqWd10VL9Ux-Gh459sMtUUqi5qmVGTV2VRi5oJlk3NgaisxXgQsmZ7VaiSBJdMDIdqFHvFVKYbzrhgJdvnFStztpNsyHnBRVHmVNeHCkpGs9RmZ8xtTkc4095HavKiFGWdGTmQ8dtl51zREK96udhkSXSZaxLo2xCvHkpmthvzuUzQwVDTJciPBClafD5nOMroyeNTwrhYRRgsDoQ065CejPCqR8qiM82Xe6fDFIfdaGfgfeJ9fL6tzv5FY3o5Ni8eeP-wc2v43wEAAP__TdB0rg">