@@ -4021,29 +4021,28 @@ void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const {
4021
4021
}
4022
4022
}
4023
4023
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
+ }
4036
4037
}
4037
- }
4038
4038
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
+ }
4045
4045
4046
- if (IsCpp) {
4047
4046
if (!LineIsFunctionDeclaration) {
4048
4047
// Annotate */&/&& in `operator` function calls as binary operators.
4049
4048
for (const auto *Tok = FirstNonComment; Tok; Tok = Tok->Next ) {
@@ -4089,6 +4088,11 @@ void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const {
4089
4088
}
4090
4089
}
4091
4090
4091
+ if (First->is (TT_ElseLBrace)) {
4092
+ First->CanBreakBefore = true ;
4093
+ First->MustBreakBefore = true ;
4094
+ }
4095
+
4092
4096
bool InFunctionDecl = Line.MightBeFunctionDecl ;
4093
4097
bool InParameterList = false ;
4094
4098
for (auto *Current = First->Next ; Current; Current = Current->Next ) {
0 commit comments