[clang] [clang-format] Don't break between string literal operands of << (PR #69871)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Oct 22 01:41:08 PDT 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-format
Author: Owen Pan (owenca)
<details>
<summary>Changes</summary>
Fixes #<!-- -->44363.
---
Full diff: https://github.com/llvm/llvm-project/pull/69871.diff
2 Files Affected:
- (modified) clang/lib/Format/TokenAnnotator.cpp (-4)
- (modified) clang/unittests/Format/FormatTest.cpp (+4)
``````````diff
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
``````````
</details>
https://github.com/llvm/llvm-project/pull/69871
More information about the cfe-commits
mailing list