Tokenizer::simplifyRedundantParenthesis refactor:
Change useless 'while' to 'if' where possible; unify duplicate 'delete [| ]| var' handling code.
This commit is contained in:
parent
93f1fed205
commit
b6b359d1c6
|
@ -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% )")) {
|
||||
|
|
Loading…
Reference in New Issue