Commit a34d037
[clang-tidy] Correctly add parentheses in
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 llvm#161318.readability-implicit-bool-conversion (llvm#162215)1 parent 1e28b92 commit a34d037
File tree
3 files changed
+17
-1
lines changed- clang-tools-extra
- clang-tidy/readability
- docs
- test/clang-tidy/checkers/readability
3 files changed
+17
-1
lines changedLines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | | - | |
| 92 | + | |
| 93 | + | |
93 | 94 | | |
94 | 95 | | |
95 | 96 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
402 | 402 | | |
403 | 403 | | |
404 | 404 | | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
405 | 410 | | |
406 | 411 | | |
407 | 412 | | |
| |||
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
547 | 547 | | |
548 | 548 | | |
549 | 549 | | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
0 commit comments