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

    <tr>
        <th>Summary</th>
        <td>
            [clang] `generateUSRForDecl` does not work for anonymous structs
        </td>
    </tr>

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

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

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

<pre>
    For simple structures like this:
```C
struct A {
        struct {
 int a;
        };
        struct {
                int b;
        };
};
```
`generateUSRForDecl` at:
https://github.com/llvm/llvm-project/blob/6009708b4367171ccdbf4b5905cb6a803753fe18/clang/lib/Index/USRGeneration.cpp#L1141
returns `false` for the two `struct A`'s fields, i.e. the anonymous structures. And their USR is indeed duplicate `c:@S@A@FI@`. 

BTW USR of those `int`s `a` and `b` is indeed valid and correct. `c:@S@A@Sa@FI@a` and `c:@S@A@Sa@FI@b` , respectively.

Why not simply add a field *index* after their `@FI@`?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVN1u4yoQfhp8g46FwTb2hS_SRj6qdK6aU_Wan3FMS0wEON28_Qo7abrtdqVFURiG-fs-ZixCMPsJoEPVHaq2mZjj6Hz3YrwJVshzJp0-d73zOJjD0QIO0c8qzh4CtuYVcBxNQGyDyBaRDarJ-rtfz6sx3mDE71YNvqzLzU1vpogFYp_MEN9-0X1x_bRSJPnHSL_I15Lfj3uYwIsIT7vH3vktKItqgkV8RznGeFww0x7Rfm_iOMtcuQOivbWn6_bP0bsXUBHRXlonEe1rQlpOGlmymhe8UErLoZRVSyola9EQxis2QNEg2isrpn0KZJLjw6ThB6L90-7x37U446ZcHY-Isv-KoizWujzE2U8Bo5oMwgZIZQ_O4zgCjm8u6a8PkvBSHvBgwOqA6D02OeSLpZjcdD64OXx46hxvJp1ujcdPu0dsAjaTBtBYz0drlIiQoqtESkl2qCRp7x9QmZjN8YXb5f_u_-clhhtwHF1YHM0UU3FJFAvZk06yTPIt10lYo5c75bwHFfPfJN2Ja-aPkb41WlIk_B7CEVQ0J7Dn_GO9z-MZTy6u_X_GQmssVt4wohuzPs0GiyGCv1CU2L3BR6zPdMd0y1qRQVfwgleckKrNxq5SxaBp2dChYpJLrqumbPSgmK7ahgmamY4SWpKaVKQuOWvzttCE101Tq4G3jUpA4CCMzVPP5c7vMxPCDF1bloxlVkiwYRluSi9NRdOc-27pUTnvAyqJNSGGW4Rool2-CKtHtcXfjoV2EBZ63px_Xbrtc_-EbPa2--uZWVAERPsVyKmjPwMAAP__DZJckA">