r210514 - clang-format: Support variadic lambda captures.

Daniel Jasper djasper at google.com
Mon Jun 9 23:39:05 PDT 2014


Author: djasper
Date: Tue Jun 10 01:39:03 2014
New Revision: 210514

URL: http://llvm.org/viewvc/llvm-project?rev=210514&view=rev
Log:
clang-format: Support variadic lambda captures.

Before:
  return [ i, args... ]{};

After:
  return [i, args...] {};

Modified:
    cfe/trunk/lib/Format/UnwrappedLineParser.cpp
    cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=210514&r1=210513&r2=210514&view=diff
==============================================================================
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Tue Jun 10 01:39:03 2014
@@ -891,6 +891,8 @@ bool UnwrappedLineParser::tryToParseLamb
     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)) {

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=210514&r1=210513&r2=210514&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Tue Jun 10 01:39:03 2014
@@ -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"





More information about the cfe-commits mailing list