Skip to content

Commit f5b36eb

Browse files
mdensonBrock Denson
andauthored
[clang] fix comment lexing of command names with underscore (#152943)
Comment lexer fails to parse non-alphanumeric names. fixes #33296 --------- Co-authored-by: Brock Denson <[email protected]>
1 parent d15b7a8 commit f5b36eb

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ Bug Fixes to AST Handling
216216
- Fix incorrect name qualifiers applied to alias CTAD. (#GH136624)
217217
- Fixed ElaboratedTypes appearing within NestedNameSpecifier, which was not a
218218
legal representation. This is fixed because ElaboratedTypes don't exist anymore. (#GH43179) (#GH68670) (#GH92757)
219+
- Fix comment lexing of special command names (#GH152943)
219220

220221
Miscellaneous Bug Fixes
221222
^^^^^^^^^^^^^^^^^^^^^^^

clang/lib/AST/CommentLexer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ bool isCommandNameStartCharacter(char C) {
214214
}
215215

216216
bool isCommandNameCharacter(char C) {
217-
return isAlphanumeric(C);
217+
return isAsciiIdentifierContinue(C, false);
218218
}
219219

220220
const char *skipCommandName(const char *BufferPtr, const char *BufferEnd) {

clang/test/AST/ast-dump-comment.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,9 @@ void Test_TemplatedFunctionVariadic(int arg, ...);
131131
// CHECK: ParamCommandComment{{.*}} [in] implicitly Param="..."
132132
// CHECK-NEXT: ParagraphComment
133133
// CHECK-NEXT: TextComment{{.*}} Text=" More arguments"
134+
135+
/// \thread_safe test for underscore in special command
136+
int Test_UnderscoreInSpecialCommand;
137+
// CHECK: VarDecl{{.*}}Test_UnderscoreInSpecialCommand 'int'
138+
// CHECK: InlineCommandComment{{.*}} Name="thread_safe" RenderNormal
139+
// CHECK-NEXT: TextComment{{.*}} Text=" test for underscore in special command"

0 commit comments

Comments
 (0)