Tokenizer::simplifyRedundantParenthesis refactor:

Change useless 'while' to 'if' where possible; unify duplicate 'delete [| ]| var' handling code.
This commit is contained in:
Edoardo Prezioso 2012-11-04 19:54:50 +01:00
parent 93f1fed205
commit b6b359d1c6
1 changed files with 4 additions and 13 deletions

View File

@ -6511,7 +6511,7 @@ bool Tokenizer::simplifyRedundantParenthesis()
ret = true;
}
while (Token::Match(tok->previous(), "[,;{}(] ( %var% (") &&
if (Token::Match(tok->previous(), "[(,;{}] ( %var% (") &&
tok->link()->previous() == tok->linkAt(2)) {
// We have "( func ( *something* ))", remove the outer
// parenthesis
@ -6520,18 +6520,10 @@ bool Tokenizer::simplifyRedundantParenthesis()
ret = true;
}
while (Token::Match(tok->previous(), "[;{] ( delete %var% ) ;")) {
// We have "( delete var )", remove the outer
if (Token::Match(tok->previous(), "[,;{}] ( delete [| ]| %var% ) ;")) {
// We have "( delete [| ]| var )", remove the outer
// parenthesis
tok->tokAt(3)->deleteThis();
tok->deleteThis();
ret = true;
}
while (Token::Match(tok->previous(), "[;{] ( delete [ ] %var% ) ;")) {
// We have "( delete [] var )", remove the outer
// parenthesis
tok->tokAt(5)->deleteThis();
tok->link()->deleteThis();
tok->deleteThis();
ret = true;
}
@ -6550,7 +6542,6 @@ bool Tokenizer::simplifyRedundantParenthesis()
tok->deleteThis();
tok->deleteNext();
ret = true;
continue;
}
if (Token::Match(tok->previous(), "[(,!] ( %var% . %var% )")) {