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) {


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) {
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D36217: Fix pars... Krasimir Georgiev via Phabricator via cfe-commits
    • [PATCH] D36217: [cl... Krasimir Georgiev via Phabricator via cfe-commits

Reply via email to