[clang] [Clang] unrecognized html tag causing undesirable comment lexing (PR #152944)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 15 20:36:29 PDT 2025
https://github.com/mdenson updated https://github.com/llvm/llvm-project/pull/152944
>From 9cfd8978eca58a584a3fc09fe3e839c44d5b3205 Mon Sep 17 00:00:00 2001
From: Brock Denson <brock.denson at virscient.com>
Date: Thu, 7 Aug 2025 10:09:25 -0500
Subject: [PATCH 1/3] [clang] unrecognized html tag causing undesirable comment
lexing. fixes #32680
---
clang/include/clang/AST/CommentHTMLTags.td | 1 +
clang/test/AST/ast-dump-comment.cpp | 9 +++++++++
2 files changed, 10 insertions(+)
diff --git a/clang/include/clang/AST/CommentHTMLTags.td b/clang/include/clang/AST/CommentHTMLTags.td
index a1ce8c6da96c0..31bfd306867b7 100644
--- a/clang/include/clang/AST/CommentHTMLTags.td
+++ b/clang/include/clang/AST/CommentHTMLTags.td
@@ -51,6 +51,7 @@ def Col : Tag<"col"> { let EndTagForbidden = 1; }
def Tr : Tag<"tr"> { let EndTagOptional = 1; }
def Th : Tag<"th"> { let EndTagOptional = 1; }
def Td : Tag<"td"> { let EndTagOptional = 1; }
+def Summary : Tag<"summary">;
// Define a list of attributes that are not safe to pass through to HTML
// output if the input is untrusted.
diff --git a/clang/test/AST/ast-dump-comment.cpp b/clang/test/AST/ast-dump-comment.cpp
index 40c3edb62821b..f4cae32cfa732 100644
--- a/clang/test/AST/ast-dump-comment.cpp
+++ b/clang/test/AST/ast-dump-comment.cpp
@@ -131,3 +131,12 @@ void Test_TemplatedFunctionVariadic(int arg, ...);
// CHECK: ParamCommandComment{{.*}} [in] implicitly Param="..."
// CHECK-NEXT: ParagraphComment
// CHECK-NEXT: TextComment{{.*}} Text=" More arguments"
+
+/// \param[out] Aaa <summary>Short summary</summary>
+int Test_HTMLSummaryTag(int Aaa);
+// CHECK: FunctionDecl{{.*}}Test_HTMLSummaryTag
+// CHECK: ParamCommandComment{{.*}} [out] explicitly Param="Aaa"
+// CHECK-NEXT: ParagraphComment
+// CHECK: HTMLStartTagComment{{.*}} Name="summary"
+// CHECK-NEXT: TextComment{{.*}} Text="Short summary"
+// CHECK-NEXT: HTMLEndTagComment{{.*}} Name="summary"
\ No newline at end of file
>From 43b138de3ef72edcbea51b25bee6c1edd2224c3f Mon Sep 17 00:00:00 2001
From: Brock Denson <brock.denson at virscient.com>
Date: Thu, 7 Aug 2025 10:09:25 -0500
Subject: [PATCH 2/3] [clang] unrecognized html tag causing undesirable comment
lexing. fixes #32680
---
clang/docs/ReleaseNotes.rst | 1 +
clang/include/clang/AST/CommentHTMLTags.td | 4 ++++
clang/test/AST/ast-dump-comment.cpp | 2 +-
3 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index a8b7a29933945..414c5cf88db49 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -195,6 +195,7 @@ Bug Fixes to AST Handling
- Fix incorrect name qualifiers applied to alias CTAD. (#GH136624)
- Fixed ElaboratedTypes appearing within NestedNameSpecifier, which was not a
legal representation. This is fixed because ElaboratedTypes don't exist anymore. (#GH43179) (#GH68670) (#GH92757)
+- Fix unrecognized html tag causing undesirable comment lexing (#GH152944)
Miscellaneous Bug Fixes
^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/clang/include/clang/AST/CommentHTMLTags.td b/clang/include/clang/AST/CommentHTMLTags.td
index 31bfd306867b7..9b89bc0c811fc 100644
--- a/clang/include/clang/AST/CommentHTMLTags.td
+++ b/clang/include/clang/AST/CommentHTMLTags.td
@@ -52,6 +52,10 @@ def Tr : Tag<"tr"> { let EndTagOptional = 1; }
def Th : Tag<"th"> { let EndTagOptional = 1; }
def Td : Tag<"td"> { let EndTagOptional = 1; }
def Summary : Tag<"summary">;
+def Details : Tag<"details">;
+def Mark : Tag<"mark">;
+def Figure : Tag<"figure">;
+def FigCaption : Tag<"figcaption">;
// Define a list of attributes that are not safe to pass through to HTML
// output if the input is untrusted.
diff --git a/clang/test/AST/ast-dump-comment.cpp b/clang/test/AST/ast-dump-comment.cpp
index f4cae32cfa732..52786b5f90ddd 100644
--- a/clang/test/AST/ast-dump-comment.cpp
+++ b/clang/test/AST/ast-dump-comment.cpp
@@ -139,4 +139,4 @@ int Test_HTMLSummaryTag(int Aaa);
// CHECK-NEXT: ParagraphComment
// CHECK: HTMLStartTagComment{{.*}} Name="summary"
// CHECK-NEXT: TextComment{{.*}} Text="Short summary"
-// CHECK-NEXT: HTMLEndTagComment{{.*}} Name="summary"
\ No newline at end of file
+// CHECK-NEXT: HTMLEndTagComment{{.*}} Name="summary"
>From 70ece735c96a50572108542acc280ec5402a47fe Mon Sep 17 00:00:00 2001
From: Brock Denson <brock.denson at virscient.com>
Date: Fri, 15 Aug 2025 21:18:33 -0500
Subject: [PATCH 3/3] add tests for new tags
---
clang/test/AST/ast-dump-comment.cpp | 33 +++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/clang/test/AST/ast-dump-comment.cpp b/clang/test/AST/ast-dump-comment.cpp
index 820e6e97f21e3..b5dbe2e317d8c 100644
--- a/clang/test/AST/ast-dump-comment.cpp
+++ b/clang/test/AST/ast-dump-comment.cpp
@@ -146,3 +146,36 @@ int Test_UnderscoreInSpecialCommand;
// CHECK: VarDecl{{.*}}Test_UnderscoreInSpecialCommand 'int'
// CHECK: InlineCommandComment{{.*}} Name="thread_safe" RenderNormal
// CHECK-NEXT: TextComment{{.*}} Text=" test for underscore in special command"
+
+/// <details>
+/// <summary>
+/// Summary
+/// </summary>
+/// <p>Details</p>
+/// </details>
+///
+/// Some <mark>highlighting</mark>
+///
+/// <figure>
+/// <img src="pic.jpg">
+/// <figcaption>Figure 1</figcaption>
+/// </figure>
+int Test_AdditionalHTMLTags(int Aaa);
+// CHECK: FunctionDecl{{.*}}Test_AdditionalHTMLTags 'int (int)'
+// CHECK: HTMLStartTagComment{{.*}} Name="details"
+// CHECK: HTMLStartTagComment{{.*}} Name="summary"
+// CHECK-NEXT: TextComment{{.*}} Text=" Summary"
+// CHECK: HTMLEndTagComment{{.*}} Name="summary"
+// CHECK: HTMLStartTagComment{{.*}} Name="p"
+// CHECK-NEXT: TextComment{{.*}} Text="Details"
+// CHECK-NEXT: HTMLEndTagComment{{.*}} Name="p"
+// CHECK: HTMLEndTagComment{{.*}} Name="details"
+// CHECK: HTMLStartTagComment{{.*}} Name="mark"
+// CHECK-NEXT: TextComment{{.*}} Text="highlighting"
+// CHECK-NEXT: HTMLEndTagComment{{.*}} Name="mark"
+// CHECK: HTMLStartTagComment{{.*}} Name="figure"
+// CHECK: HTMLStartTagComment{{.*}} Name="img" Attrs: "src="pic.jpg"
+// CHECK: HTMLStartTagComment{{.*}} Name="figcaption"
+// CHECK-NEXT: TextComment{{.*}} Text="Figure 1"
+// CHECK-NEXT: HTMLEndTagComment{{.*}} Name="figcaption"
+// CHECK: HTMLEndTagComment{{.*}} Name="figure"
More information about the cfe-commits
mailing list