AST: Fixed 'same expression' false positives (git merge --squash s, <<, >>)
This commit is contained in:
parent
1798fc3645
commit
e8eeb90adb
|
@ -3378,12 +3378,12 @@ void CheckOther::checkDuplicateExpression()
|
||||||
|
|
||||||
// Experimental implementation
|
// Experimental implementation
|
||||||
for (const Token *tok = scope->classStart; tok && tok != scope->classEnd; tok = tok->next()) {
|
for (const Token *tok = scope->classStart; tok && tok != scope->classEnd; tok = tok->next()) {
|
||||||
if (tok->isOp() && tok->astOperand1() && !Token::Match(tok, "[+-*/%=]")) {
|
if (tok->isOp() && tok->astOperand1() && !Token::Match(tok, "+|-|*|/|%|=|<<|>>")) {
|
||||||
if (Token::Match(tok, "==|!=|-") && astIsFloat(tok->astOperand1()))
|
if (Token::Match(tok, "==|!=|-") && astIsFloat(tok->astOperand1()))
|
||||||
continue;
|
continue;
|
||||||
if (isSameExpression(tok->astOperand1(), tok->astOperand2(), constStandardFunctions))
|
if (isSameExpression(tok->astOperand1(), tok->astOperand2(), constStandardFunctions))
|
||||||
duplicateExpressionError(tok, tok, tok->str());
|
duplicateExpressionError(tok, tok, tok->str());
|
||||||
else if (tok->astOperand1() && tok->str() == tok->astOperand1()->str() && isSameExpression(tok->astOperand2(), tok->astOperand1()->astOperand2(), constStandardFunctions))
|
else if (tok->astOperand1() && tok->astOperand2() && tok->str() == tok->astOperand1()->str() && isSameExpression(tok->astOperand2(), tok->astOperand1()->astOperand2(), constStandardFunctions))
|
||||||
duplicateExpressionError(tok->astOperand2(), tok->astOperand2(), tok->str());
|
duplicateExpressionError(tok->astOperand2(), tok->astOperand2(), tok->str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4812,6 +4812,14 @@ private:
|
||||||
" if (a / 1000 / 1000) {}\n"
|
" if (a / 1000 / 1000) {}\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("void foo() {\n"
|
||||||
|
" if (a << 1 << 1) {}\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("int f() { return !!y; }"); // No FP
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void duplicateIf1() { // ticket 3689 ( avoid false positive )
|
void duplicateIf1() { // ticket 3689 ( avoid false positive )
|
||||||
|
|
Loading…
Reference in New Issue