Skip to content

Commit b4c06a4

Browse files
Address review
1 parent ff688c7 commit b4c06a4

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

clang/lib/Format/WhitespaceManager.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -664,21 +664,22 @@ void WhitespaceManager::alignConsecutiveMacros() {
664664

665665
// If token is a ")", skip over the parameter list, to the
666666
// token that precedes the "("
667-
if (const auto *MatchingParen = Current->MatchingParen;
668-
Current->is(tok::r_paren) && MatchingParen) {
667+
if (Current->is(tok::r_paren)) {
668+
const auto *MatchingParen = Current->MatchingParen;
669669
// For a macro function, 0 spaces are required between the
670670
// identifier and the lparen that opens the parameter list.
671-
if (MatchingParen->SpacesRequiredBefore > 0)
671+
if (!MatchingParen || MatchingParen->SpacesRequiredBefore > 0 ||
672+
!MatchingParen->Previous) {
672673
return false;
674+
}
673675
Current = MatchingParen->Previous;
674676
} else if (Current->Next->SpacesRequiredBefore != 1) {
675677
// For a simple macro, 1 space is required between the
676678
// identifier and the first token of the defined value.
677679
return false;
678680
}
679681

680-
return Current && Current->is(tok::identifier) && Current->Previous &&
681-
Current->Previous->is(tok::pp_define);
682+
return Current->endsSequence(tok::identifier, tok::pp_define);
682683
};
683684

684685
unsigned MinColumn = 0;

0 commit comments

Comments
 (0)