llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: None (mdenson)

<details>
<summary>Changes</summary>

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

---
Full diff: https://github.com/llvm/llvm-project/pull/152943.diff


2 Files Affected:

- (modified) clang/lib/AST/CommentLexer.cpp (+1-1) 
- (modified) clang/test/AST/ast-dump-comment.cpp (+6) 


``````````diff
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

``````````

</details>


https://github.com/llvm/llvm-project/pull/152943
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to