[clang] [clang] Exclude trailing colons from param command names (PR #192598)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 16 23:11:57 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Erick Velez (evelez7)
<details>
<summary>Changes</summary>
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
---
Full diff: https://github.com/llvm/llvm-project/pull/192598.diff
3 Files Affected:
- (modified) clang/docs/ReleaseNotes.rst (+2)
- (modified) clang/lib/AST/CommentParser.cpp (+2)
- (modified) clang/test/AST/ast-dump-comment.cpp (+4)
``````````diff
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;
``````````
</details>
https://github.com/llvm/llvm-project/pull/192598
More information about the cfe-commits
mailing list