forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlambdas.cpp
More file actions
47 lines (40 loc) · 650 Bytes
/
lambdas.cpp
File metadata and controls
47 lines (40 loc) · 650 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
int source();
void sink(...) {};
// --- lambdas ---
void test_lambdas()
{
int t = source();
int u = 0;
int v = 0;
int w = 0;
auto a = [t, u]() -> int {
sink(t); // $ ast,ir
sink(u);
return t;
};
sink(a()); // $ ast,ir
auto b = [&] {
sink(t); // $ ast MISSING: ir
sink(u);
v = source(); // (v is reference captured)
};
b();
sink(v); // $ MISSING: ast,ir
auto c = [=] {
sink(t); // $ ast,ir
sink(u);
};
c();
auto d = [](int a, int b) {
sink(a); // $ ast,ir
sink(b);
};
d(t, u);
auto e = [](int &a, int &b, int &c) {
sink(a); // $ ast,ir
sink(b);
c = source();
};
e(t, u, w);
sink(w); // $ ast,ir
}