File tree 2 files changed +13
-1
lines changed
2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -8983,7 +8983,10 @@ void Tokenizer::simplifyFunctionTryCatch()
8983
8983
for (Token * tok = list.front(); tok; tok = tok->next()) {
8984
8984
if (!Token::Match(tok, "try {|:"))
8985
8985
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
8987
8990
continue;
8988
8991
8989
8992
Token* tryStartToken = skipInitializerList(tok->next());
Original file line number Diff line number Diff line change @@ -1817,6 +1817,15 @@ class TestTokenizer : public TestFixture {
1817
1817
" };\n"
1818
1818
"} catch (long) {\n"
1819
1819
"}"));
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"));
1820
1829
}
1821
1830
1822
1831
// Simplify "((..))" into "(..)"
You can’t perform that action at this time.
0 commit comments