[clang] [clang-format] unexpected break after binOp '<<' (PR #69859)
Tsarkov Maksim via cfe-commits
cfe-commits at lists.llvm.org
Sat Oct 21 16:21:32 PDT 2023
https://github.com/s1Sharp created https://github.com/llvm/llvm-project/pull/69859
the problem occurred while checking for the correctness of the break after binary operators. The output statement 'tok::lessless' is then break line every possible time, which is not expected with the BreakBeforeBinaryOperators: None
>From 383d1acd4a5726296b09681103874f071529dacc Mon Sep 17 00:00:00 2001
From: Tsarkov Maksim <mtsarkov at naumen.ru>
Date: Sun, 22 Oct 2023 02:09:21 +0300
Subject: [PATCH] [clang-format] unexpected break after binOp '<<'
the problem occurred while checking for the correctness of the break after binary operators.
The output statement 'tok::lessless' is then break line every possible time,
which is not expected with the BreakBeforeBinaryOperators: None
---
clang/lib/Format/TokenAnnotator.cpp | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 7f85f48de2ed2ed..6db1e826e11d234 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -5119,7 +5119,9 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line,
if (Left.IsUnterminatedLiteral)
return true;
if (Right.is(tok::lessless) && Right.Next && Left.is(tok::string_literal) &&
- Right.Next->is(tok::string_literal)) {
+ Right.Next->is(tok::string_literal) &&
+ (Style.BreakBeforeBinaryOperators == FormatStyle::BOS_All ||
+ Style.BreakBeforeBinaryOperators == FormatStyle::BOS_NonAssignment)) {
return true;
}
if (Right.is(TT_RequiresClause)) {
More information about the cfe-commits
mailing list