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

View File

@ -1355,7 +1355,10 @@ void Token::printValueFlow(bool xml, std::ostream &out) const
out << " <value "; out << " <value ";
switch (it->valueType) { switch (it->valueType) {
case ValueFlow::Value::INT: 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; break;
case ValueFlow::Value::TOK: case ValueFlow::Value::TOK:
out << "tokvalue=\"" << it->tokvalue << '\"'; out << "tokvalue=\"" << it->tokvalue << '\"';
@ -1384,7 +1387,10 @@ void Token::printValueFlow(bool xml, std::ostream &out) const
out << ","; out << ",";
switch (it->valueType) { switch (it->valueType) {
case ValueFlow::Value::INT: 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; break;
case ValueFlow::Value::TOK: case ValueFlow::Value::TOK:
out << it->tokvalue->str(); out << it->tokvalue->str();

View File

@ -242,6 +242,7 @@ private:
ASSERT_EQUALS(0, valueOfTok("x(NULL);", "NULL").intvalue); ASSERT_EQUALS(0, valueOfTok("x(NULL);", "NULL").intvalue);
ASSERT_EQUALS((int)('a'), valueOfTok("x='a';", "'a'").intvalue); ASSERT_EQUALS((int)('a'), valueOfTok("x='a';", "'a'").intvalue);
ASSERT_EQUALS((int)('\n'), valueOfTok("x='\\n';", "'\\n'").intvalue); ASSERT_EQUALS((int)('\n'), valueOfTok("x='\\n';", "'\\n'").intvalue);
ASSERT_EQUALS(18446744069414584320, valueOfTok("x=0xFFFFFFFF00000000;","18446744069414584320U").intvalue); // #7701
} }
void valueFlowString() { void valueFlowString() {