Index: lib/Format/UnwrappedLineParser.cpp =================================================================== --- lib/Format/UnwrappedLineParser.cpp +++ lib/Format/UnwrappedLineParser.cpp @@ -1051,6 +1051,20 @@ nextToken(); if (FormatTok->is(tok::ellipsis)) nextToken(); + if (FormatTok->is(tok::equal)) { + nextToken(); + while (!eof()) { + // FIXME: Once we have an expression parser in the UnwrappedLineParser, + // replace this by using parseAssigmentExpression() inside. + if (FormatTok->is(tok::l_paren)) { + parseParens(); + } else if (FormatTok->isOneOf(tok::comma, tok::r_square)) { + break; + } else { + nextToken(); + } + } + } if (FormatTok->is(tok::comma)) { nextToken(); } else if (FormatTok->is(tok::r_square)) { Index: unittests/Format/FormatTest.cpp =================================================================== --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -9981,6 +9981,11 @@ // More complex introducers. verifyFormat("return [i, args...] {};"); + // Lambdas with generalized captures. + verifyFormat("auto f = [b = d]() {};\n"); + verifyFormat("auto f = [b = std::move(d)]() {};\n"); + verifyFormat("auto f = [b = c, d = e, g]() {};\n"); + // Not lambdas. verifyFormat("constexpr char hello[]{\"hello\"};"); verifyFormat("double &operator[](int i) { return 0; }\n"