File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -8983,7 +8983,10 @@ void Tokenizer::simplifyFunctionTryCatch()
89838983 for (Token * tok = list.front (); tok; tok = tok->next ()) {
89848984 if (!Token::Match (tok, " try {|:" ))
89858985 continue ;
8986- if (!TokenList::isFunctionHead (tok->previous (), " try" )) // TODO: this is supposed to a list of characters and not strings
8986+ const Token* par = tok->previous ();
8987+ while (par && par->isKeyword ())
8988+ par = par->previous ();
8989+ if (!TokenList::isFunctionHead (par, " try" )) // TODO: this is supposed to a list of characters and not strings
89878990 continue ;
89888991
89898992 Token* tryStartToken = skipInitializerList (tok->next ());
Original file line number Diff line number Diff line change @@ -1817,6 +1817,15 @@ class TestTokenizer : public TestFixture {
18171817 " };\n "
18181818 " } catch (long) {\n "
18191819 " }" ));
1820+
1821+ ASSERT_EQUALS (" struct S { void func ( ) const ; } ;\n "
1822+ " void S :: func ( ) const {\n "
1823+ " try { f ( ) ; }\n "
1824+ " catch ( ... ) { g ( ) ; } }" ,
1825+ tokenizeAndStringify (" struct S { void func() const; };\n "
1826+ " void S::func() const\n "
1827+ " try { f(); }\n "
1828+ " catch (...) { g(); }\n " ));
18201829 }
18211830
18221831 // Simplify "((..))" into "(..)"
You can’t perform that action at this time.
0 commit comments