================
@@ -1387,6 +1403,21 @@ FormatToken *FormatTokenLexer::getNextToken() {
     StringRef UntrimmedText = FormatTok->TokenText;
     FormatTok->TokenText = FormatTok->TokenText.rtrim(" \t\v\f");
     TrailingWhitespace = UntrimmedText.size() - FormatTok->TokenText.size();
+
+    if (isWellFormedBlockCommentText(FormatTok->TokenText)) {
+      FormatTok->setBlockCommentKind(
+          classifyBlockComment(FormatTok->TokenText));
+      const StringRef Content =
+          FormatTok->TokenText.drop_front(2).drop_back(2).rtrim("\r\n");
+      if (!Content.empty()) {
+        const auto LastChar = static_cast<unsigned char>(Content.back());
+        if (!isHorizontalWhitespace(LastChar)) {
+          FormatTok->NeedsSpaceBeforeClosingBlockComment = true;
+          FormatTok->SpaceBeforeClosingBlockCommentOffset =
+              FormatTok->TokenText.size() - 2;
----------------
Men-cotton wrote:

Thanks for the suggestion.
I've refactored the whitespace management to be handled within 
`BreakableBlockComment::adaptStartOfLine`.
Although this runs during the initial adaptation phase (preceding the core 
reflow), it fits naturally into the comment formatting pipeline and eliminates 
the need to save external state. This version is much simpler.

https://github.com/llvm/llvm-project/pull/162105
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to