@@ -813,6 +813,20 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
813
813
Tok.Previous ->Previous ->Previous &&
814
814
Tok.Previous ->Previous ->Previous ->is (TT_FunctionDeclarationName)));
815
815
};
816
+ const auto IsLambdaParameterList = [](const FormatToken *Left) {
817
+ // adapted from TokenAnnotator.cpp:isLambdaParameterList()
818
+ // 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 ;
823
+ }
824
+
825
+ // Check for `[...]`.
826
+ return Left->Previous && Left->Previous ->is (tok::r_square) &&
827
+ Left->Previous ->MatchingParen &&
828
+ Left->Previous ->MatchingParen ->is (TT_LambdaLSquare);
829
+ };
816
830
const auto IsFunctionCallParen = [&](const FormatToken &Tok) {
817
831
return Tok.is (tok::l_paren) && Tok.ParameterCount > 0 && Tok.Previous &&
818
832
Tok.Previous ->is (tok::identifier);
@@ -828,18 +842,18 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
828
842
}
829
843
return false ;
830
844
};
845
+ // Identifies simple (no expression) one-argument function calls.
831
846
const auto IsNotSimpleFunction = [&](const FormatToken &Tok) {
832
847
const auto *Previous = Tok.Previous ;
833
848
const auto *Next = Tok.Next ;
834
849
if (Tok.FakeLParens .size () > 0 && Tok.FakeLParens .back () > prec::Unknown)
835
850
return true ;
836
851
if (Previous &&
837
- (IsFunctionDeclParen (*Previous) || IsFunctionCallParen (*Previous))) {
838
- if (!IsOpeningBracket (Tok) && Next && !Next->isMemberAccess () &&
839
- !IsInTemplateString (Tok) && !IsFunctionDeclParen (*Next) &&
840
- !IsFunctionCallParen (*Next)) {
841
- return true ;
842
- }
852
+ (IsFunctionDeclParen (*Previous) || IsFunctionCallParen (*Previous) ||
853
+ IsLambdaParameterList (Previous))) {
854
+ return !IsOpeningBracket (Tok) && Next && !Next->isMemberAccess () &&
855
+ !IsInTemplateString (Tok) && !IsFunctionDeclParen (*Next) &&
856
+ !IsFunctionCallParen (*Next);
843
857
}
844
858
return false ;
845
859
};
0 commit comments