[clang] [clang-format] Option to insert spaces before the closing `*/` (PR #162105)

Björn Schäpers via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 28 15:02:05 PDT 2025


================
@@ -4898,6 +4911,60 @@ struct FormatStyle {
   /// \version 7
   bool SpaceBeforeRangeBasedForLoopColon;
 
+  /// Specifies spacing behavior for different block comment forms.
+  /// \version 21
+  struct SpaceInCommentsOptions {
+    /// Governs the space immediately after ``/*`` in regular block comments.
+    CommentSpaceMode AfterOpeningComment;
+    /// Governs the space before ``*/`` in regular block comments.
+    CommentSpaceMode BeforeClosingComment;
+    /// Governs the space after ``/*`` in parameter comments such as
+    /// ``/*param=*/``.
+    CommentSpaceMode AfterOpeningParamComment;
+    /// Governs the space before ``*/`` in parameter comments.
+    CommentSpaceMode BeforeClosingParamComment;
+
+    SpaceInCommentsOptions()
+        : AfterOpeningComment(CommentSpaceMode::Leave),
+          BeforeClosingComment(CommentSpaceMode::Leave),
+          AfterOpeningParamComment(CommentSpaceMode::Leave),
+          BeforeClosingParamComment(CommentSpaceMode::Leave) {}
+
+    constexpr bool operator==(const SpaceInCommentsOptions &R) const {
+      return AfterOpeningComment == R.AfterOpeningComment &&
+             BeforeClosingComment == R.BeforeClosingComment &&
+             AfterOpeningParamComment == R.AfterOpeningParamComment &&
+             BeforeClosingParamComment == R.BeforeClosingParamComment;
+    }
+  };
+
+  /// Controls whitespace around block comment delimiters and parameter-style
+  /// inline comments. Each field accepts a ``CommentSpaceMode``: ``Leave``
+  /// (preserve existing spacing, the default), ``Always`` (insert a single
+  /// space), or ``Never`` (remove all spaces).
+  ///
+  /// The available controls are:
+  ///
+  /// ``AfterOpeningComment``
+  ///   Governs the space immediately after ``/*`` in regular block comments.
+  /// ``BeforeClosingComment``
+  ///   Governs the space before ``*/`` in regular block comments.
+  /// ``AfterOpeningParamComment``
+  ///   Governs the space after ``/*`` in parameter comments such as
+  ///   ``/*param=*/``.
+  /// ``BeforeClosingParamComment``
+  ///   Governs the space before ``*/`` in parameter comments.
+  ///
----------------
HazardyKnusperkeks wrote:

```suggestion
```

This is redundant.

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


More information about the cfe-commits mailing list