More simplifyRedundantParenthesis changes:
simplify also '( var . var . ... . var )' parenthesis.
This commit is contained in:
parent
b6b359d1c6
commit
24bf6f99e1
|
@ -6544,11 +6544,17 @@ bool Tokenizer::simplifyRedundantParenthesis()
|
|||
ret = true;
|
||||
}
|
||||
|
||||
if (Token::Match(tok->previous(), "[(,!] ( %var% . %var% )")) {
|
||||
// We have "( var . var )", remove the parenthesis
|
||||
tok->deleteThis();
|
||||
tok = tok->tokAt(2);
|
||||
while (Token::Match(tok->previous(), ";|{|}|[|]|(|)|.|,|! ( %var% .")) {
|
||||
Token *tok2 = tok->tokAt(2);
|
||||
while (Token::Match(tok2, ". %var%")) {
|
||||
tok2 = tok2->tokAt(2);
|
||||
}
|
||||
if (tok2 != tok->link())
|
||||
break;
|
||||
// We have "( var . var . ... . var )", remove the parenthesis
|
||||
tok = tok->previous();
|
||||
tok->deleteNext();
|
||||
tok2->deleteThis();
|
||||
ret = true;
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -4710,8 +4710,15 @@ private:
|
|||
|
||||
// "!(abc.a)" => "!abc.a"
|
||||
void removeParentheses6() {
|
||||
const char code[] = "(!(abc.a))";
|
||||
ASSERT_EQUALS("( ! abc . a )", tokenizeAndStringify(code));
|
||||
{
|
||||
const char code[] = "(!(abc.a))";
|
||||
ASSERT_EQUALS("( ! abc . a )", tokenizeAndStringify(code));
|
||||
}
|
||||
//handle more complex member selections
|
||||
{
|
||||
const char code[] = "(!(a.b.c.d));";
|
||||
ASSERT_EQUALS("( ! a . b . c . d ) ;", tokenizeAndStringify(code));
|
||||
}
|
||||
}
|
||||
|
||||
void removeParentheses7() {
|
||||
|
|
Loading…
Reference in New Issue