[PATCH] D134587: [clang-format] Correctly annotate static and consteval lambdas
Emilia Dreamer via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Sep 25 11:16:15 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7847225576d5: [clang-format] Correctly annotate static and consteval lambdas (authored by rymiel).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D134587/new/
https://reviews.llvm.org/D134587
Files:
clang/lib/Format/UnwrappedLineParser.cpp
clang/unittests/Format/TokenAnnotatorTest.cpp
Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===================================================================
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -837,6 +837,21 @@
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);
Index: clang/lib/Format/UnwrappedLineParser.cpp
===================================================================
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2230,6 +2230,7 @@
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 @@
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134587.462741.patch
Type: text/x-patch
Size: 1772 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220925/5fb56b72/attachment.bin>
More information about the cfe-commits
mailing list