valueFlowRightShift: Do not perform analysis when rhs is negative

This commit is contained in:
Daniel Marjamäki 2018-11-04 17:13:23 +01:00
parent 1d5e797e6d
commit dd9a1e890b
1 changed files with 5 additions and 1 deletions

View File

@ -1156,6 +1156,10 @@ static void valueFlowRightShift(TokenList *tokenList)
if (!tok->astOperand2()->hasKnownValue())
continue;
const MathLib::bigint rhsvalue = tok->astOperand2()->values().front().intvalue;
if (rhsvalue < 0)
continue;
if (!tok->astOperand1()->valueType() || !tok->astOperand1()->valueType()->isIntegral())
continue;
@ -1167,7 +1171,7 @@ static void valueFlowRightShift(TokenList *tokenList)
continue;
if (lhsmax < 0)
continue;
if ((1 << tok->astOperand2()->values().front().intvalue) <= lhsmax)
if ((1 << rhsvalue) <= lhsmax)
continue;
ValueFlow::Value val(0);