[clang-format] Mark constexpr lambdas as lambda

Otherwise the brace was detected as a function brace, not wrong per se,
but when directly calling the lambda the calling parens were put on the
next line.

Differential Revision: https://reviews.llvm.org/D129946
This commit is contained in:
Björn Schäpers 2022-07-16 23:46:18 +02:00
parent 3c18a8b3a3
commit d2eda49202
2 changed files with 8 additions and 0 deletions

View file

@ -2119,6 +2119,7 @@ bool UnwrappedLineParser::tryToParseLambda() {
case tok::amp:
case tok::star:
case tok::kw_const:
case tok::kw_constexpr:
case tok::comma:
case tok::less:
case tok::greater:

View file

@ -894,6 +894,13 @@ TEST_F(TokenAnnotatorTest, UnderstandsObjCBlock) {
EXPECT_TOKEN(Tokens[9], tok::l_brace, TT_ObjCBlockLBrace);
}
TEST_F(TokenAnnotatorTest, UnderstandsLambdas) {
auto Tokens = annotate("[]() constexpr {}");
ASSERT_EQ(Tokens.size(), 8u) << Tokens;
EXPECT_TOKEN(Tokens[0], tok::l_square, TT_LambdaLSquare);
EXPECT_TOKEN(Tokens[5], tok::l_brace, TT_LambdaLBrace);
}
} // namespace
} // namespace format
} // namespace clang