[clang] [clang-format] Don't always break before << between string literals (PR #92214)

Owen Pan via cfe-commits cfe-commits at lists.llvm.org
Wed May 15 22:06:22 PDT 2024


owenca wrote:

> This is interesting.. I like it in that its a "Leave" ... but part of me would like this choice of default behind an option. As with the previous changes in this area I'm uncomfortable about us changing how it behaves, but would like the extra capability to choose.. I'm going to say Approve, but I'm interested in your opinion about if we SHOULD have an option or not?

I don't think it warrants an option. (If an option is to be added in the future, the default should be `Leave`.) This is because whether to break before a `<<` that is between two string literals depends on what the string literals are. If you have code like the following in the same directory, no option value (other than `Leave`) would help:
```
// Don't break:
QTest::newRow("test") << "" << "" << "" << "" << "" << 1 << 1 << 1 << 1 << 1;

// Break:
    OS << I->Tok->Tok.getName() << "["
       << "T=" << (unsigned)I->Tok->getType()
       << ", OC=" << I->Tok->OriginalColumn << ", \"" << I->Tok->TokenText
       << "\"] ";
```
Like some of the comments from  https://reviews.llvm.org/D80950, I'm still of the opinion that the (undocumented) behavior of "always breaking" is a bug, even though the fix should be "leave" instead of "always merging" as done in d68826dfbd98.

https://github.com/llvm/llvm-project/pull/92214


More information about the cfe-commits mailing list