Author: krasimir Date: Wed Mar 7 13:30:38 2018 New Revision: 326945 URL: http://llvm.org/viewvc/llvm-project?rev=326945&view=rev Log: [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 Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp cfe/trunk/unittests/Format/FormatTestTextProto.cpp Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=326945&r1=326944&r2=326945&view=diff ============================================================================== --- cfe/trunk/lib/Format/TokenAnnotator.cpp (original) +++ cfe/trunk/lib/Format/TokenAnnotator.cpp Wed Mar 7 13:30:38 2018 @@ -2717,7 +2717,8 @@ bool TokenAnnotator::mustBreakBefore(con 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; } Modified: cfe/trunk/unittests/Format/FormatTestTextProto.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestTextProto.cpp?rev=326945&r1=326944&r2=326945&view=diff ============================================================================== --- cfe/trunk/unittests/Format/FormatTestTextProto.cpp (original) +++ cfe/trunk/unittests/Format/FormatTestTextProto.cpp Wed Mar 7 13:30:38 2018 @@ -452,5 +452,11 @@ TEST_F(FormatTestTextProto, AcceptsOpera " >\n" ">"); } + +TEST_F(FormatTestTextProto, BreaksConsecutiveStringLiterals) { + verifyFormat("ala: \"str1\"\n" + " \"str2\"\n"); +} + } // end namespace tooling } // end namespace clang _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits