This revision was automatically updated to reflect the committed changes. Closed by commit rL333003: [clang-tidy] SimplifyBoolenExpr doesn't add parens if unary negotiation is of… (authored by zinovy.nis, committed by ). Herald added subscribers: llvm-commits, klimek.
Changed prior to commit: https://reviews.llvm.org/D47122?vs=147836&id=148046#toc Repository: rL LLVM https://reviews.llvm.org/D47122 Files: clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp clang-tools-extra/trunk/test/clang-tidy/readability-simplify-bool-expr.cpp Index: clang-tools-extra/trunk/test/clang-tidy/readability-simplify-bool-expr.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-tidy/readability-simplify-bool-expr.cpp +++ clang-tools-extra/trunk/test/clang-tidy/readability-simplify-bool-expr.cpp @@ -938,3 +938,13 @@ } // CHECK-MESSAGES: :[[@LINE-5]]:12: warning: {{.*}} in conditional return // CHECK-FIXES: return p->m != 0;{{$}} + +bool operator!=(const A&, const A&) { return false; } +bool expr_with_cleanups(A &S) { + if (S != (A)S) + return false; + + return true; +} +// CHECK-MESSAGES: :[[@LINE-4]]:12: warning: {{.*}} in conditional return +// CHECK-FIXES: S == (A)S;{{$}} Index: clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp =================================================================== --- clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp +++ clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp @@ -195,6 +195,9 @@ 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)) {
Index: clang-tools-extra/trunk/test/clang-tidy/readability-simplify-bool-expr.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-tidy/readability-simplify-bool-expr.cpp +++ clang-tools-extra/trunk/test/clang-tidy/readability-simplify-bool-expr.cpp @@ -938,3 +938,13 @@ } // CHECK-MESSAGES: :[[@LINE-5]]:12: warning: {{.*}} in conditional return // CHECK-FIXES: return p->m != 0;{{$}} + +bool operator!=(const A&, const A&) { return false; } +bool expr_with_cleanups(A &S) { + if (S != (A)S) + return false; + + return true; +} +// CHECK-MESSAGES: :[[@LINE-4]]:12: warning: {{.*}} in conditional return +// CHECK-FIXES: S == (A)S;{{$}} Index: clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp =================================================================== --- clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp +++ clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp @@ -195,6 +195,9 @@ 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)) {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits