[llvm] [clang-format] Don't break between string literal operands of << (PR #69871)
Owen Pan via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 23 13:28:26 PDT 2023
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/69871
>From fc955bc2730b52093d1e6d2bdd2dbf0400879edf 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 7f85f48de2ed2ed..e185afaa2885123 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -5118,10 +5118,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 0a87cfc4f1d6af9..0841ea1bcb66fa9 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -26459,6 +26459,10 @@ TEST_F(FormatTest, AllowBreakBeforeNoexceptSpecifier) {
Style);
}
+TEST_F(FormatTest, StreamOutputOperator) {
+ verifyFormat("std::cout << \"foo\" << \"bar\" << baz;");
+}
+
} // namespace
} // namespace test
} // namespace format
More information about the llvm-commits
mailing list