r223652 - clang-format: Support commas in lambda return types.

Daniel Jasper djasper at google.com
Mon Dec 8 05:22:39 PST 2014


Author: djasper
Date: Mon Dec  8 07:22:37 2014
New Revision: 223652

URL: http://llvm.org/viewvc/llvm-project?rev=223652&view=rev
Log:
clang-format: Support commas in lambda return types.

Before:
  auto next_pair = [](A * a) -> pair<A*, A*>{};

After:
  auto next_pair = [](A* a) -> pair<A*, A*>{};

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=223652&r1=223651&r2=223652&view=diff
==============================================================================
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Mon Dec  8 07:22:37 2014
@@ -880,6 +880,7 @@ bool UnwrappedLineParser::tryToParseLamb
     case tok::amp:
     case tok::star:
     case tok::kw_const:
+    case tok::comma:
     case tok::less:
     case tok::greater:
     case tok::identifier:

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=223652&r1=223651&r2=223652&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Dec  8 07:22:37 2014
@@ -9378,6 +9378,7 @@ TEST_F(FormatTest, FormatsLambdas) {
   verifyFormat("int c = []() -> vector<int> { return {2}; }();\n");
   verifyFormat("Foo([]() -> std::vector<int> { return {2}; }());");
   verifyGoogleFormat("auto a = [&b, c](D* d) -> D* {};");
+  verifyGoogleFormat("auto a = [&b, c](D* d) -> pair<D*, D*> {};");
   verifyGoogleFormat("auto a = [&b, c](D* d) -> D& {};");
   verifyGoogleFormat("auto a = [&b, c](D* d) -> const D* {};");
   verifyFormat("auto aaaaaaaa = [](int i, // break for some reason\n"





More information about the cfe-commits mailing list