<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/102281>102281</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            CTAD: Don't reuse the template parameters of the class in the synthesized deduction guide.
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:frontend
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          hokein
      </td>
    </tr>
</table>

<pre>
    https://godbolt.org/z/ea8vzaoeP

```
template <typename T1> struct B {
  B(T1);
};

B b(1);
```

The AST is: 

```
|-ClassTemplateDecl 0xd400cf0 <<source>:1:1, line:3:1> line:1:31 B
| |-TemplateTypeParmDecl 0xd400b68 <col:11, col:20> col:20 referenced typename depth 0 index 0 T1
...

-FunctionTemplateDecl 0xd401680 <line:1:1, line:2:7> col:3 implicit <deduction guide for B>
| |-TemplateTypeParmDecl 0xd400b68 <line:1:11, col:20> col:20 referenced typename depth 0 index 0 T1
| |
```

Note that the `TemplateTypeParmDecl` is the same in the class template decl and deduction guide. We seem to take a shortcurt and reuse the `TemplateTypeParmDecl` when synthesizing the deduction guide. Instead, we should clone one to make distinct template parameters for the deduction guide.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVF9v4ygQ_zT4ZdQIQ2I7D37In0a6l9NKF-meMYxjbjFEMO5u--lPOG6b3VZ7OmmlmIwxM78_g0alZC8esWWbPdscCzXREGI7hK9ofdEF89wORNfE5I6JExOnSzBdcLQK8cLE6YWJE6rm6UUF_ML4kfHdslZ8-c2vhOPVKUJg8kDPV_RqRDiXTD5Cojhpgj2wen87DLBnojmXTGyZXPZYfXyP53UPHRPNj4d-BL2t5wFh99cZbNYAv-DI6sPDwamUzgvZI2oH_LtZc657nqkzeUhhihqZfGRyV86POICzHpncydve4-t7_i5LeJNwgIzxWv78fMUvKo53MF3VZBgdXM6eS99iwXPZ1xgi9hjRazTw5qbBKw3AwXqD34Fnd2fY1Wp1L_rhNHlNNviPKsuqmVXesb9XJ5jc1e80JNjx6qy2lHMMmmkuC5fJGoQ-RNhnl_6n9Hvs36N_wf7FDfkzEAINioAGBFbxz2iyioNN84mU4ayfY50vDLxdb5MFKW_gJz9W8DdCQhyBApD6iqAgDSGSniLNCRGnhP9F4NuAHtKzpwGTfbH-Mid8wPrDJ0Jlsn3fMONMzoB2wSPkhwKMmYKxiazX9E7_qqIakTCmuYGfFb9ZVphWmq3cqgLbshaSl_WaN8XQdlslKiVlWRrRqL5SqsKyMrjBTae2lS5sK7hY84bXvN5U62a17ZTsetz2W73R_dqwNcdRWbdy7mnMY6awKU3YllyIpiyc6tCleVwJoZ3yFyZ3fQye0BsmRB5isc25D910SWzNnU2U3quRJYft4bw75nlwDJ6Jmu7s_8yM0N81e-n8WxvwY7eLKbqf56alYepWOoxMnDKZ5e_hGsM_qImJ06wzMXFapD614t8AAAD__05NuJs">