Skip to content

Conversation

@mdenson
Copy link
Contributor

@mdenson mdenson commented Aug 10, 2025

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

@github-actions
Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Aug 10, 2025
@llvmbot
Copy link
Member

llvmbot commented Aug 10, 2025

@llvm/pr-subscribers-clang

Author: None (mdenson)

Changes

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

@Fznamznon Fznamznon requested a review from evelez7 August 12, 2025 08:24
@evelez7 evelez7 requested a review from AaronBallman August 12, 2025 14:07
int Test_UnderscoreInSpecialCommand;
// CHECK: VarDecl{{.*}}Test_UnderscoreInSpecialCommand 'int'
// CHECK: InlineCommandComment{{.*}} Name="thread_safe" RenderNormal
// CHECK-NEXT: TextComment{{.*}} Text=" test for underscore in special command"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file needs an empty line at the end of it.

@cor3ntin
Copy link
Contributor

This change needs a release note.
Please add an entry to clang/docs/ReleaseNotes.rst in the section the most adapted to the change, and referencing any Github issue this change fixes. Thanks!

@AaronBallman
Copy link
Collaborator

This change needs a release note. Please add an entry to clang/docs/ReleaseNotes.rst in the section the most adapted to the change, and referencing any Github issue this change fixes. Thanks!

+1, but otherwise LGTM

Copy link
Contributor

@cor3ntin cor3ntin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Do you need us to merge that for you?

@mdenson
Copy link
Contributor Author

mdenson commented Aug 13, 2025

perhaps. sorry, i'm new here. looks like it failed a doc test in tools/clang/docs/OpenMPSupport.rst:89:Malformed table.

@mdenson mdenson closed this Aug 13, 2025
@mdenson mdenson reopened this Aug 13, 2025
@evelez7
Copy link
Member

evelez7 commented Aug 13, 2025

Do you want the tests to run again? Don't think you have perms for that, I can rerun them for you.

@cor3ntin
Copy link
Contributor

The tests look fine to me, I'll merge!

@cor3ntin cor3ntin merged commit f5b36eb into llvm:main Aug 14, 2025
17 checks passed
@github-actions
Copy link

@mdenson Congratulations on having your first Pull Request (PR) merged into the LLVM Project!

Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR.

Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail here.

If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are working as expected, well done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Comment tag is not properly created.

5 participants