Debian Codegraph @

index_tests/lambdas/lambda.cc

raw
1 void foo() {
2 int x;
3
4 auto dosomething = [&x](int y) {
5 ++x;
6 ++y;
7 };
8
9 dosomething(1);
10 dosomething(1);
11 dosomething(1);
12 }
13
14 /*
15 OUTPUT:
16 {
17 "includes": [],
18 "skipped_ranges": [],
19 "usr2func": [{
20 "usr": 4259594751088586730,
21 "detailed_name": "void foo()",
22 "qual_name_offset": 5,
23 "short_name": "foo",
24 "spell": "1:6-1:9|1:1-12:2|2|-1",
25 "bases": [],
26 "vars": [12666114896600231317, 2981279427664991319],
27 "callees": ["9:14-9:15|17926497908620168464|3|16420", "10:14-10:15|17926497908620168464|3|16420",
28 "11:14-11:15|17926497908620168464|3|16420"], "kind": 12, "parent_kind": 1, "storage": 0, "declarations": [], "derived":
29 [], "uses": []
30 }, {
31 "usr": 17926497908620168464,
32 "detailed_name": "inline constexpr void foo()::(anon class)::operator()(int y) const",
33 "qual_name_offset": 22,
34 "short_name": "operator()",
35 "bases": [],
36 "vars": [12879188959314906706, 12879188959314906706],
37 "callees": [],
38 "kind": 6,
39 "parent_kind": 0,
40 "storage": 0,
41 "declarations": [],
42 "derived": [],
43 "uses": ["9:14-9:15|16420|-1", "10:14-10:15|16420|-1", "11:14-11:15|16420|-1"]
44 }],
45 "usr2type": [{
46 "usr": 452,
47 "detailed_name": "",
48 "qual_name_offset": 0,
49 "short_name": "",
50 "bases": [],
51 "funcs": [],
52 "types": [],
53 "vars": [],
54 "alias_of": 0,
55 "kind": 0,
56 "parent_kind": 0,
57 "declarations": [],
58 "derived": [],
59 "instances": [12666114896600231317, 12879188959314906706, 12879188959314906706],
60 "uses": []
61 }, {
62 "usr": 14635009347499519042,
63 "detailed_name": "",
64 "qual_name_offset": 0,
65 "short_name": "",
66 "bases": [],
67 "funcs": [],
68 "types": [],
69 "vars": [],
70 "alias_of": 0,
71 "kind": 0,
72 "parent_kind": 0,
73 "declarations": [],
74 "derived": [],
75 "instances": [2981279427664991319],
76 "uses": []
77 }],
78 "usr2var": [{
79 "usr": 2981279427664991319,
80 "detailed_name": "(lambda) dosomething",
81 "qual_name_offset": 9,
82 "short_name": "dosomething",
83 "hover": "(lambda) dosomething = [&x](int y) {\n ++x;\n ++y;\n }",
84 "spell": "4:8-4:19|4:3-7:4|2|-1",
85 "type": 14635009347499519042,
86 "kind": 13,
87 "parent_kind": 12,
88 "storage": 0,
89 "declarations": [],
90 "uses": ["9:3-9:14|4|-1", "10:3-10:14|4|-1", "11:3-11:14|4|-1"]
91 }, {
92 "usr": 12666114896600231317,
93 "detailed_name": "int x",
94 "qual_name_offset": 4,
95 "short_name": "x",
96 "spell": "2:7-2:8|2:3-2:8|2|-1",
97 "type": 452,
98 "kind": 13,
99 "parent_kind": 12,
100 "storage": 0,
101 "declarations": [],
102 "uses": ["4:24-4:25|4|-1", "5:7-5:8|28|-1"]
103 }, {
104 "usr": 12879188959314906706,
105 "detailed_name": "int y",
106 "qual_name_offset": 4,
107 "short_name": "y",
108 "spell": "4:31-4:32|4:27-4:32|1026|-1",
109 "type": 452,
110 "kind": 253,
111 "parent_kind": 6,
112 "storage": 0,
113 "declarations": [],
114 "uses": ["6:7-6:8|28|-1"]
115 }]
116 }
117 */