Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ static void fixGenericExprCastToBool(DiagnosticBuilder &Diag,

const Expr *SubExpr = Cast->getSubExpr();

bool NeedInnerParens = utils::fixit::areParensNeededForStatement(*SubExpr);
bool NeedInnerParens =
utils::fixit::areParensNeededForStatement(*SubExpr->IgnoreImpCasts());
bool NeedOuterParens =
Parent != nullptr && utils::fixit::areParensNeededForStatement(*Parent);

Expand Down
5 changes: 5 additions & 0 deletions clang-tools-extra/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,11 @@ Changes in existing checks
declarations and macros in system headers. The documentation is also improved
to differentiate the general options from the specific ones.

- Improved :doc:`readability-implicit-bool-conversion
<clang-tidy/checks/readability/implicit-bool-conversion>` check by correctly
adding parentheses when the inner expression are implicitly converted
multiple times.

- Improved :doc:`readability-qualified-auto
<clang-tidy/checks/readability/qualified-auto>` check by adding the option
`IgnoreAliasing`, that allows not looking at underlying types of type aliases.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -547,3 +547,13 @@ namespace PR71848 {
// CHECK-FIXES: return static_cast<int>( foo );
}
}

namespace PR161318 {
int AddParenOutsideOfCompoundAssignOp() {
int val = -1;
while(val >>= 7) {
// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: implicit conversion 'int' -> 'bool' [readability-implicit-bool-conversion]
// CHECK-FIXES: while((val >>= 7) != 0) {
}
}
}