@@ -18,65 +18,71 @@ private module Cached {
18
18
19
19
pragma [ nomagic]
20
20
private TypeTracker noContentTypeTracker ( boolean hasCall ) {
21
- result = MkTypeTracker ( hasCall , noContent ( ) )
21
+ result = MkTypeTracker ( hasCall , noContentSet ( ) )
22
22
}
23
23
24
24
/** Gets the summary resulting from appending `step` to type-tracking summary `tt`. */
25
25
cached
26
26
TypeTracker append ( TypeTracker tt , StepSummary step ) {
27
- exists ( Boolean hasCall , OptionalTypeTrackerContent currentContent |
28
- tt = MkTypeTracker ( hasCall , currentContent )
27
+ exists ( Boolean hasCall , OptionalTypeTrackerContentSet currentContents |
28
+ tt = MkTypeTracker ( hasCall , currentContents )
29
29
|
30
30
step = LevelStep ( ) and result = tt
31
31
or
32
- step = CallStep ( ) and result = MkTypeTracker ( true , currentContent )
32
+ step = CallStep ( ) and result = MkTypeTracker ( true , currentContents )
33
33
or
34
34
step = ReturnStep ( ) and hasCall = false and result = tt
35
35
or
36
36
step = JumpStep ( ) and
37
- result = MkTypeTracker ( false , currentContent )
37
+ result = MkTypeTracker ( false , currentContents )
38
38
)
39
39
or
40
- exists ( TypeTrackerContentSet contents , boolean hasCall |
41
- step = LoadStep ( pragma [ only_bind_into ] ( contents ) ) and
42
- tt = MkTypeTracker ( hasCall , contents .getAReadContent ( ) ) and
43
- result = noContentTypeTracker ( hasCall )
40
+ exists ( TypeTrackerContentSet storeContents , boolean hasCall |
41
+ exists ( TypeTrackerContentSet loadContents |
42
+ step = LoadStep ( pragma [ only_bind_into ] ( loadContents ) ) and
43
+ tt = MkTypeTracker ( hasCall , storeContents ) and
44
+ storeContents .getAStoreContent ( ) = loadContents .getAReadContent ( ) and
45
+ result = noContentTypeTracker ( hasCall )
46
+ )
44
47
or
45
- step = StoreStep ( pragma [ only_bind_into ] ( contents ) ) and
48
+ step = StoreStep ( pragma [ only_bind_into ] ( storeContents ) ) and
46
49
tt = noContentTypeTracker ( hasCall ) and
47
- result = MkTypeTracker ( hasCall , contents . getAStoreContent ( ) )
50
+ result = MkTypeTracker ( hasCall , storeContents )
48
51
)
49
52
}
50
53
51
54
pragma [ nomagic]
52
55
private TypeBackTracker noContentTypeBackTracker ( boolean hasReturn ) {
53
- result = MkTypeBackTracker ( hasReturn , noContent ( ) )
56
+ result = MkTypeBackTracker ( hasReturn , noContentSet ( ) )
54
57
}
55
58
56
59
/** Gets the summary resulting from prepending `step` to this type-tracking summary. */
57
60
cached
58
61
TypeBackTracker prepend ( TypeBackTracker tbt , StepSummary step ) {
59
- exists ( Boolean hasReturn , OptionalTypeTrackerContent content |
60
- tbt = MkTypeBackTracker ( hasReturn , content )
62
+ exists ( Boolean hasReturn , OptionalTypeTrackerContentSet contents |
63
+ tbt = MkTypeBackTracker ( hasReturn , contents )
61
64
|
62
65
step = LevelStep ( ) and result = tbt
63
66
or
64
67
step = CallStep ( ) and hasReturn = false and result = tbt
65
68
or
66
- step = ReturnStep ( ) and result = MkTypeBackTracker ( true , content )
69
+ step = ReturnStep ( ) and result = MkTypeBackTracker ( true , contents )
67
70
or
68
71
step = JumpStep ( ) and
69
- result = MkTypeBackTracker ( false , content )
72
+ result = MkTypeBackTracker ( false , contents )
70
73
)
71
74
or
72
- exists ( TypeTrackerContentSet contents , boolean hasReturn |
73
- step = StoreStep ( pragma [ only_bind_into ] ( contents ) ) and
74
- tbt = MkTypeBackTracker ( hasReturn , contents .getAReadContent ( ) ) and
75
- result = noContentTypeBackTracker ( hasReturn )
75
+ exists ( TypeTrackerContentSet loadContents , boolean hasReturn |
76
+ exists ( TypeTrackerContentSet storeContents |
77
+ step = StoreStep ( pragma [ only_bind_into ] ( storeContents ) ) and
78
+ tbt = MkTypeBackTracker ( hasReturn , loadContents ) and
79
+ storeContents .getAStoreContent ( ) = loadContents .getAReadContent ( ) and
80
+ result = noContentTypeBackTracker ( hasReturn )
81
+ )
76
82
or
77
- step = LoadStep ( pragma [ only_bind_into ] ( contents ) ) and
83
+ step = LoadStep ( pragma [ only_bind_into ] ( loadContents ) ) and
78
84
tbt = noContentTypeBackTracker ( hasReturn ) and
79
- result = MkTypeBackTracker ( hasReturn , contents . getAStoreContent ( ) )
85
+ result = MkTypeBackTracker ( hasReturn , loadContents )
80
86
)
81
87
}
82
88
@@ -216,7 +222,8 @@ module StepSummary {
216
222
}
217
223
}
218
224
219
- private newtype TTypeTracker = MkTypeTracker ( Boolean hasCall , OptionalTypeTrackerContent content )
225
+ private newtype TTypeTracker =
226
+ MkTypeTracker ( Boolean hasCall , OptionalTypeTrackerContentSet contents )
220
227
221
228
/**
222
229
* A summary of the steps needed to track a value to a given dataflow node.
@@ -247,9 +254,9 @@ private newtype TTypeTracker = MkTypeTracker(Boolean hasCall, OptionalTypeTracke
247
254
*/
248
255
class TypeTracker extends TTypeTracker {
249
256
Boolean hasCall ;
250
- OptionalTypeTrackerContent content ;
257
+ OptionalTypeTrackerContentSet contents ;
251
258
252
- TypeTracker ( ) { this = MkTypeTracker ( hasCall , content ) }
259
+ TypeTracker ( ) { this = MkTypeTracker ( hasCall , contents ) }
253
260
254
261
/** Gets the summary resulting from appending `step` to this type-tracking summary. */
255
262
TypeTracker append ( StepSummary step ) { result = append ( this , step ) }
@@ -259,8 +266,8 @@ class TypeTracker extends TTypeTracker {
259
266
exists ( string withCall , string withContent |
260
267
( if hasCall = true then withCall = "with" else withCall = "without" ) and
261
268
(
262
- if content != noContent ( )
263
- then withContent = " with content " + content
269
+ if contents != noContentSet ( )
270
+ then withContent = " with content " + contents
264
271
else withContent = ""
265
272
) and
266
273
result = "type tracker " + withCall + " call steps" + withContent
@@ -270,26 +277,26 @@ class TypeTracker extends TTypeTracker {
270
277
/**
271
278
* Holds if this is the starting point of type tracking.
272
279
*/
273
- predicate start ( ) { hasCall = false and content = noContent ( ) }
280
+ predicate start ( ) { hasCall = false and contents = noContentSet ( ) }
274
281
275
282
/**
276
283
* Holds if this is the starting point of type tracking, and the value starts in the content named `contentName`.
277
284
* The type tracking only ends after the content has been loaded.
278
285
*/
279
- predicate startInContent ( TypeTrackerContent contentName ) {
280
- hasCall = false and content = contentName
286
+ predicate startInContent ( TypeTrackerContentSet contentName ) {
287
+ hasCall = false and contents = contentName
281
288
}
282
289
283
290
/**
284
291
* Holds if this is the starting point of type tracking
285
292
* when tracking a parameter into a call, but not out of it.
286
293
*/
287
- predicate call ( ) { hasCall = true and content = noContent ( ) }
294
+ predicate call ( ) { hasCall = true and contents = noContentSet ( ) }
288
295
289
296
/**
290
297
* Holds if this is the end point of type tracking.
291
298
*/
292
- predicate end ( ) { content = noContent ( ) }
299
+ predicate end ( ) { contents = noContentSet ( ) }
293
300
294
301
/**
295
302
* INTERNAL. DO NOT USE.
@@ -303,15 +310,15 @@ class TypeTracker extends TTypeTracker {
303
310
*
304
311
* Gets the content associated with this type tracker.
305
312
*/
306
- OptionalTypeTrackerContent getContent ( ) { result = content }
313
+ OptionalTypeTrackerContentSet getContent ( ) { result = contents }
307
314
308
315
/**
309
316
* Gets a type tracker that starts where this one has left off to allow continued
310
317
* tracking.
311
318
*
312
319
* This predicate is only defined if the type is not associated to a piece of content.
313
320
*/
314
- TypeTracker continue ( ) { content = noContent ( ) and result = this }
321
+ TypeTracker continue ( ) { contents = noContentSet ( ) and result = this }
315
322
316
323
/**
317
324
* Gets the summary that corresponds to having taken a forwards
@@ -370,7 +377,7 @@ module TypeTracker {
370
377
}
371
378
372
379
private newtype TTypeBackTracker =
373
- MkTypeBackTracker ( Boolean hasReturn , OptionalTypeTrackerContent content )
380
+ MkTypeBackTracker ( Boolean hasReturn , OptionalTypeTrackerContentSet contents )
374
381
375
382
/**
376
383
* A summary of the steps needed to back-track a use of a value to a given dataflow node.
@@ -404,9 +411,9 @@ private newtype TTypeBackTracker =
404
411
*/
405
412
class TypeBackTracker extends TTypeBackTracker {
406
413
Boolean hasReturn ;
407
- OptionalTypeTrackerContent content ;
414
+ OptionalTypeTrackerContentSet contents ;
408
415
409
- TypeBackTracker ( ) { this = MkTypeBackTracker ( hasReturn , content ) }
416
+ TypeBackTracker ( ) { this = MkTypeBackTracker ( hasReturn , contents ) }
410
417
411
418
/** Gets the summary resulting from prepending `step` to this type-tracking summary. */
412
419
TypeBackTracker prepend ( StepSummary step ) { result = prepend ( this , step ) }
@@ -416,8 +423,8 @@ class TypeBackTracker extends TTypeBackTracker {
416
423
exists ( string withReturn , string withContent |
417
424
( if hasReturn = true then withReturn = "with" else withReturn = "without" ) and
418
425
(
419
- if content != noContent ( )
420
- then withContent = " with content " + content
426
+ if contents != noContentSet ( )
427
+ then withContent = " with content " + contents
421
428
else withContent = ""
422
429
) and
423
430
result = "type back-tracker " + withReturn + " return steps" + withContent
@@ -427,12 +434,12 @@ class TypeBackTracker extends TTypeBackTracker {
427
434
/**
428
435
* Holds if this is the starting point of type tracking.
429
436
*/
430
- predicate start ( ) { hasReturn = false and content = noContent ( ) }
437
+ predicate start ( ) { hasReturn = false and contents = noContentSet ( ) }
431
438
432
439
/**
433
440
* Holds if this is the end point of type tracking.
434
441
*/
435
- predicate end ( ) { content = noContent ( ) }
442
+ predicate end ( ) { contents = noContentSet ( ) }
436
443
437
444
/**
438
445
* INTERNAL. DO NOT USE.
@@ -447,7 +454,7 @@ class TypeBackTracker extends TTypeBackTracker {
447
454
*
448
455
* This predicate is only defined if the type has not been tracked into a piece of content.
449
456
*/
450
- TypeBackTracker continue ( ) { content = noContent ( ) and result = this }
457
+ TypeBackTracker continue ( ) { contents = noContentSet ( ) and result = this }
451
458
452
459
/**
453
460
* Gets the summary that corresponds to having taken a backwards
@@ -504,7 +511,7 @@ class TypeBackTracker extends TTypeBackTracker {
504
511
* also flow to `sink`.
505
512
*/
506
513
TypeTracker getACompatibleTypeTracker ( ) {
507
- exists ( boolean hasCall | result = MkTypeTracker ( hasCall , content ) |
514
+ exists ( boolean hasCall | result = MkTypeTracker ( hasCall , contents ) |
508
515
hasCall = false or this .hasReturn ( ) = false
509
516
)
510
517
}
0 commit comments