[clang] [clang] Exclude trailing colons from param command names (PR #192598)
Erick Velez via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 16 23:11:26 PDT 2026
https://github.com/evelez7 created https://github.com/llvm/llvm-project/pull/192598
Doxygen accepts param names with trailing colons and they are omitted in
documentation. The comment parser includes the colon in the param name
thus including it in AST dumps. This patch removes a trailing colon and
adds a test for it.
Fixes #185378
>From 7a0197b9a0fab1a93f560dce6d19972a09ddc76d Mon Sep 17 00:00:00 2001
From: Erick Velez <erickvelez7 at gmail.com>
Date: Thu, 16 Apr 2026 18:13:39 -0700
Subject: [PATCH] [clang] Exclude trailing colons from param command names
Doxygen accepts param names with trailing colons and they are omitted in
documentation. The comment parser includes the colon in the param name
thus including it in AST dumps. This patch removes a trailing colon and
adds a test for it.
Fixes #185378
---
clang/docs/ReleaseNotes.rst | 2 ++
clang/lib/AST/CommentParser.cpp | 2 ++
clang/test/AST/ast-dump-comment.cpp | 4 ++++
3 files changed, 8 insertions(+)
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 8d74dd8bc9699..d324b864709da 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -70,6 +70,8 @@ AST Dumping Potentially Breaking Changes
``introduced``, ``deprecated``, ``obsoleted``, ``unavailable``, ``message``,
``strict``, ``replacement``, ``priority``, and ``environment``. Previously, these
fields were missing from the JSON output.
+- Colons that appear at the end of a ParamCommentCommand name are not serialized
+ as part of the name.
Clang Frontend Potentially Breaking Changes
-------------------------------------------
diff --git a/clang/lib/AST/CommentParser.cpp b/clang/lib/AST/CommentParser.cpp
index 2e5821a8e4436..68f18cfb5173e 100644
--- a/clang/lib/AST/CommentParser.cpp
+++ b/clang/lib/AST/CommentParser.cpp
@@ -299,6 +299,8 @@ class TextTokenRetokenizer {
} else
break;
}
+ if (WordText.ends_with(':'))
+ WordText.pop_back();
const unsigned Length = WordText.size();
if (Length == 0) {
Pos = SavedPos;
diff --git a/clang/test/AST/ast-dump-comment.cpp b/clang/test/AST/ast-dump-comment.cpp
index b5dbe2e317d8c..f0eb86c964dee 100644
--- a/clang/test/AST/ast-dump-comment.cpp
+++ b/clang/test/AST/ast-dump-comment.cpp
@@ -41,6 +41,7 @@ int Test_BlockCommandComment_WithArgs();
/// \param Aaa xxx
/// \param [in,out] Bbb yyy
+/// \param Ccc: zzz
void Test_ParamCommandComment(int Aaa, int Bbb);
// CHECK: FunctionDecl{{.*}}Test_ParamCommandComment
// CHECK: ParamCommandComment{{.*}} [in] implicitly Param="Aaa" ParamIndex=0
@@ -49,6 +50,9 @@ void Test_ParamCommandComment(int Aaa, int Bbb);
// CHECK: ParamCommandComment{{.*}} [in,out] explicitly Param="Bbb" ParamIndex=1
// CHECK-NEXT: ParagraphComment
// CHECK-NEXT: TextComment{{.*}} Text=" yyy"
+// CHECK: ParamCommandComment{{.*}} [in] implicitly Param="Ccc"
+// CHECK-NEXT: ParagraphComment
+// CHECK-NEXT: TextComment{{.*}} Text=" zzz"
/// \tparam Aaa xxx
template <typename Aaa> class Test_TParamCommandComment;
More information about the cfe-commits
mailing list