<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/73867>73867</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-tidy] `readability-identifier-naming` suggest invalid fix when using empty macro arguments
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-tidy
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
bjosv
</td>
</tr>
</table>
<pre>
When running the fixer for `readability-identifier-naming` on macros that accepts empty arguments the fixer suggests invalid code.
An example is when using `readability-identifier-naming.MacroDefinitionCase=UPPER_CASE` on the following code:
``` c
#define concat(str1, str2) (str1 "" str2)
concat(,"b")
```
which clang-tidy changes to:
``` c
#define CONCAT(str1, str2) (str1 "" str2)
CONCAT("b")
```
.i.e. the required `,` in the expected `CONCAT(,"b")` is removed.
The example running on trunk. Add `--fix` to `Arguments` in the clang-tidy panel to see result of the fixer:
https://godbolt.org/z/vW4jPrT64
This example is a bit fabricated, but we have similar issues with googletests which are macro-heavy.
References
- Empty macro arguments are valid according to: https://gcc.gnu.org/onlinedocs/cpp/Macro-Arguments.html or [link](https://stackoverflow.com/a/7674214).
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVE1v4zYQ_TXUZSBBHsuSddDBa8e3tsE2xR4LihpJTCjSJSl_9NcXlBzHDgpsFjBskJ55fPPmzXDnZKeJKrb6xla7iI--N7aqX407RrVpLtWPnjTYUWupO_A9QSvPZKE1FlieWuINr6WS_hLLhrSXrSQbaz5I3bE8BaNh4MIaB77nHrgQdPAOaDj4C3DbjQNp7-6A3dh15LwDqY9cyQaEaShh6Y6lm_l7o4HOfDgoAungFPiNLrD7GZ_kt8BkR63U0kujt9wRW-7-en5--v73dvPn05XwRMYoZU4BNbzPlte3WZ7OHxDXC1w2AZBAGC24Z7h23i4YbsF5iwxLuF4BQ2SI79dz-i2J4ZYh1lNM-emt-XjqpehBKK672MvmAqLnuiMH3nyF3vaP37ebl1-kd0v6CbdEJpRMuln6Z5SWmtCMUFOegpwVpfOBhJ__ucO9LzsEO7A0mCM1Dz1_mQDmpr-bMXTKjvotgU0zocZxK88BxJtw3Ly7647EnXwHrkmFUEeBthuVB9N-OPEmau_9wYUT7hnuO9PURvnE2I7h_l-G--OP7PXZvuTZI2Hp7m3KoZYeWl5bKbinJnSgHj2cCHp-JHBykIpbkM6N5OAkfQ-dMZ0iP03D3H1uaR6nuCd-vDxI9J1asqQFufkcw9M0ZFP83agFjHmyuBDGNtNcBwvBp0KFSDo9Xgs1WklNjRGO4V4cDgz30zTFN5WT3g8KwlpYfVNSv7HVjuH6EdN5Lt7MkWyrzCkRZmC45wz3RV5kuMgYlg8lRU21bMplySOqFkW6wHKdZ3nUV22BTS5yorJdLJD4apmV1LQibVb5uubLSFaY4nKxwBJxVWCetEUmqOSIeV1kRVGyLKWBS5UodRxCjdGkfFUs13kRKV6TctNSRPzwTLDpahfZKiTF9dg5lqVKOu8-YLz0alqnd2mr3Zd25XX13TZfK8_3643-r53RaFX1qXHS92N9VTfwuv7EB2teSXiG-9llQfhQ7n8BAAD__w3X5jA">