diff options
author | Zinovy Nis <zinovy.nis@gmail.com> | 2018-05-22 17:24:28 +0000 |
---|---|---|
committer | Zinovy Nis <zinovy.nis@gmail.com> | 2018-05-22 17:24:28 +0000 |
commit | 7145b91d2293a3f5385e40745087ac953e8c8a7f (patch) | |
tree | db4cdef5208132241f9fae5dbab6cd753be7f4ee /clang-tidy/readability | |
parent | 7b0ac917e1f49f967a92f845170076c11c9fcf8c (diff) |
[clang-tidy] SimplifyBoolenExpr doesn't add parens if unary negotiation is of ExprWithCleanups type
bool foo(A &S) {
if (S != (A)S)
return false;
return true;
}
is fixed into (w/o this patch)
...
return !S != (A)S; // negotiation affects first operand only
}
instead of (with this patch)
...
return S == (A)S; // note == instead of !=
}
Differential Revision: https://reviews.llvm.org/D47122
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@333003 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'clang-tidy/readability')
-rw-r--r-- | clang-tidy/readability/SimplifyBooleanExprCheck.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/clang-tidy/readability/SimplifyBooleanExprCheck.cpp b/clang-tidy/readability/SimplifyBooleanExprCheck.cpp index 559b085b..ba8e5b42 100644 --- a/clang-tidy/readability/SimplifyBooleanExprCheck.cpp +++ b/clang-tidy/readability/SimplifyBooleanExprCheck.cpp @@ -195,6 +195,9 @@ std::string compareExpressionToZero(const MatchFinder::MatchResult &Result, std::string replacementExpression(const MatchFinder::MatchResult &Result, bool Negated, const Expr *E) { E = E->ignoreParenBaseCasts(); + if (const auto *EC = dyn_cast<ExprWithCleanups>(E)) + E = EC->getSubExpr(); + const bool NeedsStaticCast = needsStaticCast(E); if (Negated) { if (const auto *UnOp = dyn_cast<UnaryOperator>(E)) { |