[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / ExtractAPI / method_template.cpp
blobbf91a208c54884fa4b4e2c615d582f82cd391332
1 // RUN: rm -rf %t
2 // RUN: split-file %s %t
3 // RUN: sed -e "s@INPUT_DIR@%{/t:regex_replacement}@g" \
4 // RUN: %t/reference.output.json.in >> %t/reference.output.json
5 // RUN: %clang_cc1 -extract-api --pretty-sgf -triple arm64-apple-macosx \
6 // RUN: -x c++-header %t/input.h -o %t/output.json -verify
8 // Generator version is not consistent across test runs, normalize it.
9 // RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
10 // RUN: %t/output.json >> %t/output-normalized.json
11 // RUN: diff %t/reference.output.json %t/output-normalized.json
13 //--- input.h
14 class Foo {
15 template<typename T> void Bar(T Fizz);
18 /// expected-no-diagnostics
20 //--- reference.output.json.in
22 "metadata": {
23 "formatVersion": {
24 "major": 0,
25 "minor": 5,
26 "patch": 3
28 "generator": "?"
30 "module": {
31 "name": "",
32 "platform": {
33 "architecture": "arm64",
34 "operatingSystem": {
35 "minimumVersion": {
36 "major": 11,
37 "minor": 0,
38 "patch": 0
40 "name": "macosx"
42 "vendor": "apple"
45 "relationships": [
47 "kind": "memberOf",
48 "source": "c:@S@Foo@FT@>1#TBar#t0.0#v#",
49 "target": "c:@S@Foo",
50 "targetFallback": "Foo"
53 "symbols": [
55 "accessLevel": "public",
56 "declarationFragments": [
58 "kind": "keyword",
59 "spelling": "class"
62 "kind": "text",
63 "spelling": " "
66 "kind": "identifier",
67 "spelling": "Foo"
70 "kind": "text",
71 "spelling": ";"
74 "identifier": {
75 "interfaceLanguage": "c++",
76 "precise": "c:@S@Foo"
78 "kind": {
79 "displayName": "Class",
80 "identifier": "c++.class"
82 "location": {
83 "position": {
84 "character": 6,
85 "line": 0
87 "uri": "file://INPUT_DIR/input.h"
89 "names": {
90 "navigator": [
92 "kind": "identifier",
93 "spelling": "Foo"
96 "subHeading": [
98 "kind": "identifier",
99 "spelling": "Foo"
102 "title": "Foo"
104 "pathComponents": [
105 "Foo"
109 "accessLevel": "private",
110 "declarationFragments": [
112 "kind": "keyword",
113 "spelling": "template"
116 "kind": "text",
117 "spelling": " <"
120 "kind": "keyword",
121 "spelling": "typename"
124 "kind": "text",
125 "spelling": " "
128 "kind": "genericParameter",
129 "spelling": "T"
132 "kind": "text",
133 "spelling": "> "
136 "kind": "typeIdentifier",
137 "preciseIdentifier": "c:v",
138 "spelling": "void"
141 "kind": "text",
142 "spelling": " "
145 "kind": "identifier",
146 "spelling": "Bar"
149 "kind": "text",
150 "spelling": "("
153 "kind": "typeIdentifier",
154 "preciseIdentifier": "c:t0.0",
155 "spelling": "T"
158 "kind": "text",
159 "spelling": " "
162 "kind": "internalParam",
163 "spelling": "Fizz"
166 "kind": "text",
167 "spelling": ");"
170 "functionSignature": {
171 "parameters": [
173 "declarationFragments": [
175 "kind": "typeIdentifier",
176 "preciseIdentifier": "c:t0.0",
177 "spelling": "T"
180 "kind": "text",
181 "spelling": " "
184 "kind": "internalParam",
185 "spelling": "Fizz"
188 "name": "Fizz"
191 "returns": [
193 "kind": "typeIdentifier",
194 "preciseIdentifier": "c:v",
195 "spelling": "void"
199 "identifier": {
200 "interfaceLanguage": "c++",
201 "precise": "c:@S@Foo@FT@>1#TBar#t0.0#v#"
203 "kind": {
204 "displayName": "Method Template",
205 "identifier": "c++.method"
207 "location": {
208 "position": {
209 "character": 28,
210 "line": 1
212 "uri": "file://INPUT_DIR/input.h"
214 "names": {
215 "navigator": [
217 "kind": "identifier",
218 "spelling": "Bar"
221 "subHeading": [
223 "kind": "identifier",
224 "spelling": "Bar"
227 "title": "Bar"
229 "pathComponents": [
230 "Foo",
231 "Bar"
233 "swiftGenerics": {
234 "parameters": [
236 "depth": 0,
237 "index": 0,
238 "name": "T"