@@ -4000,29 +4000,28 @@ void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const {
40004000 }
40014001 }
40024002
4003- if (IsCpp &&
4004- (LineIsFunctionDeclaration ||
4005- (FirstNonComment && FirstNonComment->is (TT_CtorDtorDeclName))) &&
4006- Line.endsWith (tok::semi, tok::r_brace)) {
4007- auto *Tok = Line.Last ->Previous ;
4008- while (Tok->isNot (tok::r_brace))
4009- Tok = Tok->Previous ;
4010- if (auto *LBrace = Tok->MatchingParen ; LBrace && LBrace->is (TT_Unknown)) {
4011- assert (LBrace->is (tok::l_brace));
4012- Tok->setBlockKind (BK_Block);
4013- LBrace->setBlockKind (BK_Block);
4014- LBrace->setFinalizedType (TT_FunctionLBrace);
4003+ if (IsCpp) {
4004+ if ((LineIsFunctionDeclaration ||
4005+ (FirstNonComment && FirstNonComment->is (TT_CtorDtorDeclName))) &&
4006+ Line.endsWith (tok::semi, tok::r_brace)) {
4007+ auto *Tok = Line.Last ->Previous ;
4008+ while (Tok->isNot (tok::r_brace))
4009+ Tok = Tok->Previous ;
4010+ if (auto *LBrace = Tok->MatchingParen ; LBrace && LBrace->is (TT_Unknown)) {
4011+ assert (LBrace->is (tok::l_brace));
4012+ Tok->setBlockKind (BK_Block);
4013+ LBrace->setBlockKind (BK_Block);
4014+ LBrace->setFinalizedType (TT_FunctionLBrace);
4015+ }
40154016 }
4016- }
40174017
4018- if (IsCpp && SeenName && AfterLastAttribute &&
4019- mustBreakAfterAttributes (*AfterLastAttribute, Style)) {
4020- AfterLastAttribute->MustBreakBefore = true ;
4021- if (LineIsFunctionDeclaration)
4022- Line.ReturnTypeWrapped = true ;
4023- }
4018+ if ( SeenName && AfterLastAttribute &&
4019+ mustBreakAfterAttributes (*AfterLastAttribute, Style)) {
4020+ AfterLastAttribute->MustBreakBefore = true ;
4021+ if (LineIsFunctionDeclaration)
4022+ Line.ReturnTypeWrapped = true ;
4023+ }
40244024
4025- if (IsCpp) {
40264025 if (!LineIsFunctionDeclaration) {
40274026 // Annotate */&/&& in `operator` function calls as binary operators.
40284027 for (const auto *Tok = FirstNonComment; Tok; Tok = Tok->Next ) {
@@ -4068,6 +4067,11 @@ void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const {
40684067 }
40694068 }
40704069
4070+ if (First->is (TT_ElseLBrace)) {
4071+ First->CanBreakBefore = true ;
4072+ First->MustBreakBefore = true ;
4073+ }
4074+
40714075 bool InFunctionDecl = Line.MightBeFunctionDecl ;
40724076 bool InParameterList = false ;
40734077 for (auto *Current = First->Next ; Current; Current = Current->Next ) {
0 commit comments