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;
|
ret = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Token::Match(tok->previous(), "[(,!] ( %var% . %var% )")) {
|
while (Token::Match(tok->previous(), ";|{|}|[|]|(|)|.|,|! ( %var% .")) {
|
||||||
// We have "( var . var )", remove the parenthesis
|
Token *tok2 = tok->tokAt(2);
|
||||||
tok->deleteThis();
|
while (Token::Match(tok2, ". %var%")) {
|
||||||
tok = tok->tokAt(2);
|
tok2 = tok2->tokAt(2);
|
||||||
|
}
|
||||||
|
if (tok2 != tok->link())
|
||||||
|
break;
|
||||||
|
// We have "( var . var . ... . var )", remove the parenthesis
|
||||||
|
tok = tok->previous();
|
||||||
tok->deleteNext();
|
tok->deleteNext();
|
||||||
|
tok2->deleteThis();
|
||||||
ret = true;
|
ret = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4710,8 +4710,15 @@ private:
|
||||||
|
|
||||||
// "!(abc.a)" => "!abc.a"
|
// "!(abc.a)" => "!abc.a"
|
||||||
void removeParentheses6() {
|
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() {
|
void removeParentheses7() {
|
||||||
|
|
Loading…
Reference in New Issue