@@ -2955,9 +2955,15 @@ void UnwrappedLineParser::parseTryCatch() {
2955
2955
assert (FormatTok->isOneOf (tok::kw_try, tok::kw___try) && " 'try' expected" );
2956
2956
nextToken ();
2957
2957
bool NeedsUnwrappedLine = false ;
2958
+ bool HasCtorInitializer = false ;
2958
2959
if (FormatTok->is (tok::colon)) {
2960
+ auto *Colon = FormatTok;
2959
2961
// We are in a function try block, what comes is an initializer list.
2960
2962
nextToken ();
2963
+ if (FormatTok->is (tok::identifier)) {
2964
+ HasCtorInitializer = true ;
2965
+ Colon->setFinalizedType (TT_CtorInitializerColon);
2966
+ }
2961
2967
2962
2968
// In case identifiers were removed by clang-tidy, what might follow is
2963
2969
// multiple commas in sequence - before the first identifier.
@@ -2966,14 +2972,11 @@ void UnwrappedLineParser::parseTryCatch() {
2966
2972
2967
2973
while (FormatTok->is (tok::identifier)) {
2968
2974
nextToken ();
2969
- if (FormatTok->is (tok::l_paren))
2975
+ if (FormatTok->is (tok::l_paren)) {
2970
2976
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)) {
2976
2978
nextToken ();
2979
+ parseBracedList ();
2977
2980
}
2978
2981
2979
2982
// In case identifiers were removed by clang-tidy, what might follow is
@@ -2989,6 +2992,8 @@ void UnwrappedLineParser::parseTryCatch() {
2989
2992
keepAncestorBraces ();
2990
2993
2991
2994
if (FormatTok->is (tok::l_brace)) {
2995
+ if (HasCtorInitializer)
2996
+ FormatTok->setFinalizedType (TT_FunctionLBrace);
2992
2997
CompoundStatementIndenter Indenter (this , Style, Line->Level );
2993
2998
parseBlock ();
2994
2999
if (Style.BraceWrapping .BeforeCatch )
0 commit comments