[clang] [clang-format] Break after string literals with trailing line breaks (PR #76795)
Björn Schäpers via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 4 08:59:59 PST 2024
================
@@ -5151,6 +5151,14 @@ 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) &&
+ // 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.
+ Right.Next->is(tok::string_literal) &&
+ Left.TokenText.ends_with("\\n\"")) {
----------------
HazardyKnusperkeks wrote:
```suggestion
if (Left.is(tok::string_literal) && Left.TokenText.ends_with("\\n\"") && Right.is(tok::lessless) &&
Right.Next && Right.Next->is(tok::string_literal) ) {
// 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.
```
Or similar, right now it is a bit unsorted. (This is obviously not formatted.)
https://github.com/llvm/llvm-project/pull/76795
More information about the cfe-commits
mailing list