This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Always consider option PenaltyBreakBeforeFirstCallParameter
AbandonedPublic

Authored by mnauw on Oct 31 2020, 8:02 AM.

Details

Reviewers
sammccall
Summary

If AlignAfterOpenBracket is set to BAS_DontAlign, then it turns out that PenaltyBreakBeforeFirstCallParameter is not considered (due to hard-coded shortcut, so to speak).

This patch attempts to preserve the current (specially crafted) behavior, while considering PenaltyBreakBeforeFirstCallParameter when really specified. There may also be other ways to go about this to allow the user to actually set and use PenaltyBreakBeforeFirstCallParameter. Failing all such options, it might otherwise be documented that PenaltyBreakBeforeFirstCallParameter has no effect in BAS_DontAlign.

Diff Detail

Event Timeline

mnauw created this revision.Oct 31 2020, 8:02 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 31 2020, 8:02 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
mnauw requested review of this revision.Oct 31 2020, 8:02 AM

You need to supply full context diffs

clang/unittests/Format/FormatTest.cpp
4481

Why do you need these? what is the default value of this as set in the LLVM style?

mnauw added inline comments.Nov 1 2020, 2:16 AM
clang/unittests/Format/FormatTest.cpp
4481

The default value in the LLVM style is 19. However, the fragment of code in TokenAnnotator.cpp basically hard-codes this to 0 (in case of BAS_DontAlign; see that part). Since that part is now changed to really use PenaltyBreakBeforeFirstCallParameter style option, the latter is set to 0 in these cases to retain the original behavior.

mnauw abandoned this revision.Nov 15 2020, 4:32 AM

Looks like PenaltyBreakBeforeFirstCallParameter not being considered so well has been addressed somewhat differently in D90246, and so that does the job as well.