[clang] cc16c2c - [clang] Add concepts to XML comment schema, add tests (#202774)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 18 18:05:42 PDT 2026
Author: Erick Velez
Date: 2026-06-18T18:05:37-07:00
New Revision: cc16c2cabacf3cfb904e94f2030b25eefb31c71f
URL: https://github.com/llvm/llvm-project/commit/cc16c2cabacf3cfb904e94f2030b25eefb31c71f
DIFF: https://github.com/llvm/llvm-project/commit/cc16c2cabacf3cfb904e94f2030b25eefb31c71f.diff
LOG: [clang] Add concepts to XML comment schema, add tests (#202774)
Added:
clang/test/Index/Inputs/CommentXML/invalid-concept-01.xml
clang/test/Index/Inputs/CommentXML/valid-concept-01.xml
clang/test/Index/Inputs/CommentXML/valid-concept-02.xml
Modified:
clang/bindings/xml/comment-xml-schema.rng
clang/test/Index/comment-xml-schema.c
Removed:
################################################################################
diff --git a/clang/bindings/xml/comment-xml-schema.rng b/clang/bindings/xml/comment-xml-schema.rng
index 65ea597ed70c1..361569d4910d0 100644
--- a/clang/bindings/xml/comment-xml-schema.rng
+++ b/clang/bindings/xml/comment-xml-schema.rng
@@ -14,6 +14,7 @@
<ref name="Namespace" />
<ref name="Typedef" />
<ref name="Enum" />
+ <ref name="Concept" />
</choice>
</start>
@@ -300,6 +301,41 @@
</element>
</define>
+ <define name="Concept">
+ <element name="Concept">
+ <ref name="attrSourceLocation" />
+ <ref name="Name" />
+ <optional>
+ <ref name="USR" />
+ </optional>
+ <optional>
+ <ref name="Headerfile" />
+ </optional>
+ <optional>
+ <ref name="Declaration" />
+ </optional>
+ <optional>
+ <ref name="Abstract" />
+ </optional>
+ <optional>
+ <ref name="TemplateParameters" />
+ </optional>
+
+ <!-- Parameters and results don't make sense for concepts, but the user
+ can specify \param or \returns in a comment anyway. -->
+ <optional>
+ <ref name="Parameters" />
+ </optional>
+ <optional>
+ <ref name="ResultDiscussion" />
+ </optional>
+
+ <optional>
+ <ref name="Discussion" />
+ </optional>
+ </element>
+ </define>
+
<define name="attrSourceLocation">
<optional>
<attribute name="file">
diff --git a/clang/test/Index/Inputs/CommentXML/invalid-concept-01.xml b/clang/test/Index/Inputs/CommentXML/invalid-concept-01.xml
new file mode 100644
index 0000000000000..516af91345f62
--- /dev/null
+++ b/clang/test/Index/Inputs/CommentXML/invalid-concept-01.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Concept>
+<Abstract><Para>Aaa.</Para></Abstract>
+</Concept>
diff --git a/clang/test/Index/Inputs/CommentXML/valid-concept-01.xml b/clang/test/Index/Inputs/CommentXML/valid-concept-01.xml
new file mode 100644
index 0000000000000..4dea19e584288
--- /dev/null
+++ b/clang/test/Index/Inputs/CommentXML/valid-concept-01.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Concept>
+<Name>aaa</Name>
+<Abstract><Para>Aaa.</Para></Abstract>
+</Concept>
diff --git a/clang/test/Index/Inputs/CommentXML/valid-concept-02.xml b/clang/test/Index/Inputs/CommentXML/valid-concept-02.xml
new file mode 100644
index 0000000000000..67e0a3a21dd5d
--- /dev/null
+++ b/clang/test/Index/Inputs/CommentXML/valid-concept-02.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Concept>
+<Name>aaa</Name>
+<Abstract><Para>Aaa.</Para></Abstract>
+<TemplateParameters>
+ <Parameter>
+ <Name>T</Name>
+ <Index>0</Index>
+ <Discussion><Para>template parameter T</Para></Discussion>
+ </Parameter>
+</TemplateParameters>
+</Concept>
diff --git a/clang/test/Index/comment-xml-schema.c b/clang/test/Index/comment-xml-schema.c
index da529a53c40e9..bd864e8637bf5 100644
--- a/clang/test/Index/comment-xml-schema.c
+++ b/clang/test/Index/comment-xml-schema.c
@@ -35,6 +35,9 @@
// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-para-kind-01.xml
//
// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-inline-command-01.xml
+//
+// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-concept-01.xml
+// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-concept-02.xml
// RUN: not xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/invalid-function-01.xml 2>&1 | FileCheck %s -check-prefix=CHECK-INVALID
// RUN: not xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/invalid-function-02.xml 2>&1 | FileCheck %s -check-prefix=CHECK-INVALID
@@ -52,6 +55,9 @@
//
// RUN: not xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/invalid-para-kind-01.xml 2>&1 | FileCheck %s -check-prefix=CHECK-INVALID
// RUN: not xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/invalid-para-kind-02.xml 2>&1 | FileCheck %s -check-prefix=CHECK-INVALID
+//
+// RUN: not xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/invalid-concept-01.xml 2>&1 | FileCheck %s -check-prefix=CHECK-INVALID
+//
// CHECK-INVALID: fails to validate
More information about the cfe-commits
mailing list