@@ -13,7 +13,17 @@ def is_source(x):
13
13
return x == "source" or x == b"source" or x == 42 or x == 42.0 or x == 42j
14
14
15
15
16
- def SINK (x ):
16
+ def SINK (x , * , not_present_at_runtime = False ):
17
+ # not_present_at_runtime supports use-cases where we want flow from data-flow layer
18
+ # (so we want to use SINK), but we end up in a siaution where it's not possible to
19
+ # actually get flow from a source at runtime. The only use-case is for the
20
+ # cross-talk tests, where our ability to use if-then-else is limited because doing
21
+ # so would make cfg-splitting kick in, and that would solve the problem trivially
22
+ # (by the splitting).
23
+ if not_present_at_runtime :
24
+ print ("OK" )
25
+ return
26
+
17
27
if is_source (x ):
18
28
print ("OK" )
19
29
else :
@@ -186,6 +196,9 @@ def test_nested_obj_method():
186
196
# ------------------------------------------------------------------------------
187
197
# Crosstalk test -- using different function based on conditional
188
198
# ------------------------------------------------------------------------------
199
+ # NOTE: These tests use `SINK(objy.y, not_present_at_runtime=True)` since it's not
200
+ # possible to use if-then-else statements, since that would make cfg-splitting kick in,
201
+ # and that would solve the problem trivially (by the splitting).
189
202
190
203
class CrosstalkTestX :
191
204
def __init__ (self ):
@@ -229,7 +242,7 @@ def test_no_crosstalk_reference(cond=True):
229
242
SINK (objx .x ) # $ flow="SOURCE, l:-4 -> objx.x"
230
243
SINK_F (objx .y )
231
244
SINK_F (objy .x )
232
- SINK_F (objy .y ) # $ flow="SOURCE, l:-5 -> objy.y"
245
+ SINK (objy .y , not_present_at_runtime = True ) # $ flow="SOURCE, l:-5 -> objy.y"
233
246
234
247
235
248
@expects (8 ) # $ unresolved_call=expects(..) unresolved_call=expects(..)(..)
@@ -252,7 +265,7 @@ def test_potential_crosstalk_different_name(cond=True):
252
265
SINK (objx .x ) # $ MISSING: flow="SOURCE, l:-2 -> objx.x"
253
266
SINK_F (objx .y )
254
267
SINK_F (objy .x )
255
- SINK_F (objy .y ) # $ MISSING: flow="SOURCE, l:-5 -> objy.y"
268
+ SINK (objy .y , not_present_at_runtime = True ) # $ MISSING: flow="SOURCE, l:-5 -> objy.y"
256
269
257
270
258
271
@expects (8 ) # $ unresolved_call=expects(..) unresolved_call=expects(..)(..)
@@ -275,7 +288,7 @@ def test_potential_crosstalk_same_name(cond=True):
275
288
SINK (objx .x ) # $ MISSING: flow="SOURCE, l:-2 -> objx.x"
276
289
SINK_F (objx .y )
277
290
SINK_F (objy .x )
278
- SINK_F (objy .y ) # $ MISSING: flow="SOURCE, l:-5 -> objy.y"
291
+ SINK (objy .y , not_present_at_runtime = True ) # $ MISSING: flow="SOURCE, l:-5 -> objy.y"
279
292
280
293
281
294
@expects (10 ) # $ unresolved_call=expects(..) unresolved_call=expects(..)(..)
@@ -298,10 +311,10 @@ def test_potential_crosstalk_same_name_object_reference(cond=True):
298
311
SINK (objx .x ) # $ MISSING: flow="SOURCE, l:-2 -> objx.x"
299
312
SINK_F (objx .y )
300
313
SINK_F (objy .x )
301
- SINK_F (objy .y ) # $ MISSING: flow="SOURCE, l:-5 -> objy.y"
314
+ SINK (objy .y , not_present_at_runtime = True ) # $ MISSING: flow="SOURCE, l:-5 -> objy.y"
302
315
303
316
SINK (obj .x ) # $ flow="SOURCE, l:-7 -> obj.x"
304
- SINK_F (obj .y ) # $ flow="SOURCE, l:-8 -> obj.y"
317
+ SINK (obj .y , not_present_at_runtime = True ) # $ flow="SOURCE, l:-8 -> obj.y"
305
318
306
319
307
320
# ------------------------------------------------------------------------------
0 commit comments