[clang] [clang-format] Don't break between string literal operands of << (PR #69871)
Owen Pan via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 24 01:35:35 PDT 2023
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/69871
>From d12aee14e9d588c402e69e49aa9b33be7f940acb Mon Sep 17 00:00:00 2001
From: Owen Pan <owenpiano at gmail.com>
Date: Sun, 22 Oct 2023 01:36:17 -0700
Subject: [PATCH] [clang-format] Don't break between string literal operands of
<<
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 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 d5711782a23ef5b..176fe87c979cd2d 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -26478,6 +26478,10 @@ TEST_F(FormatTest, PPBranchesInBracedInit) {
"};");
}
+TEST_F(FormatTest, StreamOutputOperator) {
+ verifyFormat("std::cout << \"foo\" << \"bar\" << baz;");
+}
+
} // namespace
} // namespace test
} // namespace format
More information about the cfe-commits
mailing list