Author: Owen Pan Date: 2023-10-24T02:42:39-07:00 New Revision: d68826dfbd987377ef6771d40c1d984f09ee3b9e
URL: https://github.com/llvm/llvm-project/commit/d68826dfbd987377ef6771d40c1d984f09ee3b9e DIFF: https://github.com/llvm/llvm-project/commit/d68826dfbd987377ef6771d40c1d984f09ee3b9e.diff LOG: [clang-format] Don't break between string literal operands of << (#69871) Fixes #44363. Added: Modified: clang/lib/Format/TokenAnnotator.cpp clang/unittests/Format/FormatTest.cpp Removed: ################################################################################ diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 4a7378c24cda57b..e0ea8bcdb07a32b 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -5117,10 +5117,6 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line, return true; if (Left.IsUnterminatedLiteral) return true; - if (Right.is(tok::lessless) && Right.Next && Left.is(tok::string_literal) && - Right.Next->is(tok::string_literal)) { - return true; - } if (Right.is(TT_RequiresClause)) { switch (Style.RequiresClausePosition) { case FormatStyle::RCPS_OwnLine: diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 02447dec840e367..8329daa7665949c 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -26468,6 +26468,10 @@ TEST_F(FormatTest, PPBranchesInBracedInit) { "};"); } +TEST_F(FormatTest, StreamOutputOperator) { + verifyFormat("std::cout << \"foo\" << \"bar\" << baz;"); +} + } // namespace } // namespace test } // namespace format _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits