Author: Paul Kirth
Date: 2026-06-24T21:52:01-07:00
New Revision: c0e80b94eefd29c7c1b0ae868e5d5092109a1d17

URL: 
https://github.com/llvm/llvm-project/commit/c0e80b94eefd29c7c1b0ae868e5d5092109a1d17
DIFF: 
https://github.com/llvm/llvm-project/commit/c0e80b94eefd29c7c1b0ae868e5d5092109a1d17.diff

LOG: [clang-doc] Test more language constructs (#205585)

We're missing several different language constructs in our tests. This
patch simply adds the basic tests and captures the output without trying
to fix or adjust any behavior, and can be considered a sort of precommit
test for future fixes to the various documentation components.

Added: 
    clang-tools-extra/test/clang-doc/Inputs/array-type.cpp
    clang-tools-extra/test/clang-doc/Inputs/class-partial-specialization.cpp
    clang-tools-extra/test/clang-doc/Inputs/function-pointer-type.cpp
    clang-tools-extra/test/clang-doc/Inputs/member-function-pointer-type.cpp
    clang-tools-extra/test/clang-doc/Inputs/nested-pointer-qualifiers.cpp
    clang-tools-extra/test/clang-doc/array-type.cpp
    clang-tools-extra/test/clang-doc/class-partial-specialization.cpp
    clang-tools-extra/test/clang-doc/function-pointer-type.cpp
    clang-tools-extra/test/clang-doc/json/array-type.cpp
    clang-tools-extra/test/clang-doc/json/class-partial-specialization.cpp
    clang-tools-extra/test/clang-doc/json/function-pointer-type.cpp
    clang-tools-extra/test/clang-doc/json/member-function-pointer-type.cpp
    clang-tools-extra/test/clang-doc/json/nested-pointer-qualifiers.cpp
    clang-tools-extra/test/clang-doc/member-function-pointer-type.cpp
    clang-tools-extra/test/clang-doc/nested-pointer-qualifiers.cpp

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/test/clang-doc/Inputs/array-type.cpp 
b/clang-tools-extra/test/clang-doc/Inputs/array-type.cpp
new file mode 100644
index 0000000000000..74053aa4b0f4a
--- /dev/null
+++ b/clang-tools-extra/test/clang-doc/Inputs/array-type.cpp
@@ -0,0 +1 @@
+void qux(int (&arr)[5]);

diff  --git 
a/clang-tools-extra/test/clang-doc/Inputs/class-partial-specialization.cpp 
b/clang-tools-extra/test/clang-doc/Inputs/class-partial-specialization.cpp
new file mode 100644
index 0000000000000..f36b320138691
--- /dev/null
+++ b/clang-tools-extra/test/clang-doc/Inputs/class-partial-specialization.cpp
@@ -0,0 +1,2 @@
+template<typename T> struct MyClass {};
+template<typename T> struct MyClass<T*> {};

diff  --git a/clang-tools-extra/test/clang-doc/Inputs/function-pointer-type.cpp 
b/clang-tools-extra/test/clang-doc/Inputs/function-pointer-type.cpp
new file mode 100644
index 0000000000000..adbdad6a23f17
--- /dev/null
+++ b/clang-tools-extra/test/clang-doc/Inputs/function-pointer-type.cpp
@@ -0,0 +1 @@
+void bar(void (*fn)(int));

diff  --git 
a/clang-tools-extra/test/clang-doc/Inputs/member-function-pointer-type.cpp 
b/clang-tools-extra/test/clang-doc/Inputs/member-function-pointer-type.cpp
new file mode 100644
index 0000000000000..4bb025a198b6a
--- /dev/null
+++ b/clang-tools-extra/test/clang-doc/Inputs/member-function-pointer-type.cpp
@@ -0,0 +1,2 @@
+struct Class {};
+void baz(void (Class::*fn)(int));

diff  --git 
a/clang-tools-extra/test/clang-doc/Inputs/nested-pointer-qualifiers.cpp 
b/clang-tools-extra/test/clang-doc/Inputs/nested-pointer-qualifiers.cpp
new file mode 100644
index 0000000000000..49cfb4c8567f4
--- /dev/null
+++ b/clang-tools-extra/test/clang-doc/Inputs/nested-pointer-qualifiers.cpp
@@ -0,0 +1 @@
+void foo(const int * const * ptr);

diff  --git a/clang-tools-extra/test/clang-doc/array-type.cpp 
b/clang-tools-extra/test/clang-doc/array-type.cpp
new file mode 100644
index 0000000000000..0e7cef6a60853
--- /dev/null
+++ b/clang-tools-extra/test/clang-doc/array-type.cpp
@@ -0,0 +1,12 @@
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: clang-doc --output=%t --format=html --executor=standalone 
%S/Inputs/array-type.cpp
+// RUN: FileCheck %s --check-prefix=HTML < %t/html/GlobalNamespace/index.html
+// RUN: clang-doc --output=%t --format=md --executor=standalone 
%S/Inputs/array-type.cpp
+// RUN: FileCheck %s --check-prefix=MD < %t/GlobalNamespace/index.md
+// RUN: clang-doc --output=%t --format=md_mustache --executor=standalone 
%S/Inputs/array-type.cpp
+// RUN: FileCheck %s --check-prefix=MD-MUSTACHE < 
%t/md/GlobalNamespace/index.md
+
+// HTML: <pre><code class="language-cpp code-clang-doc">void qux (int 
(&amp;)[5] arr)</code></pre>
+
+// MD: *void qux(int (&)[5] arr)*
+// MD-MUSTACHE: *void qux(int (&)[5] arr)*

