mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-28 02:26:05 +00:00
[clang-tidy] readability-implicit-bool-conversion.AllowIntegerConditions
ignores DoStmt
s
Reviewed By: PiotrZSL Differential Revision: https://reviews.llvm.org/D157428
This commit is contained in:
parent
81ccfeb86a
commit
f263f45ba6
@ -228,7 +228,8 @@ bool isCastAllowedInCondition(const ImplicitCastExpr *Cast,
|
||||
if (!S)
|
||||
return false;
|
||||
if (isa<IfStmt>(S) || isa<ConditionalOperator>(S) || isa<ForStmt>(S) ||
|
||||
isa<WhileStmt>(S) || isa<BinaryConditionalOperator>(S))
|
||||
isa<WhileStmt>(S) || isa<DoStmt>(S) ||
|
||||
isa<BinaryConditionalOperator>(S))
|
||||
return true;
|
||||
if (isa<ParenExpr>(S) || isa<ImplicitCastExpr>(S) ||
|
||||
isUnaryLogicalNotOperator(S) ||
|
||||
|
@ -196,6 +196,11 @@ Changes in existing checks
|
||||
<clang-tidy/checks/readability/identifier-naming>` check to emit proper
|
||||
warnings when a type forward declaration precedes its definition.
|
||||
|
||||
- Improved :doc:`readability-implicit-bool-conversion
|
||||
<clang-tidy/checks/readability/implicit-bool-conversion>` check to take
|
||||
do-while loops into account for the `AllowIntegerConditions` and
|
||||
`AllowPointerConditions` options.
|
||||
|
||||
Removed checks
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
|
@ -38,6 +38,9 @@ void implicitConversionIntegerToBoolInConditionalsIsAllowed() {
|
||||
while (functionReturningInt()) {}
|
||||
while (functionReturningPointer()) {}
|
||||
while (functionReturningInt() && !functionReturningPointer() || (!functionReturningInt() && functionReturningPointer())) {}
|
||||
do {} while (functionReturningInt());
|
||||
do {} while (functionReturningPointer());
|
||||
do {} while (functionReturningInt() && !functionReturningPointer() || (!functionReturningInt() && functionReturningPointer()));
|
||||
int value1 = functionReturningInt() ? 1 : 2;
|
||||
int value2 = !functionReturningInt() ? 1 : 2;
|
||||
int value3 = (functionReturningInt() && functionReturningPointer() || !functionReturningInt()) ? 1 : 2;
|
||||
|
Loading…
x
Reference in New Issue
Block a user