We are currently in the process of formatting our code base with clang-format
. We found a situation where for some reason the stream operator to std::cout
is moved to the next line if two consecutive strings literals are present. Putting a variable in between thw two string literals causes clang-format to not change the format. What needs to be changed in the .clang-format
file to avoid this?
int main()
{
std::cout << "something" << "something" << std::endl;
}
becomes
int main()
{
std::cout << "something"
<< "something" << std::endl;
}
while
int main()
{
int a = 0;
std::cout << "something" << a << "something" << std::endl;
}
stays untouched. Note while this last snippet is wider, it is not split across multiple lines, while the shorter snippet above is.
This is with LLVM 9.0.0 Windows installer and is reproducible with the default config file.
This behavior can't be altered via the .clang-format
file, as it is part of the code.
This behavior was introduced in this commit: https://github.com/llvm-mirror/clang/commit/df28f7b8dd6a032515109de4ff5b4067be95da8e
Link to bug report: https://bugs.llvm.org/show_bug.cgi?id=45018
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With