forked from OSchip/llvm-project
[clang-format] Correctly annotate static and consteval lambdas
`P1169` "static operator()" (https://wg21.link/P1169) is accepted to C++23 and while clang itself doesn't exactly support it yet, clang-format could quite easily. This simply allows the keyword `static` to be a part of lambdas as specified by the addition to [expr.prim.lambda.general] While adding this, I noticed `consteval` lambdas also aren't handled, so that keyword is now allowed to be a part of lambdas as well Reviewed By: HazardyKnusperkeks, owenpan, MyDeveloperDay Differential Revision: https://reviews.llvm.org/D134587
This commit is contained in:
parent
bcb1397bda
commit
7847225576
|
@ -2230,6 +2230,7 @@ bool UnwrappedLineParser::tryToParseLambda() {
|
|||
case tok::star:
|
||||
case tok::kw_const:
|
||||
case tok::kw_constexpr:
|
||||
case tok::kw_consteval:
|
||||
case tok::comma:
|
||||
case tok::greater:
|
||||
case tok::identifier:
|
||||
|
@ -2237,6 +2238,7 @@ bool UnwrappedLineParser::tryToParseLambda() {
|
|||
case tok::coloncolon:
|
||||
case tok::kw_mutable:
|
||||
case tok::kw_noexcept:
|
||||
case tok::kw_static:
|
||||
nextToken();
|
||||
break;
|
||||
// Specialization of a template with an integer parameter can contain
|
||||
|
|
|
@ -837,6 +837,21 @@ TEST_F(TokenAnnotatorTest, UnderstandsLambdas) {
|
|||
EXPECT_TOKEN(Tokens[0], tok::l_square, TT_LambdaLSquare);
|
||||
EXPECT_TOKEN(Tokens[5], tok::l_brace, TT_LambdaLBrace);
|
||||
|
||||
Tokens = annotate("[]() consteval {}");
|
||||
ASSERT_EQ(Tokens.size(), 8u) << Tokens;
|
||||
EXPECT_TOKEN(Tokens[0], tok::l_square, TT_LambdaLSquare);
|
||||
EXPECT_TOKEN(Tokens[5], tok::l_brace, TT_LambdaLBrace);
|
||||
|
||||
Tokens = annotate("[]() mutable {}");
|
||||
ASSERT_EQ(Tokens.size(), 8u) << Tokens;
|
||||
EXPECT_TOKEN(Tokens[0], tok::l_square, TT_LambdaLSquare);
|
||||
EXPECT_TOKEN(Tokens[5], tok::l_brace, TT_LambdaLBrace);
|
||||
|
||||
Tokens = annotate("[]() static {}");
|
||||
ASSERT_EQ(Tokens.size(), 8u) << Tokens;
|
||||
EXPECT_TOKEN(Tokens[0], tok::l_square, TT_LambdaLSquare);
|
||||
EXPECT_TOKEN(Tokens[5], tok::l_brace, TT_LambdaLBrace);
|
||||
|
||||
Tokens = annotate("[]() -> auto {}");
|
||||
ASSERT_EQ(Tokens.size(), 9u) << Tokens;
|
||||
EXPECT_TOKEN(Tokens[0], tok::l_square, TT_LambdaLSquare);
|
||||
|
|
Loading…
Reference in New Issue