Skip to content

Commit ab8bf81

Browse files
committed
ValueFlow: Try to clarify debug output for impossible values
1 parent 02d88cb commit ab8bf81

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

lib/token.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1558,7 +1558,27 @@ void Token::printValueFlow(bool xml, std::ostream &out) const
15581558
out << "Line " << tok->linenr() << std::endl;
15591559
line = tok->linenr();
15601560
if (!xml) {
1561-
out << " " << tok->str() << (tok->mImpl->mValues->front().isKnown() ? " always " : " possible ");
1561+
ValueFlow::Value::ValueKind valueKind = tok->mImpl->mValues->front().valueKind;
1562+
bool same = true;
1563+
for (const ValueFlow::Value &value : *tok->mImpl->mValues) {
1564+
if (value.valueKind != valueKind) {
1565+
same = false;
1566+
break;
1567+
}
1568+
}
1569+
out << " " << tok->str() << " ";
1570+
if (same) {
1571+
switch (valueKind) {
1572+
case ValueFlow::Value::ValueKind::Impossible:
1573+
case ValueFlow::Value::ValueKind::Known:
1574+
out << "always ";
1575+
break;
1576+
case ValueFlow::Value::ValueKind::Inconclusive:
1577+
case ValueFlow::Value::ValueKind::Possible:
1578+
out << "possible ";
1579+
break;
1580+
};
1581+
}
15621582
if (tok->mImpl->mValues->size() > 1U)
15631583
out << '{';
15641584
}

0 commit comments

Comments
 (0)