[PATCH] D28764: [clang-format] Implement comment reflowing (v3)

Krasimir Georgiev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 25 05:35:31 PST 2017


krasimir added a comment.

Tried to add some comments around range computations. Most of the time it's about converting range offsets from local line-based values to start-of-token-based offsets.



================
Comment at: lib/Format/BreakableToken.cpp:279-280
+  return Content.size() >= 2 &&
+      Content != "clang-format on" &&
+      Content != "clang-format off" &&
+      !Content.endswith("\\") &&
----------------
klimek wrote:
> Can we now use delimitsRegion here?
Yep! Actually came up with even better alternative: we use switchesFormatting() below:


================
Comment at: lib/Format/ContinuationIndenter.cpp:1090-1092
+// Checks if Token delimits formatting regions, like /* clang-format off */.
+// Token must be a comment.
+static bool delimitsRegion(const FormatToken &Token) {
----------------
klimek wrote:
> delimitsRegion seems overly abstract. Perhaps switchesFormatting?
Yep. Also moved it to BreakableToken.h/.cpp so it can be used from both ContinuationIndenter::breakProtrudingToken and BreakableComment::mayReflow!


https://reviews.llvm.org/D28764





More information about the cfe-commits mailing list