[all-commits] [llvm/llvm-project] 4d2946: [clang-tidy] Correctly add parentheses in `readabi...
flovent via All-commits
all-commits at lists.llvm.org
Sat Oct 11 23:18:23 PDT 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 4d29460b43e7826300b396a1ff30e5069f42c56c
https://github.com/llvm/llvm-project/commit/4d29460b43e7826300b396a1ff30e5069f42c56c
Author: flovent <flbven at protonmail.com>
Date: 2025-10-12 (Sun, 12 Oct 2025)
Changed paths:
M clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
M clang-tools-extra/docs/ReleaseNotes.rst
M clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion.cpp
Log Message:
-----------
[clang-tidy] Correctly add parentheses in `readability-implicit-bool-conversion` (#162215)
For `CompoundAssignOperator` in condition, there will be two layers of
`ImplicitCastExpr`, for code:
```
int val = -1;
while(val >>= 7) {
}
```
While statement's AST:
```
WhileStmt <line:4:5, line:5:5>
|-ImplicitCastExpr <line:4:11, col:18> 'bool' <IntegralToBoolean>
| `-ImplicitCastExpr <col:11, col:18> 'int' <LValueToRValue>
| `-CompoundAssignOperator <col:11, col:18> 'int' lvalue '>>=' ComputeLHSTy='int' ComputeResultTy='int'
| |-DeclRefExpr <col:11> 'int' lvalue Var 0x20290cb8 'val' 'int'
| `-IntegerLiteral <col:18> 'int' 7
`-CompoundStmt <col:21, line:5:5>
```
This is not taken into account by the check when determining whether
brackets need to be added.
Closes #161318.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list