Reputation: 448
The following file test.cpp
int func() {
aaaaaaaaaaa = bbbbbbbb->cccccc(SomeNamespace::Function(dddddddd?"eeeeeeeee":"fffffffffff")).gggggggggg();
}
is formatted with clang-format
in the following way (I tried different styles):
$ for s in LLVM Google Chromium Mozilla WebKit; do clang-format -style="{BasedOnStyle: $s, ColumnLimit: 80}" test.cpp; done
int func() {
aaaaaaaaaaa = bbbbbbbb
->cccccc(SomeNamespace::Function(dddddddd ? "eeeeeeeee"
: "fffffffffff"))
.gggggggggg();
}
int func() {
aaaaaaaaaaa = bbbbbbbb
->cccccc(SomeNamespace::Function(dddddddd ? "eeeeeeeee"
: "fffffffffff"))
.gggggggggg();
}
int func() {
aaaaaaaaaaa = bbbbbbbb
->cccccc(SomeNamespace::Function(dddddddd ? "eeeeeeeee"
: "fffffffffff"))
.gggggggggg();
}
int
func()
{
aaaaaaaaaaa =
bbbbbbbb
->cccccc(SomeNamespace::Function(dddddddd ? "eeeeeeeee" : "fffffffffff"))
.gggggggggg();
}
int func()
{
aaaaaaaaaaa = bbbbbbbb
->cccccc(SomeNamespace::Function(
dddddddd ? "eeeeeeeee" : "fffffffffff"))
.gggggggggg();
}
I wonder if there is an option to prevent clang-format
from breaking the line at the ->
operator.
Upvotes: 4
Views: 1450
Reputation: 23824
There doesn't seem to be any option only affecting operator->
in the list of clang-format
options, but you can always disable clang-format
for the offending lines:
int func() {
// clang-format off
aaaaaaaaaaa = bbbbbbbb->cccccc(SomeNamespace::Function(dddddddd?"eeeeeeeee":"fffffffffff")).gggggggggg();
// clang-format on
}
This disables formatting completely, so some manual intervention may be necessary if other formatting rules are desired for the lines in question.
Upvotes: 0