Kaydet (Commit) 14184060 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Don't warn about multiplication by zero in loplugin:expressionalwayszero

That specific warning (added with 862dc17e
"loplugin:expressionalwayszero improvements", together with other improvements)
already looked somewhat unhelpful to me in
4cb78942 "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
üst 0ada546b
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment