Open Sirraide opened 1 month ago
@llvm/issue-subscribers-clang-frontend
Author: None (Sirraide)
The culprit seems to be the fact that the AST we get after instantiating this is:
`-CompoundStmt 0x289d21d8 <col:24, line:3:1>
`-IfStmt 0x289d21b8 <line:2:5, col:32>
|-ParenExpr 0x289d2198 <col:10, col:20> 'bool'
| `-BinaryOperator 0x289d2178 <col:11, col:19> 'bool' '=='
| |-ImplicitCastExpr 0x289d2160 <col:11> 'int' <LValueToRValue>
| | `-DeclRefExpr 0x289d2128 <col:11> 'int' lvalue ParmVar 0x289d1e18 'args' 'int'
| `-IntegerLiteral 0x289d1a98 <col:19> 'int' 0
`-CompoundStmt 0x289d1b38 <col:31, col:32>
which looks exactly as though the user had written if ((args == 0)) {}
.
The following code (https://godbolt.org/z/rPqP4r55b):
results in a
-Wparentheses-equality
warning:However, the suggestion to remove parentheses here is obviously wrong: neither pair of parentheses can be removed, as that would result in an invalid fold expression (because
args == 0
is not a cast-expression). It seems that, generally speaking, we should not issue this warning if the equality comparison is the operand of a fold expression.