[PATCH] D15147: [clang-format] Reflow block comments when they're over the column limit

Benjamin Kramer via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 2 04:30:40 PST 2015


bkramer created this revision.
bkramer added reviewers: djasper, klimek.
bkramer added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

/* aaaaaaaa a
 * a*/

Now becomes

/* aaaaaaaa
 * a a*/

instead of

/* aaaaaaaa
 * a
 * a*/

This is implemented by glueing the next line on while fixing whitespace
and adding another break if that brings us over the column limit again.
We also have heuristics to avoid making existing comments worse:
  1. Only reflow when the existing comment is already over the column limit
  2. Don't reflow when there's an empty line (to avoid breaking paragraphs)
  3. Don't reflow when there's a non-alphanumeric char at the beginning of
     the next line. This is a weak attempt to avoid mangling ASCII art.

I intend to do the same thing for line comments, but that will require
changes to other parts of clang-format first.

http://reviews.llvm.org/D15147

Files:
  lib/Format/BreakableToken.cpp
  lib/Format/BreakableToken.h
  unittests/Format/FormatTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15147.41610.patch
Type: text/x-patch
Size: 6427 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151202/373802ef/attachment-0001.bin>


More information about the cfe-commits mailing list