Skip to content

Commit e367b78

Browse files
committed
Address review comments
1 parent 562def1 commit e367b78

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

clang/lib/Format/ContinuationIndenter.cpp

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -805,29 +805,26 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
805805
};
806806
// Detecting functions is brittle. It would be better if we could annotate
807807
// the LParen type of functions/calls.
808-
const auto IsFunctionDeclParen = [&](const FormatToken &Tok) {
808+
auto IsFunctionDeclParen = [&](const FormatToken &Tok) {
809809
return Tok.is(tok::l_paren) && Tok.Previous &&
810810
(Tok.Previous->is(TT_FunctionDeclarationName) ||
811-
(Tok.Previous->Previous &&
812-
Tok.Previous->Previous->is(tok::coloncolon) &&
813-
Tok.Previous->Previous->Previous &&
814-
Tok.Previous->Previous->Previous->is(TT_FunctionDeclarationName)));
811+
Tok.endsSequence(TT_FunctionDeclarationName, tok::coloncolon));
815812
};
816-
const auto IsLambdaParameterList = [](const FormatToken *Left) {
813+
auto IsLambdaParameterList = [](const FormatToken *Tok) {
817814
// adapted from TokenAnnotator.cpp:isLambdaParameterList()
818815
// Skip <...> if present.
819-
if (Left->Previous && Left->Previous->is(tok::greater) &&
820-
Left->Previous->MatchingParen &&
821-
Left->Previous->MatchingParen->is(TT_TemplateOpener)) {
822-
Left = Left->Previous->MatchingParen;
816+
if (Tok->Previous && Tok->Previous->is(tok::greater) &&
817+
Tok->Previous->MatchingParen &&
818+
Tok->Previous->MatchingParen->is(TT_TemplateOpener)) {
819+
Tok = Tok->Previous->MatchingParen;
823820
}
824821

825822
// Check for `[...]`.
826-
return Left->Previous && Left->Previous->is(tok::r_square) &&
827-
Left->Previous->MatchingParen &&
828-
Left->Previous->MatchingParen->is(TT_LambdaLSquare);
823+
return Tok->Previous && Tok->Previous->is(tok::r_square) &&
824+
Tok->Previous->MatchingParen &&
825+
Tok->Previous->MatchingParen->is(TT_LambdaLSquare);
829826
};
830-
const auto IsFunctionCallParen = [&](const FormatToken &Tok) {
827+
auto IsFunctionCallParen = [&](const FormatToken &Tok) {
831828
return Tok.is(tok::l_paren) && Tok.ParameterCount > 0 && Tok.Previous &&
832829
Tok.Previous->is(tok::identifier);
833830
};

0 commit comments

Comments
 (0)