[clang-tools-extra] [clang-doc] Test more language constructs (PR #205585)
Paul Kirth via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 24 09:03:09 PDT 2026
https://github.com/ilovepi created https://github.com/llvm/llvm-project/pull/205585
None
>From bb7824f54ec7a1f1b1f15b84eeb550540728c2dc Mon Sep 17 00:00:00 2001
From: Paul Kirth <paulkirth at google.com>
Date: Thu, 18 Jun 2026 23:24:59 +0000
Subject: [PATCH] [clang-doc] Test more language constructs
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.
---
.../test/clang-doc/Inputs/array-type.cpp | 1 +
.../Inputs/class-partial-specialization.cpp | 2 ++
.../Inputs/function-pointer-type.cpp | 1 +
.../Inputs/member-function-pointer-type.cpp | 2 ++
.../Inputs/nested-pointer-qualifiers.cpp | 1 +
.../test/clang-doc/array-type.cpp | 12 +++++++++
.../class-partial-specialization.cpp | 13 ++++++++++
.../test/clang-doc/function-pointer-type.cpp | 12 +++++++++
.../test/clang-doc/json/array-type.cpp | 18 +++++++++++++
.../json/class-partial-specialization.cpp | 25 +++++++++++++++++++
.../clang-doc/json/function-pointer-type.cpp | 18 +++++++++++++
.../json/member-function-pointer-type.cpp | 18 +++++++++++++
.../json/nested-pointer-qualifiers.cpp | 18 +++++++++++++
.../member-function-pointer-type.cpp | 12 +++++++++
.../clang-doc/nested-pointer-qualifiers.cpp | 12 +++++++++
15 files changed, 165 insertions(+)
create mode 100644 clang-tools-extra/test/clang-doc/Inputs/array-type.cpp
create mode 100644 clang-tools-extra/test/clang-doc/Inputs/class-partial-specialization.cpp
create mode 100644 clang-tools-extra/test/clang-doc/Inputs/function-pointer-type.cpp
create mode 100644 clang-tools-extra/test/clang-doc/Inputs/member-function-pointer-type.cpp
create mode 100644 clang-tools-extra/test/clang-doc/Inputs/nested-pointer-qualifiers.cpp
create mode 100644 clang-tools-extra/test/clang-doc/array-type.cpp
create mode 100644 clang-tools-extra/test/clang-doc/class-partial-specialization.cpp
create mode 100644 clang-tools-extra/test/clang-doc/function-pointer-type.cpp
create mode 100644 clang-tools-extra/test/clang-doc/json/array-type.cpp
create mode 100644 clang-tools-extra/test/clang-doc/json/class-partial-specialization.cpp
create mode 100644 clang-tools-extra/test/clang-doc/json/function-pointer-type.cpp
create mode 100644 clang-tools-extra/test/clang-doc/json/member-function-pointer-type.cpp
create mode 100644 clang-tools-extra/test/clang-doc/json/nested-pointer-qualifiers.cpp
create mode 100644 clang-tools-extra/test/clang-doc/member-function-pointer-type.cpp
create mode 100644 clang-tools-extra/test/clang-doc/nested-pointer-qualifiers.cpp
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 (&)[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 <typename T></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)*
More information about the cfe-commits
mailing list