Fixed #7701 (ValueFlow: handle 64-bit unsigned values )
This commit is contained in:
parent
2e6a22e882
commit
bf5040e3d6
|
@ -528,7 +528,14 @@ MathLib::bigint MathLib::toLongNumber(const std::string & str)
|
|||
return characterLiteralToLongNumber(str.substr(1,str.size()-2));
|
||||
}
|
||||
|
||||
bigint ret = 0;
|
||||
if (str[0] == '-') {
|
||||
bigint ret = 0;
|
||||
std::istringstream istr(str);
|
||||
istr >> ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
biguint ret = 0;
|
||||
std::istringstream istr(str);
|
||||
istr >> ret;
|
||||
return ret;
|
||||
|
|
|
@ -1355,7 +1355,10 @@ void Token::printValueFlow(bool xml, std::ostream &out) const
|
|||
out << " <value ";
|
||||
switch (it->valueType) {
|
||||
case ValueFlow::Value::INT:
|
||||
out << "intvalue=\"" << it->intvalue << '\"';
|
||||
if (tok->valueType() && tok->valueType()->sign == ValueType::UNSIGNED)
|
||||
out << "intvalue=\"" << (MathLib::biguint)it->intvalue << '\"';
|
||||
else
|
||||
out << "intvalue=\"" << it->intvalue << '\"';
|
||||
break;
|
||||
case ValueFlow::Value::TOK:
|
||||
out << "tokvalue=\"" << it->tokvalue << '\"';
|
||||
|
@ -1384,7 +1387,10 @@ void Token::printValueFlow(bool xml, std::ostream &out) const
|
|||
out << ",";
|
||||
switch (it->valueType) {
|
||||
case ValueFlow::Value::INT:
|
||||
out << it->intvalue;
|
||||
if (tok->valueType() && tok->valueType()->sign == ValueType::UNSIGNED)
|
||||
out << (MathLib::biguint)it->intvalue;
|
||||
else
|
||||
out << it->intvalue;
|
||||
break;
|
||||
case ValueFlow::Value::TOK:
|
||||
out << it->tokvalue->str();
|
||||
|
|
|
@ -242,6 +242,7 @@ private:
|
|||
ASSERT_EQUALS(0, valueOfTok("x(NULL);", "NULL").intvalue);
|
||||
ASSERT_EQUALS((int)('a'), valueOfTok("x='a';", "'a'").intvalue);
|
||||
ASSERT_EQUALS((int)('\n'), valueOfTok("x='\\n';", "'\\n'").intvalue);
|
||||
ASSERT_EQUALS(18446744069414584320, valueOfTok("x=0xFFFFFFFF00000000;","18446744069414584320U").intvalue); // #7701
|
||||
}
|
||||
|
||||
void valueFlowString() {
|
||||
|
|
Loading…
Reference in New Issue