[PATCH] D11693: clang-format: Support generalized lambda captures.

strager via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 17 13:00:16 PDT 2015


strager marked 2 inline comments as done.

================
Comment at: lib/Format/UnwrappedLineParser.cpp:1060-1061
@@ +1059,4 @@
+      nextToken();
+      while (!eof()) {
+        // FIXME: Once we have an expression parser in the UnwrappedLineParser,
+        // replace this by using parseAssigmentExpression() inside. See also
----------------
djasper wrote:
> Again, please remove the FIXME. We aren't going to have an expression parser here (anytime soon) and shouldn't add (more) comments that make people think otherwise.
> We aren't going to have an expression parser here (anytime soon) and shouldn't add (more) comments that make people think otherwise.

If there is enough need for the function, perhaps it will be written.

I don't think the comment implies some code will be written soon.

================
Comment at: lib/Format/UnwrappedLineParser.cpp:1064
@@ +1063,3 @@
+        // parseBracedList. For now, parsing matching braces ([], (), {}) is
+        // good enough.
+        if (FormatTok->is(tok::l_paren)) {
----------------
djasper wrote:
> Ah, parseAngle doesn't exist here. I was thinking about the TokenAnnotator.
> 
> I don't understand your comment about mid-stream. This is precisely about the case where the input is corrupt so that clang-format can recover and doesn't just parse the reset of the file input the lambda introducer.
> This is precisely about the case where the input is corrupt so that clang-format can recover and doesn't just parse the reset of the file input the lambda introducer.

If I write this test:

```
verifyFormat("return [}] {};\n");
```

I get this output:

```
/Users/strager/Projects/llvm/tools/clang/unittests/Format/FormatTest.cpp:42: Failure
Value of: IncompleteFormat
  Actual: true
Expected: ExpectedIncompleteFormat
Which is: false
return [}] {};



/Users/strager/Projects/llvm/tools/clang/unittests/Format/FormatTest.cpp:65: Failure
Value of: format(test::messUp(Code), Style)
  Actual: "return [\n}] {};\n"
Expected: Code.str()
Which is: "return [}] {};\n"
```

How can I fix this?


http://reviews.llvm.org/D11693





More information about the cfe-commits mailing list