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

Francois Ferrand via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 20 01:03:49 PDT 2017


Typz added a comment.

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...


https://reviews.llvm.org/D33589





More information about the cfe-commits mailing list