llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.75k stars 11.89k forks source link

clang-format should prefer not to break in the middle of a binary operator expression #27982

Open 35a556ef-26b9-4f2b-837d-9b3f7ccf6035 opened 8 years ago

35a556ef-26b9-4f2b-837d-9b3f7ccf6035 commented 8 years ago
Bugzilla Link 27608
Version unspecified
OS Windows NT

Extended Description

Original formatting:

int main() {
  x.ExcessivelyLongFunctionName(
      ReallyLongFunctionCallHere() == kSomeExceedinglyLongConstant);
}

clang-format with chromium style:

int main() {
  x.ExcessivelyLongFunctionName(ReallyLongFunctionCallHere() ==
                                kSomeExceedinglyLongConstant);
}

A bit surprising, since clang-format could have just broken after the (. In fact, if there's more than one argument, clang-format will prefer to keep the binary operator expression together.

llvmbot commented 8 years ago

You can influence this by setting PenaltyBreakBeforeFirstCallParameter. I don't think there is a one solution that makes everyone happy here.