[clang] [clang-format] Option to insert spaces before the closing `*/` (PR #162105)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 28 18:10:44 PDT 2025
================
@@ -19,13 +19,234 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/Debug.h"
#include <algorithm>
+#include <iterator>
#define DEBUG_TYPE "format-token-breaker"
namespace clang {
namespace format {
+class BreakableBlockComment;
+
static constexpr StringRef Blanks(" \t\v\f\r");
+static constexpr size_t BlockCommentOpenerLength = 2;
+static constexpr size_t BlockCommentCloserLength = 2;
+
+namespace {
+
+bool isWellFormedBlockCommentText(StringRef Text) {
+ return Text.size() >= BlockCommentOpenerLength + BlockCommentCloserLength &&
+ Text.starts_with("/*") && Text.ends_with("*/");
+}
+
+int countTrailingSpaces(StringRef Text) {
+ const size_t TrimmedSize = Text.rtrim(Blanks).size();
+ return static_cast<int>(Text.size() - TrimmedSize);
+}
+
+FormatStyle::CommentSpaceMode
+resolveCommentSpaceMode(const FormatStyle &Style, const FormatToken &Tok,
+ FormatStyle::CommentSpaceMode GeneralMode,
+ FormatStyle::CommentSpaceMode ParamOverrideMode,
+ const bool ForceDocstringLeave) {
+ if (Tok.getBlockCommentKind() == CommentKind::Parameter) {
+ if (ParamOverrideMode != FormatStyle::CommentSpaceMode::Leave)
----------------
Men-cotton wrote:
https://github.com/llvm/llvm-project/pull/162105#discussion_r2464588718
https://github.com/llvm/llvm-project/pull/162105
More information about the cfe-commits
mailing list