@@ -480,10 +480,6 @@ bool UnwrappedLineParser::parseLevel(bool HasOpeningBrace,
480
480
unsigned StatementCount = 0 ;
481
481
bool SwitchLabelEncountered = false ;
482
482
do {
483
- if (FormatTok->getType () == TT_AttributeMacro) {
484
- nextToken ();
485
- continue ;
486
- }
487
483
tok::TokenKind kind = FormatTok->Tok .getKind ();
488
484
if (FormatTok->getType () == TT_MacroBlockBegin)
489
485
kind = tok::l_brace;
@@ -573,8 +569,6 @@ bool UnwrappedLineParser::parseLevel(bool HasOpeningBrace,
573
569
parseCSharpAttribute ();
574
570
break ;
575
571
}
576
- if (handleCppAttributes ())
577
- break ;
578
572
LLVM_FALLTHROUGH;
579
573
default :
580
574
ParseDefault ();
@@ -1403,11 +1397,9 @@ void UnwrappedLineParser::parseStructuralElement(IfStmtKind *IfKind,
1403
1397
// e.g. "default void f() {}" in a Java interface.
1404
1398
break ;
1405
1399
case tok::kw_case:
1406
- if (Style.isJavaScript () && Line->MustBeDeclaration ) {
1400
+ if (Style.isJavaScript () && Line->MustBeDeclaration )
1407
1401
// 'case: string' field declaration.
1408
- nextToken ();
1409
1402
break ;
1410
- }
1411
1403
parseCaseLabel ();
1412
1404
return ;
1413
1405
case tok::kw_try:
@@ -1828,12 +1820,6 @@ void UnwrappedLineParser::parseStructuralElement(IfStmtKind *IfKind,
1828
1820
case tok::kw_new:
1829
1821
parseNew ();
1830
1822
break ;
1831
- case tok::kw_case:
1832
- if (Style.isJavaScript () && Line->MustBeDeclaration )
1833
- // 'case: string' field declaration.
1834
- break ;
1835
- parseCaseLabel ();
1836
- break ;
1837
1823
default :
1838
1824
nextToken ();
1839
1825
break ;
@@ -2402,24 +2388,17 @@ static void markOptionalBraces(FormatToken *LeftBrace) {
2402
2388
RightBrace->Optional = true ;
2403
2389
}
2404
2390
2405
- void UnwrappedLineParser::handleAttributes () {
2406
- // Handle AttributeMacro, e.g. `if (x) UNLIKELY`.
2407
- if (FormatTok->is (TT_AttributeMacro))
2408
- nextToken ();
2409
- handleCppAttributes ();
2410
- }
2411
-
2412
- bool UnwrappedLineParser::handleCppAttributes () {
2413
- // Handle [[likely]] / [[unlikely]] attributes.
2414
- if (FormatTok->is (tok::l_square) && tryToParseSimpleAttribute ()) {
2415
- parseSquare ();
2416
- return true ;
2417
- }
2418
- return false ;
2419
- }
2420
-
2421
2391
FormatToken *UnwrappedLineParser::parseIfThenElse (IfStmtKind *IfKind,
2422
2392
bool KeepBraces) {
2393
+ auto HandleAttributes = [this ]() {
2394
+ // Handle AttributeMacro, e.g. `if (x) UNLIKELY`.
2395
+ if (FormatTok->is (TT_AttributeMacro))
2396
+ nextToken ();
2397
+ // Handle [[likely]] / [[unlikely]] attributes.
2398
+ if (FormatTok->is (tok::l_square) && tryToParseSimpleAttribute ())
2399
+ parseSquare ();
2400
+ };
2401
+
2423
2402
assert (FormatTok->is (tok::kw_if) && " 'if' expected" );
2424
2403
nextToken ();
2425
2404
if (FormatTok->is (tok::exclaim))
@@ -2432,7 +2411,7 @@ FormatToken *UnwrappedLineParser::parseIfThenElse(IfStmtKind *IfKind,
2432
2411
if (FormatTok->is (tok::l_paren))
2433
2412
parseParens ();
2434
2413
}
2435
- handleAttributes ();
2414
+ HandleAttributes ();
2436
2415
2437
2416
bool NeedsUnwrappedLine = false ;
2438
2417
keepAncestorBraces ();
@@ -2469,7 +2448,7 @@ FormatToken *UnwrappedLineParser::parseIfThenElse(IfStmtKind *IfKind,
2469
2448
Kind = IfStmtKind::IfElse;
2470
2449
}
2471
2450
nextToken ();
2472
- handleAttributes ();
2451
+ HandleAttributes ();
2473
2452
if (FormatTok->is (tok::l_brace)) {
2474
2453
ElseLeftBrace = FormatTok;
2475
2454
CompoundStatementIndenter Indenter (this , Style, Line->Level );
0 commit comments