[PATCH] D44204: [clang-format] Break consecutive string literals in text protos

Krasimir Georgiev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 7 05:34:28 PST 2018


krasimir created this revision.
Herald added subscribers: cfe-commits, klimek.

This patch fixes a bug where consecutive string literals in text protos were
put on the same line.


Repository:
  rC Clang

https://reviews.llvm.org/D44204

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTestTextProto.cpp


Index: unittests/Format/FormatTestTextProto.cpp
===================================================================
--- unittests/Format/FormatTestTextProto.cpp
+++ unittests/Format/FormatTestTextProto.cpp
@@ -452,5 +452,11 @@
                "  >\n"
                ">");
 }
+
+TEST_F(FormatTestTextProto, BreaksConsecutiveStringLiterals) {
+  verifyFormat("ala: \"str1\"\n"
+               "     \"str2\"\n");
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: lib/Format/TokenAnnotator.cpp
===================================================================
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2717,7 +2717,8 @@
       return true;
   } else if (Style.Language == FormatStyle::LK_Cpp ||
              Style.Language == FormatStyle::LK_ObjC ||
-             Style.Language == FormatStyle::LK_Proto) {
+             Style.Language == FormatStyle::LK_Proto ||
+             Style.Language == FormatStyle::LK_TextProto) {
     if (Left.isStringLiteral() && Right.isStringLiteral())
       return true;
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44204.137368.patch
Type: text/x-patch
Size: 1057 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180307/0221ad4a/attachment.bin>


More information about the cfe-commits mailing list