From a49fc57e00db7009fc7d6983c617938c7e04bc5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 11 Apr 2013 07:19:32 +0200 Subject: [PATCH] Tokenizer: don't simplify 'a!=(b!=0)' to 'a!=b'. Ticket: #4697 --- lib/tokenize.cpp | 3 +++ test/testtokenize.cpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index bb51629c1..c5ec6ab96 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -5672,6 +5672,9 @@ void Tokenizer::simplifyIfNotNull() continue; } + if (Token::Match(tok, "==|!= (")) + tok = tok->linkAt(1); + if (Token::Match(tok, "(|&&|%oror%")) { tok = tok->next(); diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 37fb656c3..e65b84bcb 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -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)); }