ValueFlow: Try to clarify debug output for impossible values

This commit is contained in:
Daniel Marjamäki 2020-05-08 16:13:55 +02:00
parent 02d88cb191
commit ab8bf81f03
1 changed files with 21 additions and 1 deletions

View File

@ -1558,7 +1558,27 @@ void Token::printValueFlow(bool xml, std::ostream &out) const
out << "Line " << tok->linenr() << std::endl;
line = tok->linenr();
if (!xml) {
out << " " << tok->str() << (tok->mImpl->mValues->front().isKnown() ? " always " : " possible ");
ValueFlow::Value::ValueKind valueKind = tok->mImpl->mValues->front().valueKind;
bool same = true;
for (const ValueFlow::Value &value : *tok->mImpl->mValues) {
if (value.valueKind != valueKind) {
same = false;
break;
}
}
out << " " << tok->str() << " ";
if (same) {
switch (valueKind) {
case ValueFlow::Value::ValueKind::Impossible:
case ValueFlow::Value::ValueKind::Known:
out << "always ";
break;
case ValueFlow::Value::ValueKind::Inconclusive:
case ValueFlow::Value::ValueKind::Possible:
out << "possible ";
break;
};
}
if (tok->mImpl->mValues->size() > 1U)
out << '{';
}