https://github.com/mdenson created 
https://github.com/llvm/llvm-project/pull/152943

Comment lexer fails to parse non-alphanumeric names. I'm not sure how common 
this is, but it appears to be allowed by doxygen. However, I didn't see any 
references to exactly what was allowed. I expect breaking on whitespace will 
break things like \param[in]. Doxygen's alias could add complexity.

This is simple, seems reasonable, but not the only option. 

1. Leave as it was, document the behavior
2. Update the rules, defining expected behavior
3. Something else entirely

fixes #33296

>From 475d513b79339da73f322f9b7d14122f103998a5 Mon Sep 17 00:00:00 2001
From: Brock Denson <brock.den...@virscient.com>
Date: Wed, 6 Aug 2025 21:50:02 -0500
Subject: [PATCH] [clang] fix comment parsing of special commands with
 non-alphanumeric names. fixes #33296

---
 clang/lib/AST/CommentLexer.cpp      | 2 +-
 clang/test/AST/ast-dump-comment.cpp | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/clang/lib/AST/CommentLexer.cpp b/clang/lib/AST/CommentLexer.cpp
index e19c2327aebdc..a0903d0903dd8 100644
--- a/clang/lib/AST/CommentLexer.cpp
+++ b/clang/lib/AST/CommentLexer.cpp
@@ -214,7 +214,7 @@ bool isCommandNameStartCharacter(char C) {
 }
 
 bool isCommandNameCharacter(char C) {
-  return isAlphanumeric(C);
+  return isAsciiIdentifierContinue(C, false);
 }
 
 const char *skipCommandName(const char *BufferPtr, const char *BufferEnd) {
diff --git a/clang/test/AST/ast-dump-comment.cpp 
b/clang/test/AST/ast-dump-comment.cpp
index 40c3edb62821b..2b4ec63765f41 100644
--- a/clang/test/AST/ast-dump-comment.cpp
+++ b/clang/test/AST/ast-dump-comment.cpp
@@ -131,3 +131,9 @@ void Test_TemplatedFunctionVariadic(int arg, ...);
 // CHECK:        ParamCommandComment{{.*}} [in] implicitly Param="..."
 // CHECK-NEXT:     ParagraphComment
 // CHECK-NEXT:       TextComment{{.*}} Text=" More arguments"
+
+/// \thread_safe test for underscore in special command
+int Test_UnderscoreInSpecialCommand;
+// CHECK:      VarDecl{{.*}}Test_UnderscoreInSpecialCommand 'int'
+// CHECK:        InlineCommandComment{{.*}} Name="thread_safe" RenderNormal
+// CHECK-NEXT:     TextComment{{.*}} Text=" test for underscore in special 
command"
\ No newline at end of file

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to