Skip to content

Commit

Permalink
Fix #13344 (Tokenizer: Do not remove extra parentheses ((..))) (danma…
Browse files Browse the repository at this point in the history
  • Loading branch information
swasti16 authored Dec 6, 2024
1 parent aad6e09 commit 57d4d61
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
11 changes: 1 addition & 10 deletions lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7892,15 +7892,6 @@ bool Tokenizer::simplifyRedundantParentheses()
continue;
}

while (Token::simpleMatch(tok, "( (") &&
tok->link() && tok->link()->previous() == tok->linkAt(1)) {
// We have "(( *something* ))", remove the inner
// parentheses
tok->deleteNext();
tok->link()->tokAt(-2)->deleteNext();
ret = true;
}

if (isCPP() && Token::Match(tok->tokAt(-2), "[;{}=(] new (") && Token::Match(tok->link(), ") [;,{}[]")) {
// Remove the parentheses in "new (type)" constructs
tok->link()->deleteThis();
Expand Down Expand Up @@ -7971,7 +7962,7 @@ bool Tokenizer::simplifyRedundantParentheses()
}

while (Token::Match(tok->previous(), "[{([,] ( !!{") &&
Token::Match(tok->link(), ") [;,])]") &&
Token::Match(tok->link(), ") [;,])] !!{") &&
!Token::simpleMatch(tok->tokAt(-2), "operator ,") && // Ticket #5709
!Token::findsimplematch(tok, ",", tok->link())) {
// We have "( ... )", remove the parentheses
Expand Down
2 changes: 1 addition & 1 deletion test/testsimplifytypedef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1154,7 +1154,7 @@ class TestSimplifyTypedef : public TestFixture {
"int main ( ) "
"{ "
""
"VERIFY ( is_same < result_of < int ( * ( char , float ) ) ( float , double ) > :: type , int > :: value ) ; "
"VERIFY ( ( is_same < result_of < int ( * ( char , float ) ) ( float , double ) > :: type , int > :: value ) ) ; "
"}";

ASSERT_EQUALS(expected, tok(code, false));
Expand Down

0 comments on commit 57d4d61

Please sign in to comment.