[PATCH] D27754: [clang-format] Implement comment reflowing (again).

Manuel Klimek via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 14 08:37:06 PST 2016

klimek added inline comments.

Comment at: lib/Format/ContinuationIndenter.cpp:1174-1175
        LineIndex != EndIndex; ++LineIndex) {
-    if (!DryRun)
-      Token->replaceWhitespaceBefore(LineIndex, Whitespaces);
+    Token->replaceWhitespaceBefore(LineIndex, RemainingTokenColumns,
+                                   RemainingSpace, DryRun, Whitespaces);
     unsigned TailOffset = 0;
krasimir wrote:
> klimek wrote:
> > Nice that this whole section required so few changes.
> > Why do we need to call into this in DryRun mode now, though? Does it need to keep state inside in DryRun?
> Yes, replaceWhitespaceBefore recomputes the ContentColumn in case a reflow with the previous line is decided to be made.
> Basically, the whole reflow functionality is inside replaceWhitespaceBefore now (except for a bit of control flow stuff, like updating the  ReflowInProgress member variable).
For my curiosity: what's the reason we can't precompute those in the constructor? Is that too much things we do outside of the flow here?


More information about the cfe-commits mailing list