diff  --git a/clang-tools-extra/test/clang-doc/class-partial-specialization.cpp 
b/clang-tools-extra/test/clang-doc/class-partial-specialization.cpp
new file mode 100644
index 0000000000000..0eff263bc5632
--- /dev/null
+++ b/clang-tools-extra/test/clang-doc/class-partial-specialization.cpp
@@ -0,0 +1,13 @@
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: clang-doc --output=%t --format=html --executor=standalone 
%S/Inputs/class-partial-specialization.cpp
+// RUN: FileCheck %s --check-prefix=HTML < 
%t/html/GlobalNamespace/_ZTV7MyClassIPT_E.html
+// RUN: clang-doc --output=%t --format=md --executor=standalone 
%S/Inputs/class-partial-specialization.cpp
+// RUN: FileCheck %s --check-prefix=MD < %t/GlobalNamespace/MyClass.md
+// RUN: clang-doc --output=%t --format=md_mustache --executor=standalone 
%S/Inputs/class-partial-specialization.cpp
+// RUN: FileCheck %s --check-prefix=MD-MUSTACHE < 
%t/md/GlobalNamespace/_ZTV7MyClassIPT_E.md
+
+// HTML: <pre><code class="language-cpp code-clang-doc">template &lt;typename 
T&gt;</code></pre>
+// HTML: <h1 class="hero__title-large">struct MyClass</h1>
+
+// MD: # struct MyClass
+// MD-MUSTACHE: # struct MyClass

diff  --git a/clang-tools-extra/test/clang-doc/function-pointer-type.cpp 
b/clang-tools-extra/test/clang-doc/function-pointer-type.cpp
new file mode 100644
index 0000000000000..ede36472564aa
--- /dev/null
+++ b/clang-tools-extra/test/clang-doc/function-pointer-type.cpp
@@ -0,0 +1,12 @@
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: clang-doc --output=%t --format=html --executor=standalone 
%S/Inputs/function-pointer-type.cpp
+// RUN: FileCheck %s --check-prefix=HTML < %t/html/GlobalNamespace/index.html
+// RUN: clang-doc --output=%t --format=md --executor=standalone 
%S/Inputs/function-pointer-type.cpp
+// RUN: FileCheck %s --check-prefix=MD < %t/GlobalNamespace/index.md
+// RUN: clang-doc --output=%t --format=md_mustache --executor=standalone 
%S/Inputs/function-pointer-type.cpp
+// RUN: FileCheck %s --check-prefix=MD-MUSTACHE < 
%t/md/GlobalNamespace/index.md
+
+// HTML: <pre><code class="language-cpp code-clang-doc">void bar (void 
(*)(int) fn)</code></pre>
+
+// MD: *void bar(void (*)(int) fn)*
+// MD-MUSTACHE: *void bar(void (*)(int) fn)*

diff  --git a/clang-tools-extra/test/clang-doc/json/array-type.cpp 
b/clang-tools-extra/test/clang-doc/json/array-type.cpp
new file mode 100644
index 0000000000000..861210879a887
--- /dev/null
+++ b/clang-tools-extra/test/clang-doc/json/array-type.cpp
@@ -0,0 +1,18 @@
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: clang-doc --pretty-json --output=%t --format=json 
--executor=standalone %S/../Inputs/array-type.cpp
+// RUN: FileCheck %s < %t/json/GlobalNamespace/index.json
+
+// CHECK:          "Functions": [
+// CHECK-NEXT:       {
+// CHECK:              "Name": "qux",
+// CHECK:              "Params": [
+// CHECK-NEXT:           {
+// CHECK-NEXT:             "Name": "arr",
+// CHECK-NEXT:             "ParamEnd": true,
+// CHECK-NEXT:             "Type": {
+// CHECK-NEXT:               "Name": "int (&)[5]",
+// CHECK-NEXT:               "QualName": "int (&)[5]",
+// CHECK-NEXT:               "USR": "0000000000000000000000000000000000000000"
+// CHECK-NEXT:             }
+// CHECK-NEXT:           }
+// CHECK-NEXT:         ]

