@@ -656,7 +656,6 @@ void WhitespaceManager::alignConsecutiveMacros() {
656656
657657 auto AlignMacrosMatches = [](const Change &C) {
658658 const FormatToken *Current = C.Tok ;
659- unsigned SpacesRequiredBefore = 1 ;
660659
661660 if (Current->SpacesRequiredBefore == 0 || !Current->Previous )
662661 return false ;
@@ -665,22 +664,21 @@ void WhitespaceManager::alignConsecutiveMacros() {
665664
666665 // If token is a ")", skip over the parameter list, to the
667666 // token that precedes the "("
668- if (Current->is (tok::r_paren) && Current->MatchingParen ) {
669- Current = Current->MatchingParen ->Previous ;
670- SpacesRequiredBefore = 0 ;
671- }
672-
673- if (!Current || Current->isNot (tok::identifier))
674- return false ;
675-
676- if (!Current->Previous || Current->Previous ->isNot (tok::pp_define))
667+ if (const auto *MatchingParen = Current->MatchingParen ;
668+ Current->is (tok::r_paren) && MatchingParen) {
669+ // For a macro function, 0 spaces are required between the
670+ // identifier and the lparen that opens the parameter list.
671+ if (MatchingParen->SpacesRequiredBefore > 0 )
672+ return false ;
673+ Current = MatchingParen->Previous ;
674+ } else if (Current->Next ->SpacesRequiredBefore != 1 ) {
675+ // For a simple macro, 1 space is required between the
676+ // identifier and the first token of the defined value.
677677 return false ;
678+ }
678679
679- // For a macro function, 0 spaces are required between the
680- // identifier and the lparen that opens the parameter list.
681- // For a simple macro, 1 space is required between the
682- // identifier and the first token of the defined value.
683- return Current->Next ->SpacesRequiredBefore == SpacesRequiredBefore;
680+ return Current && Current->is (tok::identifier) && Current->Previous &&
681+ Current->Previous ->is (tok::pp_define);
684682 };
685683
686684 unsigned MinColumn = 0 ;
0 commit comments