@@ -2955,9 +2955,15 @@ void UnwrappedLineParser::parseTryCatch() {
29552955 assert (FormatTok->isOneOf (tok::kw_try, tok::kw___try) && " 'try' expected" );
29562956 nextToken ();
29572957 bool NeedsUnwrappedLine = false ;
2958+ bool HasCtorInitializer = false ;
29582959 if (FormatTok->is (tok::colon)) {
2960+ auto *Colon = FormatTok;
29592961 // We are in a function try block, what comes is an initializer list.
29602962 nextToken ();
2963+ if (FormatTok->is (tok::identifier)) {
2964+ HasCtorInitializer = true ;
2965+ Colon->setFinalizedType (TT_CtorInitializerColon);
2966+ }
29612967
29622968 // In case identifiers were removed by clang-tidy, what might follow is
29632969 // multiple commas in sequence - before the first identifier.
@@ -2966,14 +2972,11 @@ void UnwrappedLineParser::parseTryCatch() {
29662972
29672973 while (FormatTok->is (tok::identifier)) {
29682974 nextToken ();
2969- if (FormatTok->is (tok::l_paren))
2975+ if (FormatTok->is (tok::l_paren)) {
29702976 parseParens ();
2971- if (FormatTok->Previous && FormatTok->Previous ->is (tok::identifier) &&
2972- FormatTok->is (tok::l_brace)) {
2973- do {
2974- nextToken ();
2975- } while (FormatTok->isNot (tok::r_brace));
2977+ } else if (FormatTok->is (tok::l_brace)) {
29762978 nextToken ();
2979+ parseBracedList ();
29772980 }
29782981
29792982 // In case identifiers were removed by clang-tidy, what might follow is
@@ -2989,6 +2992,8 @@ void UnwrappedLineParser::parseTryCatch() {
29892992 keepAncestorBraces ();
29902993
29912994 if (FormatTok->is (tok::l_brace)) {
2995+ if (HasCtorInitializer)
2996+ FormatTok->setFinalizedType (TT_FunctionLBrace);
29922997 CompoundStatementIndenter Indenter (this , Style, Line->Level );
29932998 parseBlock ();
29942999 if (Style.BraceWrapping .BeforeCatch )
0 commit comments