Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions clang/lib/Format/WhitespaceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ void WhitespaceManager::alignConsecutiveMacros() {

auto AlignMacrosMatches = [](const Change &C) {
const FormatToken *Current = C.Tok;
unsigned SpacesRequiredBefore = 1;
assert(Current);

if (Current->SpacesRequiredBefore == 0 || !Current->Previous)
return false;
Expand All @@ -665,22 +665,22 @@ void WhitespaceManager::alignConsecutiveMacros() {

// If token is a ")", skip over the parameter list, to the
// token that precedes the "("
if (Current->is(tok::r_paren) && Current->MatchingParen) {
Current = Current->MatchingParen->Previous;
SpacesRequiredBefore = 0;
}

if (!Current || Current->isNot(tok::identifier))
return false;

if (!Current->Previous || Current->Previous->isNot(tok::pp_define))
if (Current->is(tok::r_paren)) {
const auto *MatchingParen = Current->MatchingParen;
// For a macro function, 0 spaces are required between the
// identifier and the lparen that opens the parameter list.
if (!MatchingParen || MatchingParen->SpacesRequiredBefore > 0 ||
!MatchingParen->Previous) {
return false;
}
Current = MatchingParen->Previous;
} else if (Current->Next->SpacesRequiredBefore != 1) {
// For a simple macro, 1 space is required between the
// identifier and the first token of the defined value.
return false;
}

// For a macro function, 0 spaces are required between the
// identifier and the lparen that opens the parameter list.
// For a simple macro, 1 space is required between the
// identifier and the first token of the defined value.
return Current->Next->SpacesRequiredBefore == SpacesRequiredBefore;
return Current->endsSequence(tok::identifier, tok::pp_define);
};

unsigned MinColumn = 0;
Expand Down
Loading