diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index ed72acf613b6..daf185be519e 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -758,8 +758,8 @@ bool 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->isOneOf(tok::identifier, tok::kw_operator, - tok::r_square) || + (Line->Tokens.back().Tok->isOneOf(tok::identifier, tok::kw_operator) || + Line->Tokens.back().Tok->closesScope() || Line->Tokens.back().Tok->isSimpleTypeSpecifier())) { nextToken(); return false; diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 75dc57d4e798..c6968bcef9e3 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -7981,6 +7981,7 @@ TEST_F(FormatTest, FormatsLambdas) { "int i;"); verifyFormat("std::unique_ptr foo() {}"); verifyFormat("int i = a[a][a]->f();"); + verifyFormat("int i = (*b)[a]->f();"); // Other corner cases. verifyFormat("void f() {\n"