<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/100768>100768</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-format] RemoveParentheses confused by function calls containing comma operators
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-format
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
urnathan
</td>
</tr>
</table>
<pre>
I know Remove Parentheses has some be-careful stickers on it.
I discovered an unexpected removal which changes program semantics. Specifically, if a function call is of the form `foo((a, b))`, it is transformed from a single argument call to a multi-argument call of the form `foo(a, b)`. I.e. the comma operator is removed. Similar variants like `foo((a, b), (c, d))` are not so transformed -- it seems to happen only when a call's single argument is a comma expression.
[In my actual use case this was a macro invocation, and moving the LHS of the comma operator out of the call was not possible.]
```
// .clang-format:
// BasedOnStyle: LLVM
// RemoveParentheses: MultipleParentheses
void frob () {
// no transform here, expected
foo(a, b); // foo(a, b);
foo((a, b), c); // foo((a, b), c);
foo(a, (b, c)); // foo(a, (b, c));
foo((a, b), (c, d)); // foo((a, b), (c, d));
// loses parens here, unexpected and harmful
bar((a, b)); // bar(a, b);
// doesn't lose parens here, unexpected but harmless
baz(a, (b), c); // baz(a, (b), c);
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEVV1vqzgQ_TXOyyiImADJAw_traqt1KtdbaV9H8wA3hobeUx6s79-ZZK2If24EgoKc3x8znzYyKw7S1SJ_FbkdyucQu98NXmLoUe7ql1zrB7g2boX-JsGdyD4Cz3Z0BMTQ48M7AaCmtYKPbWTAQ5aPZNncBZ0SECkdyK9Of0-QKNZuQN5agAtTJZ-jaQCNeAjOxp46bXqQfVoO2IYves8DsA0oA1acQJPIyndaoXGHIX8AboFhHayKmhnIX4GzeBaCD1B6_wAokhb54TcCbnDuKQWch-fIp0JQlwQPFqOcGqg9W4ABNa2MwTou2kgG07cwQHCMJmg18vApzu-b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