File tree Expand file tree Collapse file tree 3 files changed +17
-1
lines changed
Expand file tree Collapse file tree 3 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -89,7 +89,8 @@ static void fixGenericExprCastToBool(DiagnosticBuilder &Diag,
8989
9090 const Expr *SubExpr = Cast->getSubExpr ();
9191
92- bool NeedInnerParens = utils::fixit::areParensNeededForStatement (*SubExpr);
92+ bool NeedInnerParens =
93+ utils::fixit::areParensNeededForStatement (*SubExpr->IgnoreImpCasts ());
9394 bool NeedOuterParens =
9495 Parent != nullptr && utils::fixit::areParensNeededForStatement (*Parent);
9596
Original file line number Diff line number Diff line change @@ -381,6 +381,11 @@ Changes in existing checks
381381 declarations and macros in system headers. The documentation is also improved
382382 to differentiate the general options from the specific ones.
383383
384+ - Improved :doc: `readability-implicit-bool-conversion
385+ <clang-tidy/checks/readability/implicit-bool-conversion>` check by correctly
386+ adding parentheses when the inner expression are implicitly converted
387+ multiple times.
388+
384389- Improved :doc: `readability-qualified-auto
385390 <clang-tidy/checks/readability/qualified-auto>` check by adding the option
386391 `IgnoreAliasing `, that allows not looking at underlying types of type aliases.
Original file line number Diff line number Diff line change @@ -547,3 +547,13 @@ namespace PR71848 {
547547// CHECK-FIXES: return static_cast<int>( foo );
548548 }
549549}
550+
551+ namespace PR161318 {
552+ int AddParenOutsideOfCompoundAssignOp () {
553+ int val = -1 ;
554+ while (val >>= 7 ) {
555+ // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: implicit conversion 'int' -> 'bool' [readability-implicit-bool-conversion]
556+ // CHECK-FIXES: while((val >>= 7) != 0) {
557+ }
558+ }
559+ }
You can’t perform that action at this time.
0 commit comments