[PATCH] D129946: [clang-format] Mark constexpr lambdas as lambda
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGd2eda4920238: [clang-format] Mark constexpr lambdas as lambda (authored by HazardyKnusperkeks). Changed prior to commit: https://reviews.llvm.org/D129946?vs=445267=445601#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D129946/new/ https://reviews.llvm.org/D129946 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 @@ -894,6 +894,13 @@ 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 Index: clang/lib/Format/UnwrappedLineParser.cpp === --- clang/lib/Format/UnwrappedLineParser.cpp +++ clang/lib/Format/UnwrappedLineParser.cpp @@ -2119,6 +2119,7 @@ case tok::amp: case tok::star: case tok::kw_const: +case tok::kw_constexpr: case tok::comma: case tok::less: case tok::greater: Index: clang/unittests/Format/TokenAnnotatorTest.cpp === --- clang/unittests/Format/TokenAnnotatorTest.cpp +++ clang/unittests/Format/TokenAnnotatorTest.cpp @@ -894,6 +894,13 @@ 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 Index: clang/lib/Format/UnwrappedLineParser.cpp === --- clang/lib/Format/UnwrappedLineParser.cpp +++ clang/lib/Format/UnwrappedLineParser.cpp @@ -2119,6 +2119,7 @@ case tok::amp: case tok::star: case tok::kw_const: +case tok::kw_constexpr: case tok::comma: case tok::less: case tok::greater: ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D129946: [clang-format] Mark constexpr lambdas as lambda
HazardyKnusperkeks added inline comments. Comment at: clang/lib/Format/UnwrappedLineParser.cpp:2130 case tok::kw_noexcept: +case tok::kw_constexpr: nextToken(); owenpan wrote: > Maybe move it up so that it's grouped with `kw_const`? Will do before submit. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D129946/new/ https://reviews.llvm.org/D129946 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D129946: [clang-format] Mark constexpr lambdas as lambda
owenpan accepted this revision. owenpan added inline comments. This revision is now accepted and ready to land. Comment at: clang/lib/Format/UnwrappedLineParser.cpp:2130 case tok::kw_noexcept: +case tok::kw_constexpr: nextToken(); Maybe move it up so that it's grouped with `kw_const`? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D129946/new/ https://reviews.llvm.org/D129946 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D129946: [clang-format] Mark constexpr lambdas as lambda
HazardyKnusperkeks created this revision. HazardyKnusperkeks added reviewers: owenpan, MyDeveloperDay, curdeius, eoanermine. HazardyKnusperkeks added a project: clang-format. Herald added a project: All. HazardyKnusperkeks requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. 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. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D129946 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 @@ -894,6 +894,13 @@ 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 Index: clang/lib/Format/UnwrappedLineParser.cpp === --- clang/lib/Format/UnwrappedLineParser.cpp +++ clang/lib/Format/UnwrappedLineParser.cpp @@ -2127,6 +2127,7 @@ case tok::coloncolon: case tok::kw_mutable: case tok::kw_noexcept: +case tok::kw_constexpr: nextToken(); break; // Specialization of a template with an integer parameter can contain Index: clang/unittests/Format/TokenAnnotatorTest.cpp === --- clang/unittests/Format/TokenAnnotatorTest.cpp +++ clang/unittests/Format/TokenAnnotatorTest.cpp @@ -894,6 +894,13 @@ 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 Index: clang/lib/Format/UnwrappedLineParser.cpp === --- clang/lib/Format/UnwrappedLineParser.cpp +++ clang/lib/Format/UnwrappedLineParser.cpp @@ -2127,6 +2127,7 @@ case tok::coloncolon: case tok::kw_mutable: case tok::kw_noexcept: +case tok::kw_constexpr: nextToken(); break; // Specialization of a template with an integer parameter can contain ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits