@@ -72,16 +72,18 @@ private predicate hasVariableWriteWithCapturedRead(BasicBlock bb, LocalVariable
72
72
* Holds if the call `call` at index `i` in basic block `bb` may reach
73
73
* a callable that reads captured variable `v`.
74
74
*/
75
- private predicate capturedCallRead ( Call call , BasicBlock bb , int i , LocalVariable v ) {
75
+ private predicate capturedCallRead (
76
+ CfgNodes:: ExprNodes:: CallCfgNode call , BasicBlock bb , int i , LocalVariable v
77
+ ) {
76
78
exists ( CfgScope scope |
77
79
hasVariableWriteWithCapturedRead ( bb .getAPredecessor * ( ) , v , scope ) and
78
- call = bb .getNode ( i ) . getNode ( )
80
+ call = bb .getNode ( i )
79
81
|
80
82
// If the read happens inside a block, we restrict to the call that
81
83
// contains the block
82
84
not scope instanceof Block
83
85
or
84
- scope = call .( MethodCall ) .getBlock ( )
86
+ scope = call .getExpr ( ) . ( MethodCall ) .getBlock ( )
85
87
)
86
88
}
87
89
@@ -148,16 +150,18 @@ private module Cached {
148
150
* that writes captured variable `v`.
149
151
*/
150
152
cached
151
- predicate capturedCallWrite ( Call call , BasicBlock bb , int i , LocalVariable v ) {
153
+ predicate capturedCallWrite (
154
+ CfgNodes:: ExprNodes:: CallCfgNode call , BasicBlock bb , int i , LocalVariable v
155
+ ) {
152
156
exists ( CfgScope scope |
153
157
hasVariableReadWithCapturedWrite ( bb .getASuccessor * ( ) , v , scope ) and
154
- call = bb .getNode ( i ) . getNode ( )
158
+ call = bb .getNode ( i )
155
159
|
156
160
// If the write happens inside a block, we restrict to the call that
157
161
// contains the block
158
162
not scope instanceof Block
159
163
or
160
- scope = call .( MethodCall ) .getBlock ( )
164
+ scope = call .getExpr ( ) . ( MethodCall ) .getBlock ( )
161
165
)
162
166
}
163
167
@@ -189,7 +193,7 @@ private module Cached {
189
193
190
194
pragma [ noinline]
191
195
private predicate defReachesCallReadInOuterScope (
192
- Definition def , Call call , LocalVariable v , CfgScope scope
196
+ Definition def , CfgNodes :: ExprNodes :: CallCfgNode call , LocalVariable v , CfgScope scope
193
197
) {
194
198
exists ( BasicBlock bb , int i |
195
199
ssaDefReachesRead ( v , def , bb , i ) and
@@ -217,16 +221,16 @@ private module Cached {
217
221
* ```
218
222
*/
219
223
cached
220
- predicate captureFlowIn ( Definition def , Definition entry ) {
221
- exists ( Call call , LocalVariable v , CfgScope scope |
224
+ predicate captureFlowIn ( CfgNodes :: ExprNodes :: CallCfgNode call , Definition def , Definition entry ) {
225
+ exists ( LocalVariable v , CfgScope scope |
222
226
defReachesCallReadInOuterScope ( def , call , v , scope ) and
223
227
hasCapturedEntryWrite ( entry , v , scope )
224
228
|
225
229
// If the read happens inside a block, we restrict to the call that
226
230
// contains the block
227
231
not scope instanceof Block
228
232
or
229
- scope = call .( MethodCall ) .getBlock ( )
233
+ scope = call .getExpr ( ) . ( MethodCall ) .getBlock ( )
230
234
)
231
235
}
232
236
@@ -242,7 +246,9 @@ private module Cached {
242
246
}
243
247
244
248
pragma [ noinline]
245
- private predicate hasCapturedExitRead ( Definition exit , Call call , LocalVariable v , CfgScope scope ) {
249
+ private predicate hasCapturedExitRead (
250
+ Definition exit , CfgNodes:: ExprNodes:: CallCfgNode call , LocalVariable v , CfgScope scope
251
+ ) {
246
252
exists ( BasicBlock bb , int i |
247
253
capturedCallWrite ( call , bb , i , v ) and
248
254
exit .definesAt ( v , bb , i ) and
@@ -261,16 +267,16 @@ private module Cached {
261
267
* ```
262
268
*/
263
269
cached
264
- predicate captureFlowOut ( Definition def , Definition exit ) {
265
- exists ( Call call , LocalVariable v , CfgScope scope |
270
+ predicate captureFlowOut ( CfgNodes :: ExprNodes :: CallCfgNode call , Definition def , Definition exit ) {
271
+ exists ( LocalVariable v , CfgScope scope |
266
272
defReachesExitReadInInnerScope ( def , v , scope ) and
267
273
hasCapturedExitRead ( exit , call , v , _)
268
274
|
269
275
// If the read happens inside a block, we restrict to the call that
270
276
// contains the block
271
277
not scope instanceof Block
272
278
or
273
- scope = call .( MethodCall ) .getBlock ( )
279
+ scope = call .getExpr ( ) . ( MethodCall ) .getBlock ( )
274
280
)
275
281
}
276
282
0 commit comments