]> granicus.if.org Git - clang/commitdiff
clang-format: Support commas in lambda return types.
authorDaniel Jasper <djasper@google.com>
Mon, 8 Dec 2014 13:22:37 +0000 (13:22 +0000)
committerDaniel Jasper <djasper@google.com>
Mon, 8 Dec 2014 13:22:37 +0000 (13:22 +0000)
Before:
  auto next_pair = [](A * a) -> pair<A*, A*>{};

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@223652 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/UnwrappedLineParser.cpp
unittests/Format/FormatTest.cpp

index d0c899ffe0b0577bce5b4c804a4acf50724bf5ec..6ff5405a1b4393aa8ad1a545fbb6012f93f992de 100644 (file)
@@ -880,6 +880,7 @@ bool UnwrappedLineParser::tryToParseLambda() {
     case tok::amp:
     case tok::star:
     case tok::kw_const:
+    case tok::comma:
     case tok::less:
     case tok::greater:
     case tok::identifier:
index 8664711aa0703fa9f1827bbb5959c8c9ff2d6050..7ca7978fd19d16ce2ad31e04f4d7c02c1711dc45 100644 (file)
@@ -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"