From d68826dfbd987377ef6771d40c1d984f09ee3b9e Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Tue, 24 Oct 2023 02:42:39 -0700 Subject: [PATCH] [clang-format] Don't break between string literal operands of << (#69871) Fixes #44363. --- clang/lib/Format/TokenAnnotator.cpp | 4 ---- clang/unittests/Format/FormatTest.cpp | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 4a7378c24cda57..e0ea8bcdb07a32 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 02447dec840e36..8329daa7665949 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