[clang] [clang-format] Add SpacesInComments option for block comments (PR #204727)

via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 30 00:07:42 PDT 2026


================
@@ -778,6 +778,48 @@ void BreakableBlockComment::reflow(unsigned LineIndex,
 void BreakableBlockComment::adaptStartOfLine(
     unsigned LineIndex, WhitespaceManager &Whitespaces) const {
   if (LineIndex == 0) {
+    StringRef Text = tokenAt(LineIndex).TokenText;
+    if (Style.SpacesInComments != FormatStyle::SICS_Leave &&
+        Lines.size() == 1 && Text.size() >= 4) {
----------------
frank-suwen wrote:

My original intention was to scope the initial implementation to ordinary single-line block comments only. Multiline block comments interact with the existing comment reflow and formatting logic, so I wanted to avoid changing that behavior until the overall design was confirmed.

If the preferred direction is to support multiline block comments as well, I’m happy to extend the implementation accordingly. Please let me know if you think that would be the right next step or if you have any other suggestions. Thanks!

https://github.com/llvm/llvm-project/pull/204727


More information about the cfe-commits mailing list