diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-04-19 09:07:27 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-05-30 10:49:51 +0200 |
commit | d6c32cffb5cc81989b4bb4a221a152bbe607bd98 (patch) | |
tree | 2c4ef9ec2a201ffcfea145ed5a0b901f2b6853ea /compilerplugins | |
parent | 9ab64dc48a6a61edce6ff3724093162ca1cf8331 (diff) |
loplugin:simplifybool extend to expression like !(a < b || c > d)
mostly to catch stuff from the flatten work, but I think this looks good
in general
Change-Id: I7be5b7bcf1f3d9f980c748ba20793965cef957e7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92493
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'compilerplugins')
-rw-r--r-- | compilerplugins/clang/simplifybool.cxx | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/compilerplugins/clang/simplifybool.cxx b/compilerplugins/clang/simplifybool.cxx index 6541cf01ba8b..4e48de99cb5c 100644 --- a/compilerplugins/clang/simplifybool.cxx +++ b/compilerplugins/clang/simplifybool.cxx @@ -288,21 +288,21 @@ bool SimplifyBool::VisitUnaryLNot(UnaryOperator const * expr) { } else if (binaryOp->isLogicalOp()) { - auto containsNegation = [](Expr const * expr) { + auto containsNegationOrComparison = [](Expr const * expr) { expr = ignoreParenImpCastAndComma(expr); if (auto unaryOp = dyn_cast<UnaryOperator>(expr)) if (unaryOp->getOpcode() == UO_LNot) return expr; if (auto binaryOp = dyn_cast<BinaryOperator>(expr)) - if (binaryOp->getOpcode() == BO_NE) + if (binaryOp->isComparisonOp()) return expr; if (auto cxxOpCall = dyn_cast<CXXOperatorCallExpr>(expr)) if (cxxOpCall->getOperator() == OO_ExclaimEqual) return expr; return (Expr const*)nullptr; }; - auto lhs = containsNegation(binaryOp->getLHS()); - auto rhs = containsNegation(binaryOp->getRHS()); + auto lhs = containsNegationOrComparison(binaryOp->getLHS()); + auto rhs = containsNegationOrComparison(binaryOp->getRHS()); if (!lhs || !rhs) return true; if (lhs || rhs) |