[PATCH] D33589: clang-format: consider not splitting tokens in optimization
Manuel Klimek via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 20 01:47:31 PDT 2017
klimek added a comment.
In https://reviews.llvm.org/D33589#876196, @Typz wrote:
> This cannot be implemented where we currently call breakProtrudingToken(), since this function starts by 'creating' the BreakableToken and dealing with meany corner cases: so this should be done before in any case.
> But the code at the end of breakProtrudingToken() is actually very similar to what you propose.
>
> I can refactor the code to have two functions reflowProtrudingToken() and getExcessPenalty(), though that will add some significant redundancy: the problem is that even if we don't actually reflow, we still need (I think?) to handle whitespace replacement and update the state (to set Column, Stack.back().LastSpace, and Stack[i].BreakBeforeParameter, and call updateNextToken() ...). And therefore getExcessPenalty() should probably not just compute the penalty, it should also update the state and handle whitespace replacement...
My question is: if CanBreak is false, we currently don't call breakProtrudingToken. So either we do something very wrong in that case (which might be true, but I'd like to understand why) or we should be able to just calculate the penalty by not breaking anything and go on.
https://reviews.llvm.org/D33589
More information about the cfe-commits
mailing list