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

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


klimek added inline comments.


================
Comment at: lib/Format/BreakableToken.cpp:471
+                                               WhitespaceManager &Whitespaces) {
+  if (Tok.is(TT_LineComment)) {
+    // If this is the first line of a token, inform Whitespace Manager about it.
----------------
Without looking into this in a lot of detail: this looks like you want a BreakableComment base class, and have BreakableBlockComment and BreakableLineCommentSection derive from it and implement this method.

Scanning it a bit, it seems like there is still overlap - perhaps it's also possible to pull out a couple of smaller sized methods in the interface and write the algorithm in terms of those? That could also make it easier to understand in general (large method alarm ;)


================
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;
----------------
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?


https://reviews.llvm.org/D27754





More information about the cfe-commits mailing list