[clang-format] Improve BAS_DontAlign+AllowAllArgumentsOnNextLine=false
authorAlex Richardson <Alexander.Richardson@cl.cam.ac.uk>
Mon, 2 Nov 2020 17:35:59 +0000 (17:35 +0000)
committerAlex Richardson <Alexander.Richardson@cl.cam.ac.uk>
Mon, 2 Nov 2020 17:52:37 +0000 (17:52 +0000)
commit906b9dbc9d7487ee923b6a516c36777a2be0ca35
tree793fdd468a8cb0579e861ba78298d1eaa7081845
parent5bc438efcf96c9ef83312c37674b03e98259a22b
[clang-format] Improve BAS_DontAlign+AllowAllArgumentsOnNextLine=false

TokenAnnotator::splitPenalty() was always returning 0 for opening parens if
AlignAfterOpenBracket was set to BAS_DontAlign, so the preferred point for
line breaking was always after the open paren (and was ignoring
PenaltyBreakBeforeFirstCallParameter). This change restricts the zero
penalty to the AllowAllArgumentsOnNextLine case. This results in improved
formatting for FreeBSD where we set AllowAllArgumentsOnNextLine: false
and a high value for PenaltyBreakBeforeFirstCallParameter to avoid breaking
after the open paren.

Before:
```
functionCall(
    paramA, paramB, paramC);
void functionDecl(
    int A, int B, int C)
```
After:
```
functionCall(paramA, paramB,
    paramC);
void functionDecl(int A, int B,
    int C)
```

Reviewed By: MyDeveloperDay

Differential Revision: https://reviews.llvm.org/D90246
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp