summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKrasimir Georgiev <krasimir@google.com>2018-03-07 21:30:38 +0000
committerKrasimir Georgiev <krasimir@google.com>2018-03-07 21:30:38 +0000
commit9ad7af64232488ec7c8b4801486051ccdceeead2 (patch)
treeb5efd4823863c4f973b97f025d092ef9cb9589f3
parentd8139348fbd485392dae2720015c491260c21767 (diff)
downloadbcm5719-llvm-9ad7af64232488ec7c8b4801486051ccdceeead2.tar.gz
bcm5719-llvm-9ad7af64232488ec7c8b4801486051ccdceeead2.zip
[clang-format] Break consecutive string literals in text protos
Summary: This patch fixes a bug where consecutive string literals in text protos were put on the same line. Reviewers: alexfh Reviewed By: alexfh Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D44204 llvm-svn: 326945
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp3
-rw-r--r--clang/unittests/Format/FormatTestTextProto.cpp6
2 files changed, 8 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 013a77b4c59..97a201d267e 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -2717,7 +2717,8 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line,
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;
}
diff --git a/clang/unittests/Format/FormatTestTextProto.cpp b/clang/unittests/Format/FormatTestTextProto.cpp
index 1102055ea37..39a2e71cbbd 100644
--- a/clang/unittests/Format/FormatTestTextProto.cpp
+++ b/clang/unittests/Format/FormatTestTextProto.cpp
@@ -452,5 +452,11 @@ TEST_F(FormatTestTextProto, AcceptsOperatorAsKey) {
" >\n"
">");
}
+
+TEST_F(FormatTestTextProto, BreaksConsecutiveStringLiterals) {
+ verifyFormat("ala: \"str1\"\n"
+ " \"str2\"\n");
+}
+
} // end namespace tooling
} // end namespace clang
OpenPOWER on IntegriCloud