[PATCH] D33589: clang-format: consider not splitting tokens in optimization

Manuel Klimek via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 19 06:48:07 PDT 2017


klimek added a comment.

I find the current semantics of the functions a bit surprising, specifically:
... reflowProtrudingToken(..., bool Reflow)
is really confusing me :)

I'd have expected something like this where we currently call breakProtrudingToken():

  if (CanBreak) {
    ReflowPenalty = breakProtrudingToken(Current, State, /*DryRun=*/true);
    FixedPenalty = getExcessPenalty(Current, State);
    Penalty = ReflowPenalty < FixedPenalty ? ReflowPenalty : FixedPenalty;
    if (!DryRun && ReflowPenalty < FixedPenalty
        breakProtrudingToken(Current, State, /*DryRun=*/false);
  }

I haven't looked how we calculate the penalty currently if we can't break, as if we don't, that also seems ... wrong.
getExcessPenalty would be a new function that just focuses on getting the excess penalty for a breakable token.


https://reviews.llvm.org/D33589





More information about the cfe-commits mailing list