[clang] [clang-format] revert to string << string handling to previous default (PR #88490)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Apr 13 04:22:37 PDT 2024
================
@@ -5598,10 +5598,34 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line,
// FIXME: Breaking after newlines seems useful in general. Turn this into an
// option and recognize more cases like endl etc, and break independent of
// what comes after operator lessless.
- if (Right.is(tok::lessless) && Right.Next &&
- Right.Next->is(tok::string_literal) && Left.is(tok::string_literal) &&
- Left.TokenText.ends_with("\\n\"")) {
- return true;
+ if (Style.BreakChevronOperator == FormatStyle::BCOS_BetweenStrings) {
+ if (Right.is(tok::lessless) && Right.Next && Left.is(tok::string_literal) &&
+ Right.Next->is(tok::string_literal)) {
+ return true;
+ }
+ }
+ if (Style.BreakChevronOperator == FormatStyle::BCOS_BetweenNewlineStrings) {
+ if (Right.is(tok::lessless) && Right.Next &&
+ Right.Next->is(tok::string_literal) && Left.is(tok::string_literal) &&
+ Left.TokenText.ends_with("\\n\"")) {
+ return true;
+ }
+ }
+ if (Style.BreakChevronOperator == FormatStyle::BCOS_Always) {
+ // can be std::os or os
----------------
mydeveloperday wrote:
when you have
os << "A"
<< "B"
you don't want to break between os and << so the loop tracks back to determine if this is the first << in the line, this must also handle std::os << and a::b::os etc.. whats its really saying is don't break before the first <<.
https://github.com/llvm/llvm-project/pull/88490
More information about the cfe-commits
mailing list