Fixed ticket #529 (Tokenizer: simplify if((x==0)))
http://sourceforge.net/apps/trac/cppcheck/ticket/529
This commit is contained in:
parent
050b85c5eb
commit
b56fdb83da
|
@ -2558,6 +2558,12 @@ bool Tokenizer::simplifyIfNot()
|
|||
if (tok->str() == "(" || tok->str() == "||" || tok->str() == "&&")
|
||||
{
|
||||
tok = tok->next();
|
||||
while (tok && tok->str() == "(")
|
||||
tok = tok->next();
|
||||
|
||||
if (!tok)
|
||||
break;
|
||||
|
||||
if (Token::simpleMatch(tok, "0 == (") ||
|
||||
Token::Match(tok, "0 == %var%"))
|
||||
{
|
||||
|
|
|
@ -1005,6 +1005,8 @@ private:
|
|||
ASSERT_EQUALS("if ( b ( ) && ! a )", simplifyIfNot("if( b() && 0 == a )"));
|
||||
ASSERT_EQUALS("if ( ! ( a = b ) )", simplifyIfNot("if((a=b)==0)"));
|
||||
ASSERT_EQUALS("if ( ! x . y )", simplifyIfNot("if(x.y==0)"));
|
||||
ASSERT_EQUALS("if ( ( ! x ) )", simplifyIfNot("if((x==0))"));
|
||||
ASSERT_EQUALS("if ( ( ! x ) && ! y )", simplifyIfNot("if((x==0) && y==0)"));
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue