Tokenizer: Cleanup redundant statement '; x = x + 0;'. Ticket: #2283
This commit is contained in:
parent
e6bef96711
commit
69bacde479
|
@ -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;
|
||||
|
|
|
@ -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;"));
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue