@@ -3450,10 +3450,11 @@ void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const {
3450
3450
for (AnnotatedLine *ChildLine : Line.Children )
3451
3451
calculateFormattingInformation (*ChildLine);
3452
3452
3453
- Line.First ->TotalLength =
3454
- Line.First ->IsMultiline ? Style .ColumnLimit
3455
- : Line.FirstStartColumn + Line.First ->ColumnWidth ;
3456
- FormatToken *Current = Line.First ->Next ;
3453
+ auto *First = Line.First ;
3454
+ First->TotalLength = First->IsMultiline
3455
+ ? Style .ColumnLimit
3456
+ : Line.FirstStartColumn + First->ColumnWidth ;
3457
+ FormatToken *Current = First->Next ;
3457
3458
bool InFunctionDecl = Line.MightBeFunctionDecl ;
3458
3459
bool AlignArrayOfStructures =
3459
3460
(Style .AlignArrayOfStructures != FormatStyle::AIAS_None &&
@@ -3475,16 +3476,15 @@ void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const {
3475
3476
if (const bool IsCtorOrDtor = Tok->is (TT_CtorDtorDeclName);
3476
3477
IsCtorOrDtor ||
3477
3478
isFunctionDeclarationName (Style .isCpp (), *Tok, Line, ClosingParen)) {
3478
- if (!IsCtorOrDtor) {
3479
- LineIsFunctionDeclaration = true ;
3479
+ if (!IsCtorOrDtor)
3480
3480
Tok->setFinalizedType (TT_FunctionDeclarationName);
3481
- }
3481
+ LineIsFunctionDeclaration = true ;
3482
3482
SeenName = true ;
3483
3483
break ;
3484
3484
}
3485
3485
}
3486
3486
3487
- if (IsCpp && LineIsFunctionDeclaration &&
3487
+ if (IsCpp && ( LineIsFunctionDeclaration || First-> is (TT_CtorDtorDeclName)) &&
3488
3488
Line.endsWith (tok::semi, tok::r_brace)) {
3489
3489
auto *Tok = Line.Last ->Previous ;
3490
3490
while (Tok->isNot (tok::r_brace))
@@ -3507,7 +3507,7 @@ void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const {
3507
3507
if (IsCpp) {
3508
3508
if (!LineIsFunctionDeclaration) {
3509
3509
// Annotate */&/&& in `operator` function calls as binary operators.
3510
- for (const auto *Tok = Line. First ; Tok; Tok = Tok->Next ) {
3510
+ for (const auto *Tok = First; Tok; Tok = Tok->Next ) {
3511
3511
if (Tok->isNot (tok::kw_operator))
3512
3512
continue ;
3513
3513
do {
@@ -3644,7 +3644,7 @@ void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const {
3644
3644
3645
3645
calculateUnbreakableTailLengths (Line);
3646
3646
unsigned IndentLevel = Line.Level ;
3647
- for (Current = Line. First ; Current; Current = Current->Next ) {
3647
+ for (Current = First; Current; Current = Current->Next ) {
3648
3648
if (Current->Role )
3649
3649
Current->Role ->precomputeFormattingInfos (Current);
3650
3650
if (Current->MatchingParen &&
0 commit comments