From: Daniel Jasper Date: Tue, 10 Jun 2014 06:39:03 +0000 (+0000) Subject: clang-format: Support variadic lambda captures. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a84adb5368b30f73d2a413fb859aa93e523456db;p=clang clang-format: Support variadic lambda captures. Before: return [ i, args... ]{}; After: return [i, args...] {}; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@210514 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp index d0750af1b0..6a8156f92e 100644 --- a/lib/Format/UnwrappedLineParser.cpp +++ b/lib/Format/UnwrappedLineParser.cpp @@ -891,6 +891,8 @@ bool UnwrappedLineParser::tryToParseLambdaIntroducer() { if (!FormatTok->isOneOf(tok::identifier, tok::kw_this)) return false; nextToken(); + if (FormatTok->is(tok::ellipsis)) + nextToken(); if (FormatTok->is(tok::comma)) { nextToken(); } else if (FormatTok->is(tok::r_square)) { diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 584ecba986..02636a7016 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -8709,6 +8709,9 @@ TEST_F(FormatTest, FormatsLambdas) { " return j;\n" " });"); + // More complex introducers. + verifyFormat("return [i, args...] {};"); + // Not lambdas. verifyFormat("constexpr char hello[]{\"hello\"};"); verifyFormat("double &operator[](int i) { return 0; }\n"