diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 4bc624db7dd1..de7e646b17cf 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -1442,6 +1442,8 @@ bool UnwrappedLineParser::tryToParseLambda() { case tok::lessequal: case tok::question: case tok::colon: + case tok::kw_true: + case tok::kw_false: nextToken(); break; case tok::arrow: diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 094db349ae1e..650636b76339 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -11936,6 +11936,21 @@ TEST_F(FormatTest, FormatsLambdas) { "// broken:\n" "auto foo{[]() -> foo<2 ? 1 : 0> { return {}; }};\n" "} // namespace bar"); + verifyFormat("[]() -> a<1> {};"); + verifyFormat("[]() -> a<1> { ; };"); + verifyFormat("[]() -> a<1> { ; }();"); + verifyFormat("[a, a]() -> a {};"); + verifyFormat("[]() -> a {};"); + verifyFormat("[]() -> a { ; };"); + verifyFormat("[]() -> a { ; }();"); + verifyFormat("[a, a]() -> a {};"); + verifyFormat("[]() -> a {};"); + verifyFormat("[]() -> a { ; };"); + verifyFormat("[]() -> a { ; }();"); + verifyFormat("auto foo{[]() -> foo { ; }};"); + verifyFormat("namespace bar {\n" + "auto foo{[]() -> foo { ; }};\n" + "} // namespace bar"); verifyFormat("auto aaaaaaaa = [](int i, // break for some reason\n" " int j) -> int {\n" " return ffffffffffffffffffffffffffffffffffffffffffff(i * j);\n"