Tokenizer: don't simplify 'a!=(b!=0)' to 'a!=b'. Ticket: #4697

This commit is contained in:
Daniel Marjamäki 2013-04-11 07:19:32 +02:00
parent 54e7c8f6a2
commit a49fc57e00
2 changed files with 6 additions and 0 deletions

View File

@ -5672,6 +5672,9 @@ void Tokenizer::simplifyIfNotNull()
continue;
}
if (Token::Match(tok, "==|!= ("))
tok = tok->linkAt(1);
if (Token::Match(tok, "(|&&|%oror%")) {
tok = tok->next();

View File

@ -1042,6 +1042,9 @@ private:
ASSERT_EQUALS("( ! p )", tokenizeAndStringify("( 0UL == p )", true));
ASSERT_EQUALS("( ! p )", tokenizeAndStringify("( 0ul == p )", true));
ASSERT_EQUALS("( ! p )", tokenizeAndStringify("( 0l == p )", true));
// not pointer
ASSERT_EQUALS("( x != ( y != 0 ) )", tokenizeAndStringify("( x != ( y != 0 ) )", false));
}