diff --git a/src/tokenize.cpp b/src/tokenize.cpp index 00f65ae49..0424528b0 100644 --- a/src/tokenize.cpp +++ b/src/tokenize.cpp @@ -2458,15 +2458,6 @@ bool Tokenizer::simplifyRedundantParanthesis() tok->deleteNext(); ret = true; } - - if (Token::Match(tok, "( %bool% ) )") || - Token::Match(tok, "( %num% ) )")) - { - tok = tok->next(); - tok->deleteNext(); - tok->previous()->deleteThis(); - ret = true; - } } return ret; } diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 4e27158c6..3771c37c0 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -1652,6 +1652,25 @@ private: ostr << " " << tok->str(); ASSERT_EQUALS(std::string(" void foo ( ) { { } }"), ostr.str()); } + + { + const char code[] = "void foo()\n" + "{\n" + " if( g(10)){}\n" + "}"; + + // tokenize.. + Tokenizer tokenizer; + std::istringstream istr(code); + tokenizer.tokenize(istr, "test.cpp"); + + tokenizer.simplifyTokenList(); + + std::ostringstream ostr; + for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next()) + ostr << " " << tok->str(); + ASSERT_EQUALS(std::string(" void foo ( ) { if ( g ( 10 ) ) { } }"), ostr.str()); + } } void simplify_numeric_condition()