Tokenizer: Cleanup redundant statement '; x = x + 0;'. Ticket: #2283

This commit is contained in:
Daniel Marjamäki 2010-12-09 19:35:52 +01:00
parent e6bef96711
commit 69bacde479
2 changed files with 10 additions and 0 deletions

View File

@ -6566,6 +6566,14 @@ bool Tokenizer::simplifyCalculations()
if (Token::Match(tok->previous(), "[+-] 0"))
{
tok = tok->previous();
if (Token::Match(tok->tokAt(-4), "[;{}] %var% = %var% [+-] 0 ;") &&
tok->strAt(-3) == tok->strAt(-1))
{
tok = tok->previous()->previous()->previous();
tok->deleteThis();
tok->deleteThis();
tok->deleteThis();
}
tok->deleteThis();
tok->deleteThis();
ret = true;

View File

@ -2563,6 +2563,8 @@ private:
const char code[] = "void * operator new[](size_t);";
ASSERT_EQUALS("void * operator new [ ] ( size_t ) ;", tok(code));
}
ASSERT_EQUALS(";", tok("; x = x + 0;"));
}