AST: don't warn about duplicate expressions around '+' operator. It might be more efficient than using for instance '*2'

This commit is contained in:
Daniel Marjamäki 2013-11-11 20:03:59 +01:00
parent 58d7caded1
commit 1ecade2657
2 changed files with 4 additions and 1 deletions

View File

@ -3340,7 +3340,7 @@ void CheckOther::checkDuplicateExpression()
// Experimental implementation
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()))
continue;
if (isSameExpression(tok->astOperand1(), tok->astOperand2(), constStandardFunctions))

View File

@ -4776,6 +4776,9 @@ private:
" ((f=='T') && (o == 2) && ((v < 200) || (v > 9999)))) {}\n"
"}");
ASSERT_EQUALS("", errout.str());
check("int f(int x) { return x+x; }");
ASSERT_EQUALS("", errout.str());
}
void duplicateIf1() { // ticket 3689 ( avoid false positive )