<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/54885>54885</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-tidy] modernize-macro-to-enum can create invalid syntax in header files
</td>
</tr>
<tr>
<th>Labels</th>
<td>
bug,
clang-tidy
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
LegalizeAdulthood
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
LegalizeAdulthood
</td>
</tr>
</table>
<pre>
`modernize-macro-to-enum` creates a bunch of little insertions around a cluster of macros to turn this:
```
#define FOO1 1
#define FOO2 2
#define FOO3 3
```
into this
```
enum {
FOO1 = 1,
FOO2 = 2,
FOO3 = 3
};
```
The problem is that when the fixes are exported, the insertions of the `=` are not de-duplicated by clang-apply-replacements. So if clang-tidy is run with header-filter set to apply to application header files, the header files that have fixits issued in the course of analyzing multiple source files end up with invalid syntax llike this:
```
enum {
FOO1 = = 1,
FOO2 = = 2,
FOO3 = = 3
};
};
```
The fixes need to be recorded in such a way that they can be properly de-duplicated.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyNU9tum0AQ_Rp4GWHh5WL7gYekVp4q5aH9gYUdYNtlF-0lifP1nQU7cVpbqoSAuWjOzDkzrRGnJqnzyQi0Wr5jNvHOmsybDHWYKAKdRe7RAYc26G4E04OS3isEqR1aL42moDVBC8rpVHAebcxaKjnwBnywGvwoXVI8JPkxyS_vOj8_q8kKgb3UCE_Pz1vY3vAyYDe8BRQ3C0odwSPurWgcEJLd42otkElxJFj27cPFFhe7dhWL6wK4OybF483yP0eE2ZpW4QSSaBi5h9cRIxEIvXyLlFoEfJuN9SgIYolckUocRk-sWByjFDFfGw8CMxFmJTsSRkB7Ita5HjI-z-qUWZwV73BC7d0G4IcB2Z8TvBSn2IsNGl6lH2FETrpnvVRRM4c-qrWUufxEDGrmnEl9K3SXVq9963wjf1lmk94RjgvUnVwH7kywDuNIXHN1epd6gCkoL2daJEfBDs-FkPYozGt_Ur9wJQW4k_b8DZSSv_E_FumOsnfUvaPwPZXvK_6p-yqvRpqfeGwRLHbGipUOF-iKOLzy00oa0UMKch3zaGFmtET_F4k3qWgKcSgOPPWSLq9JqsdPRZPqCHfudym7HvDfXMqvmqbBqmb0fl6oZU_0DKRAaDedmchQ6uXyyajJX9h5MheNaR-eqnK_r9Kx6Q5lUVc17rDLWVEyduirfV_v6joXfdXuUsVbVC4OkDDWhoHecZ3oczUQ-apjKhuWM5aX2yIvWc22G15uD2Xe7kq-r6sKd0mZ48Sl2sSuNsYOqW2WBqmuo6CSjk7gI8idkwNpcgb_jgPx8Y4PgtZwNEacYXkgyzb_hNNl2GaZ9A8GHZ5m">