Skip to content

Commit b5de2a5

Browse files
committed
C++: Focus the lambda captures test on stuff inside the lambdas (including some that don't currently have locations).
1 parent d5b9cea commit b5de2a5

File tree

2 files changed

+30
-90
lines changed

2 files changed

+30
-90
lines changed
Lines changed: 21 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,9 @@
1-
| captures.cpp:1:8:1:8 | declaration of operator= |
2-
| captures.cpp:1:8:1:8 | declaration of operator= |
3-
| captures.cpp:1:8:1:8 | operator= |
4-
| captures.cpp:1:8:1:8 | operator= |
5-
| captures.cpp:1:8:1:10 | definition of foo |
6-
| captures.cpp:1:8:1:10 | foo |
7-
| captures.cpp:2:8:2:8 | a |
8-
| captures.cpp:2:8:2:8 | definition of a |
9-
| captures.cpp:2:14:2:14 | definition of x |
10-
| captures.cpp:2:14:2:14 | x |
11-
| captures.cpp:2:17:6:3 | { ... } |
121
| captures.cpp:3:5:3:5 | (unnamed constructor) |
132
| captures.cpp:3:5:3:5 | (unnamed constructor) |
143
| captures.cpp:3:5:3:5 | (unnamed constructor) |
15-
| captures.cpp:3:5:3:5 | declaration of (unnamed constructor) |
16-
| captures.cpp:3:5:3:5 | declaration of (unnamed constructor) |
17-
| captures.cpp:3:5:3:5 | definition of (unnamed constructor) |
18-
| captures.cpp:3:5:3:5 | definition of operator= |
194
| captures.cpp:3:5:3:5 | operator= |
205
| captures.cpp:3:5:5:5 | [...](...){...} |
216
| captures.cpp:3:5:5:5 | {...} |
22-
| captures.cpp:3:5:5:6 | ExprStmt |
237
| captures.cpp:3:6:3:6 | definition of x |
248
| captures.cpp:3:6:3:6 | x |
259
| captures.cpp:3:6:3:6 | x |
@@ -28,7 +12,6 @@
2812
| captures.cpp:3:9:3:9 | definition of (captured this) |
2913
| captures.cpp:3:9:3:12 | (captured this) |
3014
| captures.cpp:3:9:3:12 | this |
31-
| captures.cpp:3:15:3:15 | definition of operator() |
3215
| captures.cpp:3:15:3:15 | operator() |
3316
| captures.cpp:3:15:5:5 | { ... } |
3417
| captures.cpp:4:7:4:7 | (captured this) |
@@ -40,26 +23,14 @@
4023
| captures.cpp:4:9:4:13 | x |
4124
| captures.cpp:4:13:4:13 | 1 |
4225
| captures.cpp:5:5:5:5 | return ... |
43-
| captures.cpp:6:3:6:3 | return ... |
44-
| captures.cpp:8:8:8:8 | b |
45-
| captures.cpp:8:8:8:8 | definition of b |
46-
| captures.cpp:8:14:8:14 | definition of x |
47-
| captures.cpp:8:14:8:14 | x |
48-
| captures.cpp:8:17:12:3 | { ... } |
4926
| captures.cpp:9:5:9:5 | (unnamed constructor) |
5027
| captures.cpp:9:5:9:5 | (unnamed constructor) |
5128
| captures.cpp:9:5:9:5 | (unnamed constructor) |
52-
| captures.cpp:9:5:9:5 | declaration of (unnamed constructor) |
53-
| captures.cpp:9:5:9:5 | declaration of (unnamed constructor) |
54-
| captures.cpp:9:5:9:5 | definition of (unnamed constructor) |
55-
| captures.cpp:9:5:9:5 | definition of operator= |
5629
| captures.cpp:9:5:9:5 | operator= |
5730
| captures.cpp:9:5:11:5 | [...](...){...} |
5831
| captures.cpp:9:5:11:5 | this |
5932
| captures.cpp:9:5:11:5 | x |
6033
| captures.cpp:9:5:11:5 | {...} |
61-
| captures.cpp:9:5:11:6 | ExprStmt |
62-
| captures.cpp:9:9:9:9 | definition of operator() |
6334
| captures.cpp:9:9:9:9 | operator() |
6435
| captures.cpp:9:9:11:5 | { ... } |
6536
| captures.cpp:10:7:10:7 | (captured this) |
@@ -77,48 +48,23 @@
7748
| captures.cpp:10:9:10:13 | x |
7849
| captures.cpp:10:13:10:13 | 1 |
7950
| captures.cpp:11:5:11:5 | return ... |
80-
| captures.cpp:12:3:12:3 | return ... |
81-
| captures.cpp:14:15:14:15 | c |
82-
| captures.cpp:14:15:14:15 | definition of c |
83-
| captures.cpp:14:21:14:21 | definition of x |
84-
| captures.cpp:14:21:14:21 | x |
85-
| captures.cpp:14:24:18:3 | { ... } |
8651
| captures.cpp:15:5:15:5 | (unnamed constructor) |
8752
| captures.cpp:15:5:15:5 | (unnamed constructor) |
8853
| captures.cpp:15:5:15:5 | (unnamed constructor) |
89-
| captures.cpp:15:5:15:5 | declaration of (unnamed constructor) |
90-
| captures.cpp:15:5:15:5 | declaration of (unnamed constructor) |
91-
| captures.cpp:15:5:15:5 | definition of (unnamed constructor) |
92-
| captures.cpp:15:5:15:5 | definition of operator= |
9354
| captures.cpp:15:5:15:5 | operator= |
9455
| captures.cpp:15:5:17:5 | [...](...){...} |
9556
| captures.cpp:15:5:17:5 | {...} |
96-
| captures.cpp:15:5:17:6 | ExprStmt |
9757
| captures.cpp:15:6:15:6 | definition of x |
9858
| captures.cpp:15:6:15:6 | x |
9959
| captures.cpp:15:6:15:6 | x |
10060
| captures.cpp:15:6:15:6 | x |
101-
| captures.cpp:15:9:15:9 | definition of operator() |
10261
| captures.cpp:15:9:15:9 | operator() |
10362
| captures.cpp:15:9:17:5 | { ... } |
10463
| captures.cpp:16:7:16:7 | call to c |
10564
| captures.cpp:16:7:16:11 | ExprStmt |
10665
| captures.cpp:16:9:16:9 | 0 |
107-
| captures.cpp:16:13:16:49 | // `x` is unused, but still captured. |
10866
| captures.cpp:17:5:17:5 | return ... |
109-
| captures.cpp:18:3:18:3 | return ... |
110-
| captures.cpp:21:5:21:5 | d |
111-
| captures.cpp:21:5:21:5 | definition of d |
112-
| captures.cpp:21:11:21:11 | definition of x |
113-
| captures.cpp:21:11:21:11 | x |
114-
| captures.cpp:21:18:21:18 | definition of y |
115-
| captures.cpp:21:18:21:18 | y |
116-
| captures.cpp:21:21:27:1 | { ... } |
117-
| captures.cpp:22:3:24:4 | declaration |
118-
| captures.cpp:22:8:22:15 | definition of myLambda |
119-
| captures.cpp:22:8:22:15 | myLambda |
12067
| captures.cpp:22:18:24:3 | [...](...){...} |
121-
| captures.cpp:22:18:24:3 | initializer for myLambda |
12268
| captures.cpp:22:18:24:3 | y |
12369
| captures.cpp:22:18:24:3 | {...} |
12470
| captures.cpp:22:19:22:19 | (reference dereference) |
@@ -130,10 +76,6 @@
13076
| captures.cpp:22:19:22:19 | (unnamed parameter 0) |
13177
| captures.cpp:22:19:22:19 | constructor init of field x |
13278
| captures.cpp:22:19:22:19 | constructor init of field y |
133-
| captures.cpp:22:19:22:19 | declaration of (unnamed constructor) |
134-
| captures.cpp:22:19:22:19 | definition of (unnamed constructor) |
135-
| captures.cpp:22:19:22:19 | definition of (unnamed constructor) |
136-
| captures.cpp:22:19:22:19 | definition of operator= |
13779
| captures.cpp:22:19:22:19 | operator= |
13880
| captures.cpp:22:19:22:19 | return ... |
13981
| captures.cpp:22:19:22:19 | x |
@@ -143,9 +85,7 @@
14385
| captures.cpp:22:23:22:23 | x |
14486
| captures.cpp:22:23:22:23 | x |
14587
| captures.cpp:22:23:22:23 | x |
146-
| captures.cpp:22:25:22:25 | definition of operator() |
14788
| captures.cpp:22:25:22:25 | operator() |
148-
| captures.cpp:22:30:22:30 | definition of z |
14989
| captures.cpp:22:30:22:30 | z |
15090
| captures.cpp:22:40:24:3 | { ... } |
15191
| captures.cpp:23:5:23:21 | return ... |
@@ -160,40 +100,14 @@
160100
| captures.cpp:23:16:23:16 | y |
161101
| captures.cpp:23:16:23:16 | y |
162102
| captures.cpp:23:20:23:20 | z |
163-
| captures.cpp:26:3:26:24 | return ... |
164-
| captures.cpp:26:10:26:17 | (const lambda [] type at line 22, col. 19)... |
165-
| captures.cpp:26:10:26:17 | myLambda |
166-
| captures.cpp:26:18:26:18 | call to operator() |
167-
| captures.cpp:26:19:26:22 | 1000 |
168-
| end_pos.cpp:2:1:2:14 | #define OPEN { |
169-
| end_pos.cpp:3:6:3:10 | definition of igFun |
170-
| end_pos.cpp:3:6:3:10 | igFun |
171-
| end_pos.cpp:3:14:12:1 | { ... } |
172-
| end_pos.cpp:4:5:4:8 | OPEN |
173-
| end_pos.cpp:4:5:5:5 | { ... } |
174-
| end_pos.cpp:6:5:6:15 | declaration |
175-
| end_pos.cpp:6:9:6:10 | definition of ii |
176-
| end_pos.cpp:6:9:6:10 | ii |
177-
| end_pos.cpp:6:13:6:14 | 0 |
178-
| end_pos.cpp:6:13:6:14 | initializer for ii |
179-
| end_pos.cpp:7:5:7:69 | // EDG used to not give the initialization for this ii capture an |
180-
| end_pos.cpp:8:5:8:20 | // end location: |
181-
| end_pos.cpp:9:5:11:6 | declaration |
182-
| end_pos.cpp:9:10:9:11 | definition of fp |
183-
| end_pos.cpp:9:10:9:11 | fp |
184103
| end_pos.cpp:9:14:11:5 | [...](...){...} |
185-
| end_pos.cpp:9:14:11:5 | initializer for fp |
186104
| end_pos.cpp:9:14:11:5 | {...} |
187105
| end_pos.cpp:9:15:9:15 | (reference dereference) |
188106
| end_pos.cpp:9:15:9:15 | (unnamed constructor) |
189107
| end_pos.cpp:9:15:9:15 | (unnamed constructor) |
190108
| end_pos.cpp:9:15:9:15 | (unnamed constructor) |
191109
| end_pos.cpp:9:15:9:15 | (unnamed parameter 0) |
192110
| end_pos.cpp:9:15:9:15 | constructor init of field ii |
193-
| end_pos.cpp:9:15:9:15 | declaration of (unnamed constructor) |
194-
| end_pos.cpp:9:15:9:15 | definition of (unnamed constructor) |
195-
| end_pos.cpp:9:15:9:15 | definition of (unnamed constructor) |
196-
| end_pos.cpp:9:15:9:15 | definition of operator= |
197111
| end_pos.cpp:9:15:9:15 | ii |
198112
| end_pos.cpp:9:15:9:15 | operator= |
199113
| end_pos.cpp:9:15:9:15 | return ... |
@@ -203,9 +117,28 @@
203117
| end_pos.cpp:9:17:9:18 | (reference to) |
204118
| end_pos.cpp:9:17:9:18 | ii |
205119
| end_pos.cpp:9:17:9:18 | ii |
206-
| end_pos.cpp:9:20:9:20 | definition of operator() |
207120
| end_pos.cpp:9:20:9:20 | operator() |
208121
| end_pos.cpp:9:27:11:5 | { ... } |
209122
| end_pos.cpp:10:9:10:17 | return ... |
210123
| end_pos.cpp:10:16:10:16 | 1 |
211-
| end_pos.cpp:12:1:12:1 | return ... |
124+
| file://:0:0:0:0 | (reference to) |
125+
| file://:0:0:0:0 | (unnamed parameter 0) |
126+
| file://:0:0:0:0 | (unnamed parameter 0) |
127+
| file://:0:0:0:0 | (unnamed parameter 0) |
128+
| file://:0:0:0:0 | (unnamed parameter 0) |
129+
| file://:0:0:0:0 | (unnamed parameter 0) |
130+
| file://:0:0:0:0 | (unnamed parameter 0) |
131+
| file://:0:0:0:0 | (unnamed parameter 0) |
132+
| file://:0:0:0:0 | (unnamed parameter 0) |
133+
| file://:0:0:0:0 | (unnamed parameter 0) |
134+
| file://:0:0:0:0 | (unnamed parameter 0) |
135+
| file://:0:0:0:0 | (unnamed parameter 0) |
136+
| file://:0:0:0:0 | (unnamed parameter 0) |
137+
| file://:0:0:0:0 | (unnamed parameter 0) |
138+
| file://:0:0:0:0 | (unnamed parameter 0) |
139+
| file://:0:0:0:0 | (unnamed parameter 0) |
140+
| file://:0:0:0:0 | decltype([...](...){...}) |
141+
| file://:0:0:0:0 | decltype([...](...){...}) |
142+
| file://:0:0:0:0 | decltype([...](...){...}) |
143+
| file://:0:0:0:0 | decltype([...](...){...}) |
144+
| file://:0:0:0:0 | decltype([...](...){...}) |
Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
import cpp
22

3+
predicate interesting(Element e) {
4+
e instanceof LambdaCapture or
5+
e instanceof LambdaExpression or
6+
e = any(LambdaExpression le).getLambdaFunction() or
7+
e = any(LambdaExpression le).getInitializer() or
8+
e instanceof Closure
9+
}
10+
311
from Element e
412
where
5-
e.getLocation().getFile().getBaseName() != "" and
6-
not e instanceof Container
13+
interesting(e.getEnclosingElement*())
714
select e

0 commit comments

Comments
 (0)