@@ -4021,29 +4021,28 @@ void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const {
40214021 }
40224022 }
40234023
4024- if (IsCpp &&
4025- (LineIsFunctionDeclaration ||
4026- (FirstNonComment && FirstNonComment->is (TT_CtorDtorDeclName))) &&
4027- Line.endsWith (tok::semi, tok::r_brace)) {
4028- auto *Tok = Line.Last ->Previous ;
4029- while (Tok->isNot (tok::r_brace))
4030- Tok = Tok->Previous ;
4031- if (auto *LBrace = Tok->MatchingParen ; LBrace && LBrace->is (TT_Unknown)) {
4032- assert (LBrace->is (tok::l_brace));
4033- Tok->setBlockKind (BK_Block);
4034- LBrace->setBlockKind (BK_Block);
4035- LBrace->setFinalizedType (TT_FunctionLBrace);
4024+ if (IsCpp) {
4025+ if ((LineIsFunctionDeclaration ||
4026+ (FirstNonComment && FirstNonComment->is (TT_CtorDtorDeclName))) &&
4027+ Line.endsWith (tok::semi, tok::r_brace)) {
4028+ auto *Tok = Line.Last ->Previous ;
4029+ while (Tok->isNot (tok::r_brace))
4030+ Tok = Tok->Previous ;
4031+ if (auto *LBrace = Tok->MatchingParen ; LBrace && LBrace->is (TT_Unknown)) {
4032+ assert (LBrace->is (tok::l_brace));
4033+ Tok->setBlockKind (BK_Block);
4034+ LBrace->setBlockKind (BK_Block);
4035+ LBrace->setFinalizedType (TT_FunctionLBrace);
4036+ }
40364037 }
4037- }
40384038
4039- if (IsCpp && SeenName && AfterLastAttribute &&
4040- mustBreakAfterAttributes (*AfterLastAttribute, Style)) {
4041- AfterLastAttribute->MustBreakBefore = true ;
4042- if (LineIsFunctionDeclaration)
4043- Line.ReturnTypeWrapped = true ;
4044- }
4039+ if ( SeenName && AfterLastAttribute &&
4040+ mustBreakAfterAttributes (*AfterLastAttribute, Style)) {
4041+ AfterLastAttribute->MustBreakBefore = true ;
4042+ if (LineIsFunctionDeclaration)
4043+ Line.ReturnTypeWrapped = true ;
4044+ }
40454045
4046- if (IsCpp) {
40474046 if (!LineIsFunctionDeclaration) {
40484047 // Annotate */&/&& in `operator` function calls as binary operators.
40494048 for (const auto *Tok = FirstNonComment; Tok; Tok = Tok->Next ) {
@@ -4089,6 +4088,11 @@ void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const {
40894088 }
40904089 }
40914090
4091+ if (First->is (TT_ElseLBrace)) {
4092+ First->CanBreakBefore = true ;
4093+ First->MustBreakBefore = true ;
4094+ }
4095+
40924096 bool InFunctionDecl = Line.MightBeFunctionDecl ;
40934097 bool InParameterList = false ;
40944098 for (auto *Current = First->Next ; Current; Current = Current->Next ) {
0 commit comments