AST: don't warn about duplicate expressions around '+' operator. It might be more efficient than using for instance '*2'
This commit is contained in:
parent
58d7caded1
commit
1ecade2657
|
@ -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))
|
||||
|
|
|
@ -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 )
|
||||
|
|
Loading…
Reference in New Issue