diff  --git 
a/clang-tools-extra/test/clang-doc/json/class-partial-specialization.cpp 
b/clang-tools-extra/test/clang-doc/json/class-partial-specialization.cpp
new file mode 100644
index 0000000000000..c5d2a65f5e53f
--- /dev/null
+++ b/clang-tools-extra/test/clang-doc/json/class-partial-specialization.cpp
@@ -0,0 +1,25 @@
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: clang-doc --pretty-json --output=%t --format=json 
--executor=standalone %S/../Inputs/class-partial-specialization.cpp
+// RUN: FileCheck %s < %t/json/GlobalNamespace/_ZTV7MyClassIPT_E.json
+
+// CHECK:      "MangledName": "_ZTV7MyClassIPT_E",
+// CHECK-NEXT: "Name": "MyClass",
+// CHECK:      "Template": {
+// CHECK-NEXT:   "Parameters": [
+// CHECK-NEXT:     {
+// CHECK-NEXT:       "End": true,
+// CHECK-NEXT:       "Param": "typename T"
+// CHECK-NEXT:     }
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "Specialization": {
+// CHECK-NEXT:     "Parameters": [
+// CHECK-NEXT:       {
+// CHECK-NEXT:         "Param": "T*",
+// CHECK-NEXT:         "SpecParamEnd": true
+// CHECK-NEXT:       }
+// CHECK-NEXT:     ],
+// CHECK-NEXT:     "SpecializationOf": "{{[0-9A-F]*}}",
+// CHECK-NEXT:     "VerticalDisplay": false
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "VerticalDisplay": false
+// CHECK-NEXT: }

diff  --git a/clang-tools-extra/test/clang-doc/json/function-pointer-type.cpp 
b/clang-tools-extra/test/clang-doc/json/function-pointer-type.cpp
new file mode 100644
index 0000000000000..34b693bc67d2b
--- /dev/null
+++ b/clang-tools-extra/test/clang-doc/json/function-pointer-type.cpp
@@ -0,0 +1,18 @@
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: clang-doc --pretty-json --output=%t --format=json 
--executor=standalone %S/../Inputs/function-pointer-type.cpp
+// RUN: FileCheck %s < %t/json/GlobalNamespace/index.json
+
+// CHECK:          "Functions": [
+// CHECK-NEXT:       {
+// CHECK:              "Name": "bar",
+// CHECK:              "Params": [
+// CHECK-NEXT:           {
+// CHECK-NEXT:             "Name": "fn",
+// CHECK-NEXT:             "ParamEnd": true,
+// CHECK-NEXT:             "Type": {
+// CHECK-NEXT:               "Name": "void (*)(int)",
+// CHECK-NEXT:               "QualName": "void (*)(int)",
+// CHECK-NEXT:               "USR": "0000000000000000000000000000000000000000"
+// CHECK-NEXT:             }
+// CHECK-NEXT:           }
+// CHECK-NEXT:         ]

diff  --git 
a/clang-tools-extra/test/clang-doc/json/member-function-pointer-type.cpp 
b/clang-tools-extra/test/clang-doc/json/member-function-pointer-type.cpp
new file mode 100644
index 0000000000000..8ca1ecbb1d14d
--- /dev/null
+++ b/clang-tools-extra/test/clang-doc/json/member-function-pointer-type.cpp
@@ -0,0 +1,18 @@
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: clang-doc --pretty-json --output=%t --format=json 
--executor=standalone %S/../Inputs/member-function-pointer-type.cpp
+// RUN: FileCheck %s < %t/json/GlobalNamespace/index.json
+
+// CHECK:          "Functions": [
+// CHECK-NEXT:       {
+// CHECK:              "Name": "baz",
+// CHECK:              "Params": [
+// CHECK-NEXT:           {
+// CHECK-NEXT:             "Name": "fn",
+// CHECK-NEXT:             "ParamEnd": true,
+// CHECK-NEXT:             "Type": {
+// CHECK-NEXT:               "Name": "void (Class::*)(int)",
+// CHECK-NEXT:               "QualName": "void (Class::*)(int)",
+// CHECK-NEXT:               "USR": "0000000000000000000000000000000000000000"
+// CHECK-NEXT:             }
+// CHECK-NEXT:           }
+// CHECK-NEXT:         ]

diff  --git 
a/clang-tools-extra/test/clang-doc/json/nested-pointer-qualifiers.cpp 
b/clang-tools-extra/test/clang-doc/json/nested-pointer-qualifiers.cpp
new file mode 100644
index 0000000000000..5a3e8842b8036
--- /dev/null
+++ b/clang-tools-extra/test/clang-doc/json/nested-pointer-qualifiers.cpp
@@ -0,0 +1,18 @@
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: clang-doc --pretty-json --output=%t --format=json 
--executor=standalone %S/../Inputs/nested-pointer-qualifiers.cpp
+// RUN: FileCheck %s < %t/json/GlobalNamespace/index.json
+
+// CHECK:          "Functions": [
+// CHECK-NEXT:       {
+// CHECK:              "Name": "foo",
+// CHECK:              "Params": [
+// CHECK-NEXT:           {
+// CHECK-NEXT:             "Name": "ptr",
+// CHECK-NEXT:             "ParamEnd": true,
+// CHECK-NEXT:             "Type": {
+// CHECK-NEXT:               "Name": "const int *const *",
+// CHECK-NEXT:               "QualName": "const int *const *",
+// CHECK-NEXT:               "USR": "0000000000000000000000000000000000000000"
+// CHECK-NEXT:             }
+// CHECK-NEXT:           }
+// CHECK-NEXT:         ]

diff  --git a/clang-tools-extra/test/clang-doc/member-function-pointer-type.cpp 
b/clang-tools-extra/test/clang-doc/member-function-pointer-type.cpp
new file mode 100644
index 0000000000000..4906c0c4ca966
--- /dev/null
+++ b/clang-tools-extra/test/clang-doc/member-function-pointer-type.cpp
@@ -0,0 +1,12 @@
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: clang-doc --output=%t --format=html --executor=standalone 
%S/Inputs/member-function-pointer-type.cpp
+// RUN: FileCheck %s --check-prefix=HTML < %t/html/GlobalNamespace/index.html
+// RUN: clang-doc --output=%t --format=md --executor=standalone 
%S/Inputs/member-function-pointer-type.cpp
+// RUN: FileCheck %s --check-prefix=MD < %t/GlobalNamespace/index.md
+// RUN: clang-doc --output=%t --format=md_mustache --executor=standalone 
%S/Inputs/member-function-pointer-type.cpp
+// RUN: FileCheck %s --check-prefix=MD-MUSTACHE < 
%t/md/GlobalNamespace/index.md
+
+// HTML: <pre><code class="language-cpp code-clang-doc">void baz (void 
(Class::*)(int) fn)</code></pre>
+
+// MD: *void baz(void (Class::*)(int) fn)*
+// MD-MUSTACHE: *void baz(void (Class::*)(int) fn)*

