diff options
| -rw-r--r-- | clang/lib/Format/UnwrappedLineParser.cpp | 6 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 3 |
2 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 13b9847527a..5029bd689bc 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -674,6 +674,12 @@ void UnwrappedLineParser::parseStructuralElement() { } void UnwrappedLineParser::tryToParseLambda() { + // FIXME: This is a dirty way to access the previous token. Find a better + // solution. + if (!Line->Tokens.empty() && Line->Tokens.back().Tok->is(tok::identifier)) { + nextToken(); + return; + } assert(FormatTok->is(tok::l_square)); FormatToken &LSquare = *FormatTok; if (!tryToParseLambdaIntroducer()) diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 5e5a579ddbb..4c66ef0c281 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -6300,6 +6300,9 @@ TEST_F(FormatTest, FormatsLambdas) { " x.end(), //\n" " [&](int, int) { return 1; });\n" "}\n"); + + // Not lambdas. + verifyFormat("constexpr char hello[]{ \"hello\" };"); } TEST_F(FormatTest, FormatsBlocks) { |

