[PATCH] D52676: [clang-format] tweaked another case of lambda formatting

Krasimir Georgiev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 22 14:53:30 PDT 2018


krasimir added inline comments.


================
Comment at: unittests/Format/FormatTest.cpp:11604
+               "      x.end(),   //\n"
+               "      [&](int, int) { return 1; });\n"
                "}\n");
----------------
This looks a bit suspicious: I'd expect a break before the first arg to be forced only when there exists a multiline (after formatting) lambda expression arg. Is this (multiline vs. lambdas fitting 1 line) something that we (can) differentiate with respect to? djasper@ might have an insight on this.


================
Comment at: unittests/Format/FormatTest.cpp:11657
                "}});");
-  verifyFormat("virtual aaaaaaaaaaaaaaaa(std::function<bool()> bbbbbbbbbbbb =\n"
-               "                             [&]() { return true; },\n"
-               "                         aaaaa aaaaaaaaa);");
+  verifyFormat("virtual aaaaaaaaaaaaaaaa(\n"
+               "    std::function<bool()> bbbbbbbbbbbb = [&]() { return true; },\n"
----------------
Similar to my previous comment, this forcing the std::function on a newline here might not be what we want to end up with?


================
Comment at: unittests/Format/FormatTest.cpp:11736
+  // line and there are no further args.
+  verifyFormat("function(1, [this, that] {\n"
+               "  //\n"
----------------
Could we please have a test case where there are several args packed on the first line, then a line break, then an arg, then a multiline lambda as a last arg (illustrating that we don't pull the first arg down if there's only a multiline lambda as the last arg):
```
function(a, b, ccccccc,
         d, [] () {
  body
});
```


Repository:
  rC Clang

https://reviews.llvm.org/D52676





More information about the cfe-commits mailing list