diff  --git a/clang-tools-extra/test/clang-doc/nested-pointer-qualifiers.cpp 
b/clang-tools-extra/test/clang-doc/nested-pointer-qualifiers.cpp
new file mode 100644
index 0000000000000..dc204f044711b
--- /dev/null
+++ b/clang-tools-extra/test/clang-doc/nested-pointer-qualifiers.cpp
@@ -0,0 +1,12 @@
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: clang-doc --output=%t --format=html --executor=standalone 
%S/Inputs/nested-pointer-qualifiers.cpp
+// RUN: FileCheck %s --check-prefix=HTML < %t/html/GlobalNamespace/index.html
+// RUN: clang-doc --output=%t --format=md --executor=standalone 
%S/Inputs/nested-pointer-qualifiers.cpp
+// RUN: FileCheck %s --check-prefix=MD < %t/GlobalNamespace/index.md
+// RUN: clang-doc --output=%t --format=md_mustache --executor=standalone 
%S/Inputs/nested-pointer-qualifiers.cpp
+// RUN: FileCheck %s --check-prefix=MD-MUSTACHE < 
%t/md/GlobalNamespace/index.md
+
+// HTML: <pre><code class="language-cpp code-clang-doc">void foo (const int 
*const * ptr)</code></pre>
+
+// MD: *void foo(const int *const * ptr)*
+// MD-MUSTACHE: *void foo(const int *const * ptr)*


        
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to