File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -3788,7 +3788,7 @@ void Tokenizer::simplifyParenthesizedLibraryFunctions()
37883788 if (!Token::simpleMatch (tok, " ) (" ))
37893789 continue ;
37903790 Token *rpar = tok, *lpar = tok->link ();
3791- if (!lpar || (Token::Match (lpar->previous (), " %name%" ) && !lpar->previous ()-> isKeyword ( )))
3791+ if (!lpar || (Token::Match (lpar->previous (), " %name%" ) && !Token::Match ( lpar->previous (), " return|delete|throw " )))
37923792 continue ;
37933793 const Token *ftok = rpar->previous ();
37943794 if (mSettings .library .isNotLibraryFunction (ftok))
Original file line number Diff line number Diff line change @@ -185,6 +185,7 @@ class TestTokenizer : public TestFixture {
185185 TEST_CASE (removeParentheses27);
186186 TEST_CASE (removeParentheses28); // #12164 - don't remove parentheses in '(expr1) ? (expr2) : (expr3);'
187187 TEST_CASE (removeParantheses29); // #13735
188+ TEST_CASE (removeParentheses30);
188189
189190 TEST_CASE (tokenize_double);
190191 TEST_CASE (tokenize_strings);
@@ -2192,6 +2193,19 @@ class TestTokenizer : public TestFixture {
21922193 ASSERT_EQUALS (exp, tokenizeAndStringify (code));
21932194 }
21942195
2196+ void removeParentheses30 () {
2197+ static char code[] = " void f (Node *node) {\n "
2198+ " if (node->data && (node->provider)->free)\n "
2199+ " (node->provider)->free (node);\n "
2200+ " }\n " ;
2201+ static const char exp[] = " void f ( Node * node ) {\n "
2202+ " if ( node . data && ( node . provider ) . free ) {\n "
2203+ " node . provider . free ( node ) ; }\n "
2204+ " }" ;
2205+ ASSERT_EQUALS (exp, tokenizeAndStringify (code));
2206+ (void ) errout_str ();
2207+ }
2208+
21952209 void tokenize_double () {
21962210 const char code[] = " void f() {\n "
21972211 " double a = 4.2;\n "
You can’t perform that action at this time.
0 commit comments