Fixed #7701 (ValueFlow: handle 64-bit unsigned values )

This commit is contained in:
Daniel Marjamäki 2017-07-22 12:19:46 +02:00
parent 2e6a22e882
commit bf5040e3d6
3 changed files with 17 additions and 3 deletions

View File

@ -528,10 +528,17 @@ MathLib::bigint MathLib::toLongNumber(const std::string & str)
return characterLiteralToLongNumber(str.substr(1,str.size()-2));
}
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;
}

View File

@ -1355,6 +1355,9 @@ void Token::printValueFlow(bool xml, std::ostream &out) const
out << " <value ";
switch (it->valueType) {
case ValueFlow::Value::INT:
if (tok->valueType() && tok->valueType()->sign == ValueType::UNSIGNED)
out << "intvalue=\"" << (MathLib::biguint)it->intvalue << '\"';
else
out << "intvalue=\"" << it->intvalue << '\"';
break;
case ValueFlow::Value::TOK:
@ -1384,6 +1387,9 @@ void Token::printValueFlow(bool xml, std::ostream &out) const
out << ",";
switch (it->valueType) {
case ValueFlow::Value::INT:
if (tok->valueType() && tok->valueType()->sign == ValueType::UNSIGNED)
out << (MathLib::biguint)it->intvalue;
else
out << it->intvalue;
break;
case ValueFlow::Value::TOK:

View File

@ -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() {