@@ -3450,10 +3450,11 @@ void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const {
34503450 for (AnnotatedLine *ChildLine : Line.Children )
34513451 calculateFormattingInformation (*ChildLine);
34523452
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 ;
34573458 bool InFunctionDecl = Line.MightBeFunctionDecl ;
34583459 bool AlignArrayOfStructures =
34593460 (Style.AlignArrayOfStructures != FormatStyle::AIAS_None &&
@@ -3475,16 +3476,15 @@ void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const {
34753476 if (const bool IsCtorOrDtor = Tok->is (TT_CtorDtorDeclName);
34763477 IsCtorOrDtor ||
34773478 isFunctionDeclarationName (Style.isCpp (), *Tok, Line, ClosingParen)) {
3478- if (!IsCtorOrDtor) {
3479- LineIsFunctionDeclaration = true ;
3479+ if (!IsCtorOrDtor)
34803480 Tok->setFinalizedType (TT_FunctionDeclarationName);
3481- }
3481+ LineIsFunctionDeclaration = true ;
34823482 SeenName = true ;
34833483 break ;
34843484 }
34853485 }
34863486
3487- if (IsCpp && LineIsFunctionDeclaration &&
3487+ if (IsCpp && ( LineIsFunctionDeclaration || First-> is (TT_CtorDtorDeclName)) &&
34883488 Line.endsWith (tok::semi, tok::r_brace)) {
34893489 auto *Tok = Line.Last ->Previous ;
34903490 while (Tok->isNot (tok::r_brace))
@@ -3507,7 +3507,7 @@ void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const {
35073507 if (IsCpp) {
35083508 if (!LineIsFunctionDeclaration) {
35093509 // 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 ) {
35113511 if (Tok->isNot (tok::kw_operator))
35123512 continue ;
35133513 do {
@@ -3644,7 +3644,7 @@ void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const {
36443644
36453645 calculateUnbreakableTailLengths (Line);
36463646 unsigned IndentLevel = Line.Level ;
3647- for (Current = Line. First ; Current; Current = Current->Next ) {
3647+ for (Current = First; Current; Current = Current->Next ) {
36483648 if (Current->Role )
36493649 Current->Role ->precomputeFormattingInfos (Current);
36503650 if (Current->MatchingParen &&
0 commit comments