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

    <tr>
        <th>Summary</th>
        <td>
            clangd: renaming class template breaks 'friend class' declarations
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

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

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

<pre>
    ```c++
template<class C>
class A {  // <--
  class B {
    friend class A;
 };
};
```
If I hover over `A` and rename it to `A2` using clangd, the output is invalid:
```c++
template<class C>
class A2 {
 class B {
    friend A2 A;  // <-- invalid syntax
 };
};
```
llvm-project version: 16.0.1 cd89023f797900e4492da58b7bed36f702120011
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUUs2OmzAQfprhMgoyNn8-cCBJI-1j2HgAtw5Etom6b18Bod3tYaWVLGD4xprvZ1QIdpiIGijOUFwTtcRx9k2IXg3kEz2b9wZKtp8O-Hk97AqsjXR_OBUJxKVzKgS8gPixQ3vdIlRnROA34DcEcTmddhhxbzivDccvxN5bmswLa0EcEFTXv8Wn74PWXr71-Ibj_CSP2wPKrQXVZNDTpO6ENmKcN4CvyBLsNKzzpsEAv2AcCeclPpaINqCdnspZA6L9b9w3XeAfVH6lu-Wb6M-GHSwwvE9R_f6eI84976eHn39SF_FJPth5AtFiVqYszbAztWRc9JWsJGOU55IbVdS60mRE2VeMZ5yxLEtMI4wUUiXUZGUty7zksk7Gps9lxgutWUay7jQzZVkXfd2R0ozldZHYhjMuWJXVjGeZqFOtVCVE3ysmc6l7gpzRXVmXrlTT2Q-JDWGhphRS8MQpTS4cm-mbTY9ehgA5czbE8O9atNFR84pStHvgr3RDwCMl1J7Ur4DAq4_bBrxCQ51TXkU7TyFZvGvGGB9hTX-LY7BxXHTazXfgt3Xs63X4C_y2UQ_Abxv7PwEAAP__Q9n2VQ">