Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

  • Loading branch information...
commit a49fc57e00db7009fc7d6983c617938c7e04bc5b 1 parent 54e7c8f
@danmar authored
Showing with 6 additions and 0 deletions.
  1. +3 −0  lib/tokenize.cpp
  2. +3 −0  test/testtokenize.cpp
View
3  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();
View
3  test/testtokenize.cpp
@@ -1042,6 +1042,9 @@ class TestTokenizer : public TestFixture {
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));
}
Please sign in to comment.
Something went wrong with that request. Please try again.