[cfe-users] clang-format option to not break lines at operator ->

Mikhail Artemyev via cfe-users cfe-users at lists.llvm.org
Thu Jun 22 14:44:03 PDT 2017


Hi All,

I am currently trying to beatify a reasonably large code base, and I am
quite surprised about how clang-format breaks long lines where there is a
'->' operator.

Example:
% cat test.cpp
int func() {
   aaaaaaaaaaa = bbbbbbbbbb->cccccccccc(SomeNamespace::Function(
dddddddd?"eeeeeeee":"ffffffff")).gggggggggg();
}

I tried different clang-format styles, but they all break this long line at
the '->':
% for s in LLVM Google Chromium Mozilla WebKit; do clang-format
-style="{BasedOnStyle: $s, ColumnLimit: 80}" test.cpp; done
int func() {
  aaaaaaaaaaa = bbbbbbbbbb
                    ->cccccccccc(SomeNamespace::Function(dddddddd ?
"eeeeeeee"
                                                                  :
"ffffffff"))
                    .gggggggggg();
}
int func() {
  aaaaaaaaaaa = bbbbbbbbbb
                    ->cccccccccc(SomeNamespace::Function(dddddddd ?
"eeeeeeee"
                                                                  :
"ffffffff"))
                    .gggggggggg();
}
int func() {
  aaaaaaaaaaa = bbbbbbbbbb
                    ->cccccccccc(SomeNamespace::Function(dddddddd ?
"eeeeeeee"
                                                                  :
"ffffffff"))
                    .gggggggggg();
}
int
func()
{
  aaaaaaaaaaa =
    bbbbbbbbbb
      ->cccccccccc(SomeNamespace::Function(dddddddd ? "eeeeeeee" :
"ffffffff"))
      .gggggggggg();
}
int func()
{
    aaaaaaaaaaa = bbbbbbbbbb
                      ->cccccccccc(SomeNamespace::Function(
                          dddddddd ? "eeeeeeee" : "ffffffff"))
                      .gggggggggg();
}

Is there a way to prevent clang-format from breaking lines like that at the
'->'?

Thank you,
Mikhail

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20170622/0792e48f/attachment.html>


More information about the cfe-users mailing list