s1Sharp wrote:
> @s1Sharp are there any conclusions here? our code also incidentally relied on
> having new lines between string literals, mostly for the sake of having a
> line break after string literals that end with `\n`.
>
> what do people think about restoring the functionality to break after string
> literals that end with `\n`?
> https://github.com/search?q=%2F%5C%5Cn%5C%22%5Cn%5Cs*%3C%3C%5C+%5C%22%2F+language%3AC%2B%2B+&type=code&ref=advsearch
> shows a lot of examples of such pattern, so i feel like having that without
> an option initially easy relatively easy and likely to preserve
> clang-format's behavior for a lot of existing code for the next release.
> afterwards we can discuss introducing more options again.
First, I want to show how this works with the current code.
As an example, here are a couple of output statements.
.clang-format:
```
Language: Cpp
BasedOnStyle: Google
IndentWidth: 4
ColumnLimit: 70
```
before clang-format:
```C++
cout << "hello\n" << "World\n" << "HELLO" << "world" << "hello" << "World" <<
"HELLO" << "world" << "hello" << "World" << "HELLO" << "world";
cout << "hello" << std::endl << "World" << "hello" << '\n' << "another hello"
<< "world";
cout << "hello\n"
<< "World" << std::endl
<< "HELLO" << "world";
```
after clang-format:
```C++
cout << "hello\n"
<< "World\n"
<< "HELLO" << "world" << "hello" << "World" << "HELLO"
<< "world" << "hello" << "World" << "HELLO" << "world";
cout << "hello" << std::endl
<< "World" << "hello" << '\n'
<< "another hello" << "world";
cout << "hello\n" << "World" << std::endl << "HELLO" << "world";
```
A bit unexpected results, right? Formatting applies to single-line expressions
and breaks to another line after the \n and std::endl characters. And if the
code has already been manually formatted (as in 3rd cout), then clang-format
groups this code into a single-line expression.
I agree with your suggestion that to maintain compatibility with the old
behavior of clang-format.
https://github.com/llvm/llvm-project/pull/69859
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits