[PATCH] D36217: [clang-format] Fix parsing of <>-style proto options

Krasimir Georgiev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 3 06:44:42 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL309937: [clang-format] Fix parsing of <>-style proto options (authored by krasimir).

Repository:
  rL LLVM

https://reviews.llvm.org/D36217

Files:
  cfe/trunk/lib/Format/UnwrappedLineParser.cpp
  cfe/trunk/unittests/Format/FormatTestProto.cpp


Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===================================================================
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -1450,6 +1450,15 @@
       nextToken();
       parseBracedList();
       break;
+    case tok::less:
+      if (Style.Language == FormatStyle::LK_Proto) {
+        nextToken();
+        parseBracedList(/*ContinueOnSemicolons=*/false,
+                        /*ClosingBraceKind=*/tok::greater);
+      } else {
+        nextToken();
+      }
+      break;
     case tok::semi:
       // JavaScript (or more precisely TypeScript) can have semicolons in braced
       // lists (in so-called TypeMemberLists). Thus, the semicolon cannot be
Index: cfe/trunk/unittests/Format/FormatTestProto.cpp
===================================================================
--- cfe/trunk/unittests/Format/FormatTestProto.cpp
+++ cfe/trunk/unittests/Format/FormatTestProto.cpp
@@ -356,6 +356,11 @@
                "  }\n"
                "  field_g: OK\n"
                ">;");
+
+  verifyFormat("option (MyProto.options) = <\n"
+               "  data1 <key1: value1>\n"
+               "  data2 {key2: value2}\n"
+               ">;");
 }
 
 TEST_F(FormatTestProto, FormatsService) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36217.109544.patch
Type: text/x-patch
Size: 1292 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170803/16f02eee/attachment.bin>


More information about the cfe-commits mailing list