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

Manuel Klimek via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 14 08:09:47 PST 2017


klimek added a comment.

One interesting trade-off I'm running into:
My gut feeling is that we really want to make local decisions about whether we want to break/reflow - this makes the code significantly simpler (IMO), and handles all tests in this patch correctly, but is fundamentally limiting the global optimizations we can do. Specifically, we would not correctly reflow this:

  //       |< limit
  // foo bar
  // baz
  // x

to

  // foo
  // bar
  // baz x

when the excess character limit is low.

That would be a point for global optimization, but I find it really hard to understand exactly why it's ok to do it. Won't we get things like this wrong:

  Limit: 13
  // foo  bar baz
  // bab      bob

as we'll not compress whitespace?


https://reviews.llvm.org/D33589





More information about the cfe-commits mailing list