Skip to content

Commit ed42c81

Browse files
authored
[clang-doc] Add JSON output to existing template tests (#171936)
clang-doc has some useful, preexisting tests for templates, so we'll reuse them to cover more cases.
1 parent 112a612 commit ed42c81

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed

clang-tools-extra/test/clang-doc/templates.cpp

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
// RUN: clang-doc --doxygen --executor=standalone %s -output=%t/docs --format=md
88
// RUN: cat %t/docs/GlobalNamespace/index.md | FileCheck %s --check-prefix=MD
99

10+
// RUN: clang-doc --doxygen --executor=standalone %s -output=%t/docs --format=json
11+
// RUN: cat %t/docs/json/GlobalNamespace/index.json | FileCheck %s --check-prefix=JSON
12+
1013
// YAML: ---
1114
// YAML-NEXT: USR: '{{([0-9A-F]{40})}}'
1215
// YAML-NEXT: ChildRecords:
@@ -44,6 +47,27 @@ void ParamPackFunction(T... args);
4447
// MD: ### ParamPackFunction
4548
// MD: *void ParamPackFunction(T... args)*
4649

50+
// JSON: "Name": "ParamPackFunction",
51+
// JSON-NEXT: "Params": [
52+
// JSON-NEXT: {
53+
// JSON-NEXT: "End": true,
54+
// JSON-NEXT: "Name": "args",
55+
// JSON-NEXT: "Type": "T..."
56+
// JSON-NEXT: }
57+
// JSON-NEXT: ],
58+
// JSON-NEXT: "ReturnType": {
59+
// JSON-NEXT: "IsBuiltIn": true,
60+
// JSON-NEXT: "IsTemplate": false,
61+
// JSON-NEXT: "Name": "void",
62+
// JSON-NEXT: "QualName": "void",
63+
// JSON-NEXT: "USR": "0000000000000000000000000000000000000000"
64+
// JSON-NEXT: },
65+
// JSON-NEXT: "Template": {
66+
// JSON-NEXT: "Parameters": [
67+
// JSON-NEXT: "class... T"
68+
// JSON-NEXT: ]
69+
// JSON-NEXT: },
70+
4771
template <typename T, int U = 1>
4872
void function(T x) {}
4973

@@ -70,6 +94,28 @@ void function(T x) {}
7094
// MD: *void function(T x)*
7195
// MD: *Defined at {{.*}}templates.cpp#[[# @LINE - 23]]*
7296

97+
// JSON: "Name": "function",
98+
// JSON-NEXT: "Params": [
99+
// JSON-NEXT: {
100+
// JSON-NEXT: "End": true,
101+
// JSON-NEXT: "Name": "x",
102+
// JSON-NEXT: "Type": "T"
103+
// JSON-NEXT: }
104+
// JSON-NEXT: ],
105+
// JSON-NEXT: "ReturnType": {
106+
// JSON-NEXT: "IsBuiltIn": true,
107+
// JSON-NEXT: "IsTemplate": false,
108+
// JSON-NEXT: "Name": "void",
109+
// JSON-NEXT: "QualName": "void",
110+
// JSON-NEXT: "USR": "0000000000000000000000000000000000000000"
111+
// JSON-NEXT: },
112+
// JSON-NEXT: "Template": {
113+
// JSON-NEXT: "Parameters": [
114+
// JSON-NEXT: "typename T",
115+
// JSON-NEXT: "int U = 1"
116+
// JSON-NEXT: ]
117+
// JSON-NEXT: },
118+
73119
template <>
74120
void function<bool, 0>(bool x) {}
75121

@@ -98,6 +144,31 @@ void function<bool, 0>(bool x) {}
98144
// MD: *void function(bool x)*
99145
// MD: *Defined at {{.*}}templates.cpp#[[# @LINE - 26]]*
100146

147+
// JSON: "Name": "function",
148+
// JSON-NEXT: "Params": [
149+
// JSON-NEXT: {
150+
// JSON-NEXT: "End": true,
151+
// JSON-NEXT: "Name": "x",
152+
// JSON-NEXT: "Type": "bool"
153+
// JSON-NEXT: }
154+
// JSON-NEXT: ],
155+
// JSON-NEXT: "ReturnType": {
156+
// JSON-NEXT: "IsBuiltIn": true,
157+
// JSON-NEXT: "IsTemplate": false,
158+
// JSON-NEXT: "Name": "void",
159+
// JSON-NEXT: "QualName": "void",
160+
// JSON-NEXT: "USR": "0000000000000000000000000000000000000000"
161+
// JSON-NEXT: },
162+
// JSON-NEXT: "Template": {
163+
// JSON-NEXT: "Specialization": {
164+
// JSON-NEXT: "Parameters": [
165+
// JSON-NEXT: "bool",
166+
// JSON-NEXT: "0"
167+
// JSON-NEXT: ],
168+
// JSON-NEXT: "SpecializationOf": "{{([0-9A-F]{40})}}"
169+
// JSON-NEXT: }
170+
// JSON-NEXT: },
171+
101172
/// A Tuple type
102173
///
103174
/// Does Tuple things.
@@ -154,3 +225,20 @@ tuple<int, int, bool> func_with_tuple_param(tuple<int, int, bool> t) { return t;
154225
// MD: *Defined at {{.*}}templates.cpp#[[# @LINE - 44]]*
155226
// MD: A function with a tuple parameter
156227
// MD: **t** The input to func_with_tuple_param
228+
229+
// JSON: "Name": "func_with_tuple_param",
230+
// COM: FIXME: Add type info to parameters
231+
// JSON-NEXT: "Params": [
232+
// JSON-NEXT: {
233+
// JSON-NEXT: "End": true,
234+
// JSON-NEXT: "Name": "t",
235+
// JSON-NEXT: "Type": "tuple"
236+
// JSON-NEXT: }
237+
// JSON-NEXT: ],
238+
// JSON-NEXT: "ReturnType": {
239+
// JSON-NEXT: "IsBuiltIn": false,
240+
// JSON-NEXT: "IsTemplate": false,
241+
// JSON-NEXT: "Name": "tuple",
242+
// JSON-NEXT: "QualName": "tuple<int, int, bool>",
243+
// JSON-NEXT: "USR": "{{([0-9A-F]{40})}}"
244+
// JSON-NEXT: },

0 commit comments

Comments
 (0)