Skip to content

Commit 65ffa53

Browse files
mdensonBrock Denson
andauthored
[Clang] unrecognized html tag causing undesirable comment lexing (#152944)
Simple fix for this particular html tag. A more complete solution should be implemented. 1. Add all html tags to table so they are recognized. Some input on what is desirable/safe would be appreciated 2. Change the lex strategy to deal with this in a different manner Fixes #32680 --------- Co-authored-by: Brock Denson <[email protected]>
1 parent a66d8f6 commit 65ffa53

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ Bug Fixes to AST Handling
230230
- Fix incorrect name qualifiers applied to alias CTAD. (#GH136624)
231231
- Fixed ElaboratedTypes appearing within NestedNameSpecifier, which was not a
232232
legal representation. This is fixed because ElaboratedTypes don't exist anymore. (#GH43179) (#GH68670) (#GH92757)
233+
- Fix unrecognized html tag causing undesirable comment lexing (#GH152944)
233234
- Fix comment lexing of special command names (#GH152943)
234235

235236
Miscellaneous Bug Fixes

clang/include/clang/AST/CommentHTMLTags.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ def Col : Tag<"col"> { let EndTagForbidden = 1; }
5151
def Tr : Tag<"tr"> { let EndTagOptional = 1; }
5252
def Th : Tag<"th"> { let EndTagOptional = 1; }
5353
def Td : Tag<"td"> { let EndTagOptional = 1; }
54+
def Summary : Tag<"summary">;
55+
def Details : Tag<"details">;
56+
def Mark : Tag<"mark">;
57+
def Figure : Tag<"figure">;
58+
def FigCaption : Tag<"figcaption">;
5459

5560
// Define a list of attributes that are not safe to pass through to HTML
5661
// output if the input is untrusted.

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

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,50 @@ void Test_TemplatedFunctionVariadic(int arg, ...);
132132
// CHECK-NEXT: ParagraphComment
133133
// CHECK-NEXT: TextComment{{.*}} Text=" More arguments"
134134

135+
/// \param[out] Aaa <summary>Short summary</summary>
136+
int Test_HTMLSummaryTag(int Aaa);
137+
// CHECK: FunctionDecl{{.*}}Test_HTMLSummaryTag
138+
// CHECK: ParamCommandComment{{.*}} [out] explicitly Param="Aaa"
139+
// CHECK-NEXT: ParagraphComment
140+
// CHECK: HTMLStartTagComment{{.*}} Name="summary"
141+
// CHECK-NEXT: TextComment{{.*}} Text="Short summary"
142+
// CHECK-NEXT: HTMLEndTagComment{{.*}} Name="summary"
143+
135144
/// \thread_safe test for underscore in special command
136145
int Test_UnderscoreInSpecialCommand;
137146
// CHECK: VarDecl{{.*}}Test_UnderscoreInSpecialCommand 'int'
138147
// CHECK: InlineCommandComment{{.*}} Name="thread_safe" RenderNormal
139148
// CHECK-NEXT: TextComment{{.*}} Text=" test for underscore in special command"
149+
150+
/// <details>
151+
/// <summary>
152+
/// Summary
153+
/// </summary>
154+
/// <p>Details</p>
155+
/// </details>
156+
///
157+
/// Some <mark>highlighting</mark>
158+
///
159+
/// <figure>
160+
/// <img src="pic.jpg">
161+
/// <figcaption>Figure 1</figcaption>
162+
/// </figure>
163+
int Test_AdditionalHTMLTags(int Aaa);
164+
// CHECK: FunctionDecl{{.*}}Test_AdditionalHTMLTags 'int (int)'
165+
// CHECK: HTMLStartTagComment{{.*}} Name="details"
166+
// CHECK: HTMLStartTagComment{{.*}} Name="summary"
167+
// CHECK-NEXT: TextComment{{.*}} Text=" Summary"
168+
// CHECK: HTMLEndTagComment{{.*}} Name="summary"
169+
// CHECK: HTMLStartTagComment{{.*}} Name="p"
170+
// CHECK-NEXT: TextComment{{.*}} Text="Details"
171+
// CHECK-NEXT: HTMLEndTagComment{{.*}} Name="p"
172+
// CHECK: HTMLEndTagComment{{.*}} Name="details"
173+
// CHECK: HTMLStartTagComment{{.*}} Name="mark"
174+
// CHECK-NEXT: TextComment{{.*}} Text="highlighting"
175+
// CHECK-NEXT: HTMLEndTagComment{{.*}} Name="mark"
176+
// CHECK: HTMLStartTagComment{{.*}} Name="figure"
177+
// CHECK: HTMLStartTagComment{{.*}} Name="img" Attrs: "src="pic.jpg"
178+
// CHECK: HTMLStartTagComment{{.*}} Name="figcaption"
179+
// CHECK-NEXT: TextComment{{.*}} Text="Figure 1"
180+
// CHECK-NEXT: HTMLEndTagComment{{.*}} Name="figcaption"
181+
// CHECK: HTMLEndTagComment{{.*}} Name="figure"

0 commit comments

Comments
 (0)