parent
cb03b9883f
commit
df9df70ba7
|
@ -150,9 +150,9 @@ static bool isInLoopCondition(const Token * tok)
|
||||||
/// If tok2 comes after tok1
|
/// If tok2 comes after tok1
|
||||||
static bool precedes(const Token * tok1, const Token * tok2)
|
static bool precedes(const Token * tok1, const Token * tok2)
|
||||||
{
|
{
|
||||||
if(!tok1)
|
if (!tok1)
|
||||||
return false;
|
return false;
|
||||||
if(!tok2)
|
if (!tok2)
|
||||||
return false;
|
return false;
|
||||||
return tok1->progressValue() < tok2->progressValue();
|
return tok1->progressValue() < tok2->progressValue();
|
||||||
}
|
}
|
||||||
|
@ -165,7 +165,7 @@ static const Token * followVariableExpression(const Token * tok, bool cpp, const
|
||||||
if (!tok)
|
if (!tok)
|
||||||
return tok;
|
return tok;
|
||||||
// Skip following variables that is across multiple files
|
// Skip following variables that is across multiple files
|
||||||
if(end && end->fileIndex() != tok->fileIndex())
|
if (end && end->fileIndex() != tok->fileIndex())
|
||||||
return tok;
|
return tok;
|
||||||
// Skip array access
|
// Skip array access
|
||||||
if (Token::Match(tok, "%var% ["))
|
if (Token::Match(tok, "%var% ["))
|
||||||
|
@ -216,7 +216,7 @@ static const Token * followVariableExpression(const Token * tok, bool cpp, const
|
||||||
}
|
}
|
||||||
|
|
||||||
if (const Variable * var2 = tok2->variable()) {
|
if (const Variable * var2 = tok2->variable()) {
|
||||||
if(!var2->scope())
|
if (!var2->scope())
|
||||||
return tok;
|
return tok;
|
||||||
const Token * endToken2 = var2->scope() != tok->scope() ? var2->scope()->bodyEnd : endToken;
|
const Token * endToken2 = var2->scope() != tok->scope() ? var2->scope()->bodyEnd : endToken;
|
||||||
if (!var2->isLocal() && !var2->isConst() && !var2->isArgument())
|
if (!var2->isLocal() && !var2->isConst() && !var2->isArgument())
|
||||||
|
@ -225,8 +225,8 @@ static const Token * followVariableExpression(const Token * tok, bool cpp, const
|
||||||
return tok;
|
return tok;
|
||||||
if (!var2->isConst() && isVariableChanged(tok2, endToken2, tok2->varId(), false, nullptr, cpp))
|
if (!var2->isConst() && isVariableChanged(tok2, endToken2, tok2->varId(), false, nullptr, cpp))
|
||||||
return tok;
|
return tok;
|
||||||
// Recognized as a variable but the declaration is unknown
|
// Recognized as a variable but the declaration is unknown
|
||||||
} else if(tok2->varId() > 0) {
|
} else if (tok2->varId() > 0) {
|
||||||
return tok;
|
return tok;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -427,10 +427,10 @@ void CheckCondition::multiCondition()
|
||||||
break;
|
break;
|
||||||
tok2 = tok2->tokAt(4);
|
tok2 = tok2->tokAt(4);
|
||||||
|
|
||||||
if (cond1 &&
|
if (cond1 &&
|
||||||
tok2->astOperand2() &&
|
tok2->astOperand2() &&
|
||||||
!cond1->hasKnownValue() &&
|
!cond1->hasKnownValue() &&
|
||||||
!tok2->astOperand2()->hasKnownValue() &&
|
!tok2->astOperand2()->hasKnownValue() &&
|
||||||
isOverlappingCond(cond1, tok2->astOperand2(), true))
|
isOverlappingCond(cond1, tok2->astOperand2(), true))
|
||||||
multiConditionError(tok2, cond1->linenr());
|
multiConditionError(tok2, cond1->linenr());
|
||||||
}
|
}
|
||||||
|
@ -583,7 +583,7 @@ void CheckCondition::multiCondition2()
|
||||||
tokens1.push(firstCondition->astOperand1());
|
tokens1.push(firstCondition->astOperand1());
|
||||||
tokens1.push(firstCondition->astOperand2());
|
tokens1.push(firstCondition->astOperand2());
|
||||||
} else if (!firstCondition->hasKnownValue()) {
|
} else if (!firstCondition->hasKnownValue()) {
|
||||||
if(isOppositeCond(false, mTokenizer->isCPP(), firstCondition, cond2, mSettings->library, true, &errorPath)) {
|
if (isOppositeCond(false, mTokenizer->isCPP(), firstCondition, cond2, mSettings->library, true, &errorPath)) {
|
||||||
if (!isAliased(vars))
|
if (!isAliased(vars))
|
||||||
oppositeInnerConditionError(firstCondition, cond2, errorPath);
|
oppositeInnerConditionError(firstCondition, cond2, errorPath);
|
||||||
} else if (isSameExpression(mTokenizer->isCPP(), true, firstCondition, cond2, mSettings->library, true, &errorPath)) {
|
} else if (isSameExpression(mTokenizer->isCPP(), true, firstCondition, cond2, mSettings->library, true, &errorPath)) {
|
||||||
|
@ -602,8 +602,8 @@ void CheckCondition::multiCondition2()
|
||||||
if (secondCondition->str() == "||" || secondCondition->str() == "&&") {
|
if (secondCondition->str() == "||" || secondCondition->str() == "&&") {
|
||||||
tokens2.push(secondCondition->astOperand1());
|
tokens2.push(secondCondition->astOperand1());
|
||||||
tokens2.push(secondCondition->astOperand2());
|
tokens2.push(secondCondition->astOperand2());
|
||||||
} else if ((!cond1->hasKnownValue() || !secondCondition->hasKnownValue()) &&
|
} else if ((!cond1->hasKnownValue() || !secondCondition->hasKnownValue()) &&
|
||||||
isSameExpression(mTokenizer->isCPP(), true, cond1, secondCondition, mSettings->library, true, &errorPath)) {
|
isSameExpression(mTokenizer->isCPP(), true, cond1, secondCondition, mSettings->library, true, &errorPath)) {
|
||||||
if (!isAliased(vars))
|
if (!isAliased(vars))
|
||||||
identicalConditionAfterEarlyExitError(cond1, secondCondition, errorPath);
|
identicalConditionAfterEarlyExitError(cond1, secondCondition, errorPath);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue