[PATCH] D29626: [clang-format] Break before a sequence of line comments aligned with the next line.

Daniel Jasper via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 7 03:04:01 PST 2017


djasper added inline comments.


================
Comment at: lib/Format/UnwrappedLineParser.cpp:2206
+    const SmallVectorImpl<FormatToken *> &Comments,
+    const FormatToken* NextTok) {
   bool CommentsInCurrentLine = true;
----------------
krasimir wrote:
> Any suggestions on how to improve the code quality a bit if we stick with this design?
I think comments might actually help here, but also this isn't too bad. As in, when writing the comments, it might become more obvious how to write this better.


================
Comment at: lib/Format/UnwrappedLineParser.cpp:2207
+    const FormatToken* NextTok) {
   bool CommentsInCurrentLine = true;
+  int StartOfSectionAlignedWithNextToken = -1;
----------------
krasimir wrote:
> Need to add comments about this if we decide we may go with this.
Yeah.. Commented comment handling is best comment handling :-D


================
Comment at: lib/Format/UnwrappedLineParser.cpp:2210
+  if (NextTok) {
+    for (int i = Comments.size() - 1; i >= 0; --i) {
+      if (Comments[i]->OriginalColumn ==
----------------
I think we use "unsigned" in most of these loops.

And to avoid and edge conditions put this at the top of the function:

  if (Comments.empty())
    return;


================
Comment at: lib/Format/UnwrappedLineParser.h:118
+  void organiseComments(const SmallVectorImpl<FormatToken *> &Comments,
+                        const FormatToken *NextTok);
   void flushComments(bool NewlineBeforeNext);
----------------
krasimir wrote:
> @djasper: considering what this code does, what would be a better name of this?
Maybe analyzeCommentAlignment? Or determineCommentAlignment?


https://reviews.llvm.org/D29626





More information about the cfe-commits mailing list