Bug hunting; Fix TestBughuntingChecks
This commit is contained in:
parent
592637af61
commit
f2bd603bd3
|
@ -180,13 +180,19 @@ static bool isVariableAssigned(const Variable *var, const Token *tok, const Toke
|
||||||
}
|
}
|
||||||
if (scopeStart && Token::Match(prev, "return|throw|continue|break"))
|
if (scopeStart && Token::Match(prev, "return|throw|continue|break"))
|
||||||
return true;
|
return true;
|
||||||
if (Token::Match(prev, "%varid% =", var->declarationId()))
|
if (Token::Match(prev, "%varid% =", var->declarationId())) {
|
||||||
return true;
|
bool usedInRhs = false;
|
||||||
|
visitAstNodes(prev->next()->astOperand2(), [&usedInRhs, var](const Token *tok) {
|
||||||
// bailout; if variable is used previously that is checked first
|
if (tok->varId() == var->declarationId()) {
|
||||||
if (!scopeStart && prev->varId() == var->declarationId())
|
usedInRhs = true;
|
||||||
|
return ChildrenToVisit::done;
|
||||||
|
}
|
||||||
|
return ChildrenToVisit::op1_and_op2;
|
||||||
|
});
|
||||||
|
if (!usedInRhs)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue