[PATCH] D18793: fix for 19986, extra spacing around c++14 lambda capture with initializer

Jacek Sieka via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 5 07:46:09 PDT 2016


arnetheduck created this revision.
arnetheduck added a reviewer: djasper.
arnetheduck added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

Here's a little one-off patch that fixes
https://llvm.org/bugs/show_bug.cgi?id=19986 for me, by allowing a few
more things inside [] when trying to match a lambda capture section.

I hope someone can help it find its way into the main repo.


http://reviews.llvm.org/D18793

Files:
  lib/Format/UnwrappedLineParser.cpp

Index: lib/Format/UnwrappedLineParser.cpp
===================================================================
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -1080,8 +1080,25 @@
     if (!FormatTok->isOneOf(tok::identifier, tok::kw_this))
       return false;
     nextToken();
-    if (FormatTok->is(tok::ellipsis))
+    if (FormatTok->is(tok::equal)) {
       nextToken();
+      int parens = 0;
+      while (!eof()) {
+        if (FormatTok->isOneOf(tok::l_paren, tok::l_square)) {
+          ++parens;
+        } else if (parens && FormatTok->isOneOf(tok::r_paren, tok::r_square)) {
+          --parens;
+        } else if (FormatTok->isOneOf(tok::comma, tok::r_square)) {
+          break;
+        } else if (!FormatTok->isOneOf(tok::identifier, tok::coloncolon)) {
+          return false;
+        }
+
+        nextToken();
+      }
+    } else if (FormatTok->is(tok::ellipsis)) {
+      nextToken();
+    }
     if (FormatTok->is(tok::comma)) {
       nextToken();
     } else if (FormatTok->is(tok::r_square)) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18793.52691.patch
Type: text/x-patch
Size: 1056 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160405/6c39b7cb/attachment.bin>


More information about the cfe-commits mailing list