This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Improve BAS_DontAlign+AllowAllArgumentsOnNextLine=false
ClosedPublic

Authored by arichardson on Oct 27 2020, 9:33 AM.

Details

Summary

TokenAnnotator::splitPenalty() was always returning 0 for opening parens if
AlignAfterOpenBracket was set to BAS_DontAlign, 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 which 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)

Diff Detail

Event Timeline

arichardson created this revision.Oct 27 2020, 9:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 27 2020, 9:33 AM
arichardson requested review of this revision.Oct 27 2020, 9:33 AM
MyDeveloperDay edited the summary of this revision. (Show Details)Oct 31 2020, 6:56 AM

This LGTM actually, and something that's been annoying me for ages that it breaks like this

MyDeveloperDay accepted this revision.Oct 31 2020, 6:58 AM
This revision is now accepted and ready to land.Oct 31 2020, 6:58 AM
This revision was landed with ongoing or failed builds.Nov 2 2020, 9:53 AM
This revision was automatically updated to reflect the committed changes.