From 14184060bd2249a492ea44d36463914c421e6ce5 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Mon, 23 Apr 2018 09:24:53 +0200 Subject: Don't warn about multiplication by zero in loplugin:expressionalwayszero That specific warning (added with 862dc17e437f0972223e18555110dc875d2ffa44 "loplugin:expressionalwayszero improvements", together with other improvements) already looked somewhat unhelpful to me in 4cb78942f25e9ea2e9a8445825438cd67b1c00f9 "loplugin:expressionalwayszero (clang-cl)", but now started to generate > [CXX] vcl/source/bitmap/BitmapSobelGreyFilter.cxx > /data/sbergman/lo-clang2/core/vcl/source/bitmap/BitmapSobelGreyFilter.cxx:92:34: error: expression always evaluates to zero, lhs=0 rhs=unknown [loplugin:expressionalwayszero] > nSum1 += nMask121 * nGrey12; > ^~~~~~~~~~~~~~~~~~ > /data/sbergman/lo-clang2/core/vcl/source/bitmap/BitmapSobelGreyFilter.cxx:99:34: error: expression always evaluates to zero, lhs=0 rhs=unknown [loplugin:expressionalwayszero] > nSum2 += nMask212 * nGrey21; > ^~~~~~~~~~~~~~~~~~ > /data/sbergman/lo-clang2/core/vcl/source/bitmap/BitmapSobelGreyFilter.cxx:101:34: error: expression always evaluates to zero, lhs=0 rhs=unknown [loplugin:expressionalwayszero] > nSum1 += nMask221 * nGrey22; > ^~~~~~~~~~~~~~~~~~ > /data/sbergman/lo-clang2/core/vcl/source/bitmap/BitmapSobelGreyFilter.cxx:102:34: error: expression always evaluates to zero, lhs=0 rhs=unknown [loplugin:expressionalwayszero] > nSum2 += nMask222 * nGrey22; > ^~~~~~~~~~~~~~~~~~ > /data/sbergman/lo-clang2/core/vcl/source/bitmap/BitmapSobelGreyFilter.cxx:105:34: error: expression always evaluates to zero, lhs=0 rhs=unknown [loplugin:expressionalwayszero] > nSum2 += nMask232 * nGrey23; > ^~~~~~~~~~~~~~~~~~ > /data/sbergman/lo-clang2/core/vcl/source/bitmap/BitmapSobelGreyFilter.cxx:110:34: error: expression always evaluates to zero, lhs=0 rhs=unknown [loplugin:expressionalwayszero] > nSum1 += nMask321 * nGrey32; > ^~~~~~~~~~~~~~~~~~ > 6 errors generated. (where all those nMask* are zero constants; and which even passed Gerrit/Jenkins as loplugin:expressionalwayszero is only active for Clang >= 3.9). Lets just remove that specific check again. Change-Id: Ia8710f83b16d6e6949439d3941e17b8a0959aa8b --- compilerplugins/clang/expressionalwayszero.cxx | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) (limited to 'compilerplugins') diff --git a/compilerplugins/clang/expressionalwayszero.cxx b/compilerplugins/clang/expressionalwayszero.cxx index 66e7c699a67a..6633f138cfb3 100644 --- a/compilerplugins/clang/expressionalwayszero.cxx +++ b/compilerplugins/clang/expressionalwayszero.cxx @@ -75,13 +75,8 @@ bool ExpressionAlwaysZero::VisitBinaryOperator( BinaryOperator const * binaryOpe if (binaryOperator->getLocStart().isMacroID()) return true; - bool bAndOperator = false; auto op = binaryOperator->getOpcode(); - if (op == BO_And || op == BO_AndAssign || op == BO_LAnd) - bAndOperator = true; - else if (op == BO_Mul || op == BO_MulAssign) - ; // ok - else + if (!(op == BO_And || op == BO_AndAssign || op == BO_LAnd)) return true; auto lhsValue = getExprValue(binaryOperator->getLHS()); @@ -90,9 +85,7 @@ bool ExpressionAlwaysZero::VisitBinaryOperator( BinaryOperator const * binaryOpe ; // ok else if (rhsValue && rhsValue->getExtValue() == 0) ; // ok - else if (bAndOperator && lhsValue && rhsValue && (lhsValue->getExtValue() & rhsValue->getExtValue()) == 0) - ; // ok - else if (!bAndOperator && lhsValue && rhsValue && (lhsValue->getExtValue() * rhsValue->getExtValue()) == 0) + else if (lhsValue && rhsValue && (lhsValue->getExtValue() & rhsValue->getExtValue()) == 0) ; // ok else return true; @@ -112,13 +105,8 @@ bool ExpressionAlwaysZero::VisitCXXOperatorCallExpr( CXXOperatorCallExpr const * if (cxxOperatorCallExpr->getLocStart().isMacroID()) return true; - bool bAndOperator = false; auto op = cxxOperatorCallExpr->getOperator(); - if ( op == OO_Amp || op == OO_AmpEqual || op == OO_AmpAmp) - bAndOperator = true; - else if (op == OO_Star || op == OO_StarEqual) - ; // ok - else + if ( !(op == OO_Amp || op == OO_AmpEqual || op == OO_AmpAmp)) return true; if (cxxOperatorCallExpr->getNumArgs() != 2) @@ -129,9 +117,7 @@ bool ExpressionAlwaysZero::VisitCXXOperatorCallExpr( CXXOperatorCallExpr const * ; // ok else if (rhsValue && rhsValue->getExtValue() == 0) ; // ok - else if (bAndOperator && lhsValue && rhsValue && (lhsValue->getExtValue() & rhsValue->getExtValue()) == 0) - ; // ok - else if (!bAndOperator && lhsValue && rhsValue && (lhsValue->getExtValue() * rhsValue->getExtValue()) == 0) + else if (lhsValue && rhsValue && (lhsValue->getExtValue() & rhsValue->getExtValue()) == 0) ; // ok else return true; -- cgit v1.2.3