<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/130618>130618</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang][ASTMatchers] global anonymous union declaration not picked up by ASTConsumer::handleTopLevelDecl
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
carlosgalvezp
</td>
</tr>
</table>
<pre>
Hi,
I'm trying to solve an issue with a clang-tidy check on the following example code:
```
static union {
int global;
};
```
Clearly this shows up in the AST as a `CXXRecordDecl` under the `TranslationUnitDecl`: https://godbolt.org/z/j8GqxvEYd
For debugging, I am overriding the `ASTConsumer::HandleTopLevelDecl` function in `MatchASTConsumer`, and I am just simply dumping the Decls that get picked up by it.
I notice that this `CXXRecordDecl` of the union is **not** picked up by this function.
Is this intentional? Why are global anonymous unions not registered as a "top level declaration"?
Thanks!
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJx0U8Fu4zYQ_ZrRZRCDoizZPuig2FV3gfbSuOj2SJETiQlFqiTlrPfrC0oKmu22gAEL0sx7b96bESHo3hLVUD5CecnEHAfnaym8caEX5kbfpqxz6l5_0sDPwBpgzWfghxGjv2vbY3QYnLkRCos6hJnwTccBBUojbP8QtbqjHEi-orMYB8JnZ4x7S630VYyTIZROERTNCg4V236sCVFELXG22lmEwyOwBlHbiL1xnTBQpDdwuGwPHzqBNWdDwps7xkEHDIN7CzhPqFcRzdMVRUCBULHzly-_kXReXUgaqBjOVpFfyqBiVy9sMCJqZ3-3Om41UDQ4xDiFpJu3wNveqc6ZuHO-B95-A96-HH_-6-vtpz_Vqqd1HhV1c99r2wM_42cUI7obea_V4uRK2Dxdz86GeSSfwIvmk7DK0NVNv9CNzLvI59nKJCpNBBX7VUQ5fGytWOIQVq08L3OIGPQ4mTuqeZzeCRNcwDiIiD1FnLR8JZWM6u6o424LHK2LWtJatxj6X7655wVyjSvV8AZ4Y11cH74HX1Deh9jhRhTW99pGsulDCrnFP4Y7Ck9b7Ciss_fRzWGlCkkdeup1iORJbcFyHt2EJnmGiqQRfgkROIeiXemug7CvAXgOrMlUXahTcRIZ1flhn1f5YV_ss6Hujp0snqWSklFZypzvc1nkp0qcqOpyzjNdc8ZLVuQs3xcHdtyp7lCV-TFnh5zk6SBgz2gU2uyMuY1pQbLlUOq8YFV-zIzoyITlAjlfriZpLC-Zr1PDQzf3AfbM6BDDPxBRR7Oc7dpRXqB8bJ6uyx6QD1Be_seuj2Yszn0Xyw_bN_ywfdnsTf2v5ddxmLuddCPwNknc_h4m715IRuDtMnIA3m5T32r-dwAAAP__e3p1iA">