Skip to content

Commit 6462da7

Browse files
committed
CPP: Another test case.
1 parent 19a0d46 commit 6462da7

File tree

3 files changed

+81
-0
lines changed

3 files changed

+81
-0
lines changed

cpp/ql/test/library-tests/lambdas/captures/captures.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,11 @@ struct foo {
1717
};
1818
}
1919
};
20+
21+
int d(int x, int y) {
22+
auto myLambda = [&, x](int z) -> int {
23+
return x + y + z;
24+
};
25+
26+
return myLambda(1000);
27+
}

cpp/ql/test/library-tests/lambdas/captures/captures.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
| captures.cpp:10:7:10:7 | (captured this) | implicit | 0 | (captured this) | this |
44
| captures.cpp:10:9:10:9 | x | implicit | 1 | x | x |
55
| captures.cpp:15:6:15:6 | x | explicit | 0 | x | x |
6+
| captures.cpp:22:23:22:23 | x | explicit | 0 | x | x |
7+
| captures.cpp:23:16:23:16 | y | implicit | 1 | y | y |
68
| end_pos.cpp:9:17:9:18 | ii | explicit | 0 | ii | ii |

cpp/ql/test/library-tests/lambdas/captures/elements.expected

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,53 @@
9393
| captures.cpp:16:13:16:49 | // `x` is unused, but still captured. |
9494
| captures.cpp:17:5:17:5 | return ... |
9595
| captures.cpp:18:3:18:3 | return ... |
96+
| captures.cpp:21:5:21:5 | d |
97+
| captures.cpp:21:5:21:5 | definition of d |
98+
| captures.cpp:21:11:21:11 | definition of x |
99+
| captures.cpp:21:11:21:11 | x |
100+
| captures.cpp:21:18:21:18 | definition of y |
101+
| captures.cpp:21:18:21:18 | y |
102+
| captures.cpp:21:21:27:1 | { ... } |
103+
| captures.cpp:22:3:24:4 | declaration |
104+
| captures.cpp:22:8:22:15 | definition of myLambda |
105+
| captures.cpp:22:8:22:15 | myLambda |
106+
| captures.cpp:22:18:24:3 | initializer for myLambda |
107+
| captures.cpp:22:19:22:19 | (constructor) |
108+
| captures.cpp:22:19:22:19 | (constructor) |
109+
| captures.cpp:22:19:22:19 | (constructor) |
110+
| captures.cpp:22:19:22:19 | Unknown literal |
111+
| captures.cpp:22:19:22:19 | Unknown literal |
112+
| captures.cpp:22:19:22:19 | constructor init of field x |
113+
| captures.cpp:22:19:22:19 | constructor init of field y |
114+
| captures.cpp:22:19:22:19 | declaration of (null) |
115+
| captures.cpp:22:19:22:19 | definition of (null) |
116+
| captures.cpp:22:19:22:19 | definition of (null) |
117+
| captures.cpp:22:19:22:19 | definition of operator= |
118+
| captures.cpp:22:19:22:19 | operator= |
119+
| captures.cpp:22:19:22:19 | return ... |
120+
| captures.cpp:22:19:22:19 | { ... } |
121+
| captures.cpp:22:19:24:3 | [...](...){...} |
122+
| captures.cpp:22:19:24:3 | {...} |
123+
| captures.cpp:22:23:22:23 | definition of x |
124+
| captures.cpp:22:23:22:23 | x |
125+
| captures.cpp:22:23:22:23 | x |
126+
| captures.cpp:22:25:22:25 | definition of operator() |
127+
| captures.cpp:22:25:22:25 | operator() |
128+
| captures.cpp:22:30:22:30 | definition of z |
129+
| captures.cpp:22:30:22:30 | z |
130+
| captures.cpp:22:40:24:3 | { ... } |
131+
| captures.cpp:23:5:23:21 | return ... |
132+
| captures.cpp:23:12:23:16 | ... + ... |
133+
| captures.cpp:23:12:23:20 | ... + ... |
134+
| captures.cpp:23:16:23:16 | (reference dereference) |
135+
| captures.cpp:23:16:23:16 | definition of y |
136+
| captures.cpp:23:16:23:16 | y |
137+
| captures.cpp:23:20:23:20 | z |
138+
| captures.cpp:26:3:26:24 | return ... |
139+
| captures.cpp:26:10:26:17 | (const lambda [] type at line 22, col. 19)... |
140+
| captures.cpp:26:10:26:17 | myLambda |
141+
| captures.cpp:26:18:26:18 | call to operator() |
142+
| captures.cpp:26:19:26:22 | 1000 |
96143
| end_pos.cpp:0:0:0:0 | end_pos.cpp |
97144
| end_pos.cpp:2:1:2:14 | #define OPEN { |
98145
| end_pos.cpp:3:6:3:10 | definition of igFun |
@@ -139,8 +186,13 @@
139186
| file://:0:0:0:0 | (captured this) |
140187
| file://:0:0:0:0 | (captured this) |
141188
| file://:0:0:0:0 | (global namespace) |
189+
| file://:0:0:0:0 | (reference to) |
142190
| file://:0:0:0:0 | ..()(..) |
191+
| file://:0:0:0:0 | ..()(..) |
192+
| file://:0:0:0:0 | ..(*)(..) |
143193
| file://:0:0:0:0 | ..(*)(..) |
194+
| file://:0:0:0:0 | ..(*)(..) |
195+
| file://:0:0:0:0 | ..(..) |
144196
| file://:0:0:0:0 | __va_list_tag |
145197
| file://:0:0:0:0 | __va_list_tag & |
146198
| file://:0:0:0:0 | __va_list_tag && |
@@ -161,6 +213,11 @@
161213
| file://:0:0:0:0 | const lambda [] type at line 9, col. 15 & |
162214
| file://:0:0:0:0 | const lambda [] type at line 15, col. 5 |
163215
| file://:0:0:0:0 | const lambda [] type at line 15, col. 5 & |
216+
| file://:0:0:0:0 | const lambda [] type at line 22, col. 19 |
217+
| file://:0:0:0:0 | const lambda [] type at line 22, col. 19 & |
218+
| file://:0:0:0:0 | const lambda [] type at line 22, col. 19 * |
219+
| file://:0:0:0:0 | const lambda [] type at line 22, col. 19 *const |
220+
| file://:0:0:0:0 | declaration of 1st parameter |
164221
| file://:0:0:0:0 | declaration of 1st parameter |
165222
| file://:0:0:0:0 | declaration of 1st parameter |
166223
| file://:0:0:0:0 | declaration of 1st parameter |
@@ -175,6 +232,9 @@
175232
| file://:0:0:0:0 | declaration of 1st parameter |
176233
| file://:0:0:0:0 | declaration of 1st parameter |
177234
| file://:0:0:0:0 | declaration of 1st parameter |
235+
| file://:0:0:0:0 | declaration of 1st parameter |
236+
| file://:0:0:0:0 | declaration of 1st parameter |
237+
| file://:0:0:0:0 | decltype([...](...){...}) |
178238
| file://:0:0:0:0 | decltype([...](...){...}) |
179239
| file://:0:0:0:0 | decltype([...](...){...}) |
180240
| file://:0:0:0:0 | decltype([...](...){...}) |
@@ -200,6 +260,9 @@
200260
| file://:0:0:0:0 | lambda [] type at line 9, col. 15 && |
201261
| file://:0:0:0:0 | lambda [] type at line 15, col. 5 & |
202262
| file://:0:0:0:0 | lambda [] type at line 15, col. 5 && |
263+
| file://:0:0:0:0 | lambda [] type at line 22, col. 19 & |
264+
| file://:0:0:0:0 | lambda [] type at line 22, col. 19 && |
265+
| file://:0:0:0:0 | lambda [] type at line 22, col. 19 * |
203266
| file://:0:0:0:0 | operator= |
204267
| file://:0:0:0:0 | operator= |
205268
| file://:0:0:0:0 | overflow_arg_area |
@@ -219,13 +282,21 @@
219282
| file://:0:0:0:0 | p#0 |
220283
| file://:0:0:0:0 | p#0 |
221284
| file://:0:0:0:0 | p#0 |
285+
| file://:0:0:0:0 | p#0 |
286+
| file://:0:0:0:0 | p#0 |
287+
| file://:0:0:0:0 | p#0 |
222288
| file://:0:0:0:0 | reg_save_area |
223289
| file://:0:0:0:0 | this |
224290
| file://:0:0:0:0 | this |
225291
| file://:0:0:0:0 | this |
226292
| file://:0:0:0:0 | this |
227293
| file://:0:0:0:0 | this |
294+
| file://:0:0:0:0 | this |
295+
| file://:0:0:0:0 | this |
228296
| file://:0:0:0:0 | void * |
229297
| file://:0:0:0:0 | x |
230298
| file://:0:0:0:0 | x |
231299
| file://:0:0:0:0 | x |
300+
| file://:0:0:0:0 | x |
301+
| file://:0:0:0:0 | y |
302+
| file://:0:0:0:0 | y |

0 commit comments

Comments
 (0)