ValueFlow: Don't calculate x<<64 and x>>64
This commit is contained in:
parent
dd69d5eabe
commit
ac7b351d1e
|
@ -432,7 +432,7 @@ static void setTokenValue(Token* tok, const ValueFlow::Value &value, const Setti
|
||||||
result.intvalue = value1->intvalue > value2->intvalue;
|
result.intvalue = value1->intvalue > value2->intvalue;
|
||||||
else if (parent->str() == ">=")
|
else if (parent->str() == ">=")
|
||||||
result.intvalue = value1->intvalue >= value2->intvalue;
|
result.intvalue = value1->intvalue >= value2->intvalue;
|
||||||
else if (parent->str() == ">>" && value1->intvalue >= 0 && value2->intvalue >= 0)
|
else if (parent->str() == ">>" && value1->intvalue >= 0 && value2->intvalue >= 0 && value2->intvalue < 64)
|
||||||
result.intvalue = value1->intvalue >> value2->intvalue;
|
result.intvalue = value1->intvalue >> value2->intvalue;
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
|
@ -445,7 +445,7 @@ static void setTokenValue(Token* tok, const ValueFlow::Value &value, const Setti
|
||||||
result.intvalue = value1->intvalue < value2->intvalue;
|
result.intvalue = value1->intvalue < value2->intvalue;
|
||||||
else if (parent->str() == "<=")
|
else if (parent->str() == "<=")
|
||||||
result.intvalue = value1->intvalue <= value2->intvalue;
|
result.intvalue = value1->intvalue <= value2->intvalue;
|
||||||
else if (parent->str() == "<<" && value1->intvalue >= 0 && value2->intvalue >= 0)
|
else if (parent->str() == "<<" && value1->intvalue >= 0 && value2->intvalue >= 0 && value2->intvalue < 64)
|
||||||
result.intvalue = value1->intvalue << value2->intvalue;
|
result.intvalue = value1->intvalue << value2->intvalue;
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -282,8 +282,10 @@ private:
|
||||||
// Don't calculate if there is UB
|
// Don't calculate if there is UB
|
||||||
ASSERT(tokenValues("-1<<10","<<").empty());
|
ASSERT(tokenValues("-1<<10","<<").empty());
|
||||||
ASSERT(tokenValues("10<<-1","<<").empty());
|
ASSERT(tokenValues("10<<-1","<<").empty());
|
||||||
|
ASSERT(tokenValues("10<<64","<<").empty());
|
||||||
ASSERT(tokenValues("-1>>10",">>").empty());
|
ASSERT(tokenValues("-1>>10",">>").empty());
|
||||||
ASSERT(tokenValues("10>>-1",">>").empty());
|
ASSERT(tokenValues("10>>-1",">>").empty());
|
||||||
|
ASSERT(tokenValues("10>>64",">>").empty());
|
||||||
|
|
||||||
// calculation using 1,2 variables/values
|
// calculation using 1,2 variables/values
|
||||||
code = "void f(int x) {\n"
|
code = "void f(int x) {\n"
|
||||||
|
|
Loading…
Reference in New Issue