[PATCH] D33394: [clang-format] Keep trailing preprocessor line comments separate from the following section comments

Daniel Jasper via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 22 03:02:49 PDT 2017


djasper accepted this revision.
djasper added inline comments.
This revision is now accepted and ready to land.


================
Comment at: lib/Format/UnwrappedLineParser.cpp:106
+             isLineComment(*Token) && Token->NewlinesBefore == 1 &&
+             Token->OriginalColumn == PreviousToken->OriginalColumn);
   }
----------------
krasimir wrote:
> djasper wrote:
> > Any chance of moving this logic to distributeComments? I think that's the place we previously tried to encapsulate this logic in. If not, this is fine for now.
> Because of the way parsing around macros works, moving this to distributeComments is gonna be super-tricky: I tried this approach first for a while and gave up. However, I can extract the common logic here and in continuesLineComment at least.
Yeah. Much nicer. Thank you.


================
Comment at: lib/Format/UnwrappedLineParser.cpp:119
     return Token && Token->HasUnescapedNewline &&
-           !(PreviousToken && isLineComment(*PreviousToken) &&
-             isLineComment(*Token) && Token->NewlinesBefore == 1);
+           !(continuesLineComment(*Token, PreviousToken,
+                                  /*MinColumnToken=*/PreviousToken));
----------------
Remove parentheses?


https://reviews.llvm.org/D33394





More information about the cfe-commits mailing list