Fixed testrunner
This commit is contained in:
parent
a0770f05e1
commit
f34ff9325a
|
@ -440,6 +440,7 @@ bool extractForLoopValues(const Token *forToken,
|
|||
nonneg int * const varid,
|
||||
bool * const knownInitValue,
|
||||
MathLib::bigint * const initValue,
|
||||
bool * const partialCond,
|
||||
MathLib::bigint * const stepValue,
|
||||
MathLib::bigint * const lastValue)
|
||||
{
|
||||
|
@ -453,6 +454,16 @@ bool extractForLoopValues(const Token *forToken,
|
|||
*varid = initExpr->astOperand1()->varId();
|
||||
*knownInitValue = initExpr->astOperand2()->hasKnownIntValue();
|
||||
*initValue = (*knownInitValue) ? initExpr->astOperand2()->getKnownIntValue() : 0;
|
||||
*partialCond = Token::Match(condExpr, "%oror%|&&");
|
||||
visitAstNodes(condExpr, [varid, &condExpr](const Token *tok) {
|
||||
if (Token::Match(tok, "%oror%|&&"))
|
||||
return ChildrenToVisit::op1_and_op2;
|
||||
if (Token::Match(tok, "<|<=") && tok->isBinaryOp() && tok->astOperand1()->varId() == *varid && tok->astOperand2()->hasKnownIntValue()) {
|
||||
if (Token::Match(condExpr, "%oror%|&&") || tok->astOperand2()->getKnownIntValue() < condExpr->astOperand2()->getKnownIntValue())
|
||||
condExpr = tok;
|
||||
}
|
||||
return ChildrenToVisit::none;
|
||||
});
|
||||
if (!Token::Match(condExpr, "<|<=") || !condExpr->isBinaryOp() || condExpr->astOperand1()->varId() != *varid || !condExpr->astOperand2()->hasKnownIntValue())
|
||||
return false;
|
||||
if (!incExpr || !incExpr->isUnaryOp("++") || incExpr->astOperand1()->varId() != *varid)
|
||||
|
|
|
@ -115,6 +115,7 @@ bool extractForLoopValues(const Token *forToken,
|
|||
nonneg int * const varid,
|
||||
bool * const knownInitValue,
|
||||
long long * const initValue,
|
||||
bool * const partialCond,
|
||||
long long * const stepValue,
|
||||
long long * const lastValue);
|
||||
|
||||
|
|
|
@ -2371,9 +2371,9 @@ static std::string execute(const Token *start, const Token *end, Data &data)
|
|||
|
||||
if (Token::simpleMatch(tok, "for (")) {
|
||||
nonneg int varid;
|
||||
bool hasKnownInitValue;
|
||||
bool hasKnownInitValue, partialCond;
|
||||
MathLib::bigint initValue, stepValue, lastValue;
|
||||
if (extractForLoopValues(tok, &varid, &hasKnownInitValue, &initValue, &stepValue, &lastValue) && hasKnownInitValue) {
|
||||
if (extractForLoopValues(tok, &varid, &hasKnownInitValue, &initValue, &partialCond, &stepValue, &lastValue) && hasKnownInitValue && !partialCond) {
|
||||
auto loopValues = std::make_shared<ExprEngine::IntRange>(data.getNewSymbolName(), initValue, lastValue);
|
||||
data.assignValue(tok, varid, loopValues);
|
||||
tok = tok->linkAt(1);
|
||||
|
|
|
@ -4626,10 +4626,10 @@ static void valueFlowForLoop(TokenList *tokenlist, SymbolDatabase* symboldatabas
|
|||
continue;
|
||||
|
||||
nonneg int varid;
|
||||
bool knownInitValue;
|
||||
bool knownInitValue, partialCond;
|
||||
MathLib::bigint initValue, stepValue, lastValue;
|
||||
|
||||
if (extractForLoopValues(tok, &varid, &knownInitValue, &initValue, &stepValue, &lastValue)) {
|
||||
if (extractForLoopValues(tok, &varid, &knownInitValue, &initValue, &partialCond, &stepValue, &lastValue)) {
|
||||
const bool executeBody = !knownInitValue || initValue <= lastValue;
|
||||
if (executeBody) {
|
||||
valueFlowForLoopSimplify(bodyStart, varid, false, initValue, tokenlist, errorLogger, settings);
|
||||
|
|
Loading…
Reference in New Issue