ValueFlow: Clarify note when impossible value is assigned (#10297)
This commit is contained in:
parent
79f59d8f39
commit
769b20b426
|
@ -1637,9 +1637,9 @@ struct OnException {
|
||||||
void TokenList::validateAst() const
|
void TokenList::validateAst() const
|
||||||
{
|
{
|
||||||
OnException oe{[&] {
|
OnException oe{[&] {
|
||||||
if (mSettings->debugnormal)
|
if (mSettings->debugnormal)
|
||||||
mTokensFrontBack.front->printOut();
|
mTokensFrontBack.front->printOut();
|
||||||
}};
|
}};
|
||||||
// Check for some known issues in AST to avoid crash/hang later on
|
// Check for some known issues in AST to avoid crash/hang later on
|
||||||
std::set < const Token* > safeAstTokens; // list of "safe" AST tokens without endless recursion
|
std::set < const Token* > safeAstTokens; // list of "safe" AST tokens without endless recursion
|
||||||
for (const Token *tok = mTokensFrontBack.front; tok; tok = tok->next()) {
|
for (const Token *tok = mTokensFrontBack.front; tok; tok = tok->next()) {
|
||||||
|
|
|
@ -4086,7 +4086,16 @@ static void valueFlowForwardAssign(Token* const tok,
|
||||||
values.remove_if(std::mem_fn(&ValueFlow::Value::isTokValue));
|
values.remove_if(std::mem_fn(&ValueFlow::Value::isTokValue));
|
||||||
if (tok->astParent()) {
|
if (tok->astParent()) {
|
||||||
for (ValueFlow::Value& value : values) {
|
for (ValueFlow::Value& value : values) {
|
||||||
const std::string info = "Assignment '" + tok->astParent()->expressionString() + "', assigned value is " + value.infoString();
|
std::string valueKind;
|
||||||
|
if (value.valueKind == ValueFlow::Value::ValueKind::Impossible) {
|
||||||
|
if (value.bound == ValueFlow::Value::Bound::Point)
|
||||||
|
valueKind = "never ";
|
||||||
|
else if (value.bound == ValueFlow::Value::Bound::Lower)
|
||||||
|
valueKind = "less than ";
|
||||||
|
else if (value.bound == ValueFlow::Value::Bound::Upper)
|
||||||
|
valueKind = "greater than ";
|
||||||
|
}
|
||||||
|
const std::string info = "Assignment '" + tok->astParent()->expressionString() + "', assigned value is " + valueKind + value.infoString();
|
||||||
value.errorPath.emplace_back(tok, info);
|
value.errorPath.emplace_back(tok, info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue