@@ -2017,8 +2017,7 @@ void UnwrappedLineParser::parseStructuralElement(
2017
2017
} else if (Style.Language == FormatStyle::LK_Proto &&
2018
2018
FormatTok->is (tok::less)) {
2019
2019
nextToken ();
2020
- parseBracedList (/* ContinueOnSemicolons=*/ false , /* IsEnum=*/ false ,
2021
- /* ClosingBraceKind=*/ tok::greater);
2020
+ parseBracedList (/* IsAngleBracket=*/ true );
2022
2021
}
2023
2022
break ;
2024
2023
case tok::l_square:
@@ -2379,9 +2378,7 @@ bool UnwrappedLineParser::tryToParseChildBlock() {
2379
2378
return true ;
2380
2379
}
2381
2380
2382
- bool UnwrappedLineParser::parseBracedList (bool ContinueOnSemicolons,
2383
- bool IsEnum,
2384
- tok::TokenKind ClosingBraceKind) {
2381
+ bool UnwrappedLineParser::parseBracedList (bool IsAngleBracket, bool IsEnum) {
2385
2382
bool HasError = false ;
2386
2383
2387
2384
// FIXME: Once we have an expression parser in the UnwrappedLineParser,
@@ -2403,7 +2400,7 @@ bool UnwrappedLineParser::parseBracedList(bool ContinueOnSemicolons,
2403
2400
parseChildBlock ();
2404
2401
}
2405
2402
}
2406
- if (FormatTok->Tok . getKind () == ClosingBraceKind ) {
2403
+ if (FormatTok->is (IsAngleBracket ? tok::greater : tok::r_brace) ) {
2407
2404
if (IsEnum && !Style.AllowShortEnumsOnASingleLine )
2408
2405
addUnwrappedLine ();
2409
2406
nextToken ();
@@ -2434,14 +2431,9 @@ bool UnwrappedLineParser::parseBracedList(bool ContinueOnSemicolons,
2434
2431
parseBracedList ();
2435
2432
break ;
2436
2433
case tok::less:
2437
- if (Style.Language == FormatStyle::LK_Proto ||
2438
- ClosingBraceKind == tok::greater) {
2439
- nextToken ();
2440
- parseBracedList (/* ContinueOnSemicolons=*/ false , /* IsEnum=*/ false ,
2441
- /* ClosingBraceKind=*/ tok::greater);
2442
- } else {
2443
- nextToken ();
2444
- }
2434
+ nextToken ();
2435
+ if (IsAngleBracket)
2436
+ parseBracedList (/* IsAngleBracket=*/ true );
2445
2437
break ;
2446
2438
case tok::semi:
2447
2439
// JavaScript (or more precisely TypeScript) can have semicolons in braced
@@ -2453,8 +2445,8 @@ bool UnwrappedLineParser::parseBracedList(bool ContinueOnSemicolons,
2453
2445
break ;
2454
2446
}
2455
2447
HasError = true ;
2456
- if (!ContinueOnSemicolons )
2457
- return !HasError ;
2448
+ if (!IsEnum )
2449
+ return false ;
2458
2450
nextToken ();
2459
2451
break ;
2460
2452
case tok::comma:
@@ -3618,8 +3610,7 @@ void UnwrappedLineParser::parseConstraintExpression() {
3618
3610
return ;
3619
3611
3620
3612
nextToken ();
3621
- parseBracedList (/* ContinueOnSemicolons=*/ false , /* IsEnum=*/ false ,
3622
- /* ClosingBraceKind=*/ tok::greater);
3613
+ parseBracedList (/* IsAngleBracket=*/ true );
3623
3614
break ;
3624
3615
3625
3616
default :
@@ -3650,8 +3641,7 @@ void UnwrappedLineParser::parseConstraintExpression() {
3650
3641
nextToken ();
3651
3642
if (FormatTok->is (tok::less)) {
3652
3643
nextToken ();
3653
- parseBracedList (/* ContinueOnSemicolons=*/ false , /* IsEnum=*/ false ,
3654
- /* ClosingBraceKind=*/ tok::greater);
3644
+ parseBracedList (/* IsAngleBracket=*/ true );
3655
3645
}
3656
3646
TopLevelParensAllowed = false ;
3657
3647
break ;
@@ -3732,8 +3722,7 @@ bool UnwrappedLineParser::parseEnum() {
3732
3722
addUnwrappedLine ();
3733
3723
Line->Level += 1 ;
3734
3724
}
3735
- bool HasError = !parseBracedList (/* ContinueOnSemicolons=*/ true ,
3736
- /* IsEnum=*/ true );
3725
+ bool HasError = !parseBracedList (/* IsAngleBracket=*/ false , /* IsEnum=*/ true );
3737
3726
if (!Style.AllowShortEnumsOnASingleLine )
3738
3727
Line->Level -= 1 ;
3739
3728
if (HasError) {
0 commit comments