@@ -102,11 +102,7 @@ private predicate summarizedLocalStep(Node nodeFrom, Node nodeTo) {
102
102
}
103
103
104
104
/** Holds if there is a level step from `nodeFrom` to `nodeTo`. */
105
- predicate levelStep ( Node nodeFrom , Node nodeTo ) {
106
- summarizedLocalStep ( nodeFrom , nodeTo )
107
- or
108
- TypeTrackingStep:: step ( nodeFrom , nodeTo )
109
- }
105
+ predicate levelStep ( Node nodeFrom , Node nodeTo ) { summarizedLocalStep ( nodeFrom , nodeTo ) }
110
106
111
107
pragma [ noinline]
112
108
private predicate argumentPositionMatch (
@@ -221,8 +217,6 @@ predicate basicStoreStep(Node nodeFrom, Node nodeTo, DataFlow::ContentSet conten
221
217
nodeFrom = evaluateSummaryComponentStackLocal ( callable , call , input ) and
222
218
nodeTo = evaluateSummaryComponentStackLocal ( callable , call , output )
223
219
)
224
- or
225
- TypeTrackingStep:: storeStep ( nodeFrom , nodeTo , contents )
226
220
}
227
221
228
222
/**
@@ -265,8 +259,6 @@ predicate basicLoadStep(Node nodeFrom, Node nodeTo, DataFlow::ContentSet content
265
259
nodeFrom = evaluateSummaryComponentStackLocal ( callable , call , input ) and
266
260
nodeTo = evaluateSummaryComponentStackLocal ( callable , call , output )
267
261
)
268
- or
269
- TypeTrackingStep:: loadStep ( nodeFrom , nodeTo , contents )
270
262
}
271
263
272
264
/**
@@ -285,8 +277,6 @@ predicate basicLoadStoreStep(
285
277
nodeFrom = evaluateSummaryComponentStackLocal ( callable , call , input ) and
286
278
nodeTo = evaluateSummaryComponentStackLocal ( callable , call , output )
287
279
)
288
- or
289
- TypeTrackingStep:: loadStoreStep ( nodeFrom , nodeTo , loadContent , storeContent )
290
280
}
291
281
292
282
/**
@@ -303,8 +293,6 @@ predicate basicWithoutContentStep(Node nodeFrom, Node nodeTo, ContentFilter filt
303
293
nodeFrom = evaluateSummaryComponentStackLocal ( callable , call , input ) and
304
294
nodeTo = evaluateSummaryComponentStackLocal ( callable , call , output )
305
295
)
306
- or
307
- TypeTrackingStep:: withoutContentStep ( nodeFrom , nodeTo , filter )
308
296
}
309
297
310
298
/**
@@ -321,8 +309,6 @@ predicate basicWithContentStep(Node nodeFrom, Node nodeTo, ContentFilter filter)
321
309
nodeFrom = evaluateSummaryComponentStackLocal ( callable , call , input ) and
322
310
nodeTo = evaluateSummaryComponentStackLocal ( callable , call , output )
323
311
)
324
- or
325
- TypeTrackingStep:: withContentStep ( nodeFrom , nodeTo , filter )
326
312
}
327
313
328
314
/**
@@ -339,7 +325,6 @@ private predicate hasStoreSummary(
339
325
SummarizedCallable callable , DataFlow:: ContentSet contents , SummaryComponentStack input ,
340
326
SummaryComponentStack output
341
327
) {
342
- not TypeTrackingStep:: suppressSummary ( callable ) and
343
328
callable .propagatesFlow ( input , push ( SummaryComponent:: content ( contents ) , output ) , true ) and
344
329
not isNonLocal ( input .head ( ) ) and
345
330
not isNonLocal ( output .head ( ) )
@@ -350,7 +335,6 @@ private predicate hasLoadSummary(
350
335
SummarizedCallable callable , DataFlow:: ContentSet contents , SummaryComponentStack input ,
351
336
SummaryComponentStack output
352
337
) {
353
- not TypeTrackingStep:: suppressSummary ( callable ) and
354
338
callable .propagatesFlow ( push ( SummaryComponent:: content ( contents ) , input ) , output , true ) and
355
339
not isNonLocal ( input .head ( ) ) and
356
340
not isNonLocal ( output .head ( ) )
@@ -361,7 +345,6 @@ private predicate hasLoadStoreSummary(
361
345
SummarizedCallable callable , DataFlow:: ContentSet loadContents ,
362
346
DataFlow:: ContentSet storeContents , SummaryComponentStack input , SummaryComponentStack output
363
347
) {
364
- not TypeTrackingStep:: suppressSummary ( callable ) and
365
348
callable
366
349
.propagatesFlow ( push ( SummaryComponent:: content ( loadContents ) , input ) ,
367
350
push ( SummaryComponent:: content ( storeContents ) , output ) , true ) and
@@ -394,7 +377,6 @@ private predicate hasWithoutContentSummary(
394
377
SummaryComponentStack output
395
378
) {
396
379
exists ( DataFlow:: ContentSet content |
397
- not TypeTrackingStep:: suppressSummary ( callable ) and
398
380
callable .propagatesFlow ( push ( SummaryComponent:: withoutContent ( content ) , input ) , output , true ) and
399
381
filter = getFilterFromWithoutContentStep ( content ) and
400
382
not isNonLocal ( input .head ( ) ) and
@@ -404,12 +386,12 @@ private predicate hasWithoutContentSummary(
404
386
}
405
387
406
388
/**
407
- * Gets a content filter to use for a `WithoutContent [content]` step, or has no result if
408
- * the step should be treated as ordinary flow .
389
+ * Gets a content filter to use for a `WithContent [content]` step, or has no result if
390
+ * the step cannot be handled by type-tracking .
409
391
*
410
- * `WithoutContent ` is often used to perform strong updates on individual collection elements, but for
411
- * type-tracking this is rarely beneficial and quite expensive. However, `WithoutContent` can be quite useful
412
- * for restricting the type of an object, and in these cases we translate it to a filter.
392
+ * `WithContent ` is often used to perform strong updates on individual collection elements (or rather
393
+ * to preserve those that didn't get updated). But for type-tracking this is rarely beneficial and quite expensive.
394
+ * However, `WithContent` can be quite useful for restricting the type of an object, and in these cases we translate it to a filter.
413
395
*/
414
396
private ContentFilter getFilterFromWithContentStep ( DataFlow:: ContentSet content ) {
415
397
(
@@ -430,7 +412,6 @@ private predicate hasWithContentSummary(
430
412
SummaryComponentStack output
431
413
) {
432
414
exists ( DataFlow:: ContentSet content |
433
- not TypeTrackingStep:: suppressSummary ( callable ) and
434
415
callable .propagatesFlow ( push ( SummaryComponent:: withContent ( content ) , input ) , output , true ) and
435
416
filter = getFilterFromWithContentStep ( content ) and
436
417
not isNonLocal ( input .head ( ) ) and
@@ -475,7 +456,6 @@ private predicate dependsOnSummaryComponentStack(
475
456
SummarizedCallable callable , SummaryComponentStack stack
476
457
) {
477
458
exists ( callable .getACallSimple ( ) ) and
478
- not TypeTrackingStep:: suppressSummary ( callable ) and
479
459
(
480
460
callable .propagatesFlow ( stack , _, true )
481
461
or
@@ -544,116 +524,3 @@ private DataFlow::Node evaluateSummaryComponentStackLocal(
544
524
)
545
525
)
546
526
}
547
-
548
- private newtype TUnit = MkUnit ( )
549
-
550
- /**
551
- * A data flow edge that should be followed by type tracking.
552
- *
553
- * This type of edge does not affect the local data flow graph, and is not used by data-flow configurations.
554
- *
555
- * Note: For performance reasons, all subclasses of this class should be part
556
- * of the standard library, and their implementations may not depend on API graphs.
557
- * For query-specific steps, consider including the custom steps in the type-tracking predicate itself.
558
- */
559
- class TypeTrackingStep extends TUnit {
560
- /** Gets the string `"unit"`. */
561
- string toString ( ) { result = "unit" }
562
-
563
- /**
564
- * Holds if type-tracking should not attempt to derive steps from (simple) calls to `callable`.
565
- *
566
- * This can be done to manually control how steps are generated from such calls.
567
- */
568
- predicate suppressSummary ( SummarizedCallable callable ) { none ( ) }
569
-
570
- /**
571
- * Holds if type-tracking should step from `pred` to `succ`.
572
- */
573
- predicate step ( Node pred , Node succ ) { none ( ) }
574
-
575
- /**
576
- * Holds if type-tracking should step from `pred` into the `content` of `succ`.
577
- */
578
- predicate storeStep ( Node pred , TypeTrackingNode succ , TypeTrackerContent content ) { none ( ) }
579
-
580
- /**
581
- * Holds if type-tracking should step from the `content` of `pred` to `succ`.
582
- */
583
- predicate loadStep ( Node pred , Node succ , TypeTrackerContent content ) { none ( ) }
584
-
585
- /**
586
- * Holds if type-tracking should step from the `loadContent` of `pred` to the `storeContent` in `succ`.
587
- */
588
- predicate loadStoreStep (
589
- Node pred , TypeTrackingNode succ , TypeTrackerContent loadContent ,
590
- TypeTrackerContent storeContent
591
- ) {
592
- none ( )
593
- }
594
-
595
- /**
596
- * Holds if type-tracking should step from `pred` to `succ` but block flow of contents matched by `filter` through here.
597
- */
598
- predicate withoutContentStep ( Node pred , Node succ , ContentFilter filter ) { none ( ) }
599
-
600
- /**
601
- * Holds if type-tracking should step from `pred` to `succ` if inside a content matched by `filter`.
602
- */
603
- predicate withContentStep ( Node pred , Node succ , ContentFilter filter ) { none ( ) }
604
- }
605
-
606
- /** Provides access to the steps contributed by subclasses of `SharedTypeTrackingStep`. */
607
- module TypeTrackingStep {
608
- /**
609
- * Holds if type-tracking should not attempt to derive steps from (simple) calls to `callable`.
610
- *
611
- * This can be done to manually control how steps are generated from such calls.
612
- */
613
- predicate suppressSummary ( SummarizedCallable callable ) {
614
- any ( TypeTrackingStep st ) .suppressSummary ( callable )
615
- }
616
-
617
- /**
618
- * Holds if type-tracking should step from `pred` to `succ`.
619
- */
620
- predicate step ( Node pred , Node succ ) { any ( TypeTrackingStep st ) .step ( pred , succ ) }
621
-
622
- /**
623
- * Holds if type-tracking should step from `pred` into the `content` of `succ`.
624
- */
625
- predicate storeStep ( Node pred , TypeTrackingNode succ , TypeTrackerContent content ) {
626
- any ( TypeTrackingStep st ) .storeStep ( pred , succ , content )
627
- }
628
-
629
- /**
630
- * Holds if type-tracking should step from the `content` of `pred` to `succ`.
631
- */
632
- predicate loadStep ( Node pred , Node succ , TypeTrackerContent content ) {
633
- any ( TypeTrackingStep st ) .loadStep ( pred , succ , content )
634
- }
635
-
636
- /**
637
- * Holds if type-tracking should step from the `loadContent` of `pred` to the `storeContent` in `succ`.
638
- */
639
- predicate loadStoreStep (
640
- Node pred , TypeTrackingNode succ , TypeTrackerContent loadContent ,
641
- TypeTrackerContent storeContent
642
- ) {
643
- any ( TypeTrackingStep st ) .loadStoreStep ( pred , succ , loadContent , storeContent )
644
- }
645
-
646
- /**
647
- * Holds if type-tracking should step from `pred` to `succ` but block flow of contents matched by `filter` through here.
648
- */
649
- predicate withoutContentStep ( Node pred , Node succ , ContentFilter filter ) {
650
- any ( TypeTrackingStep st ) .withoutContentStep ( pred , succ , filter )
651
- }
652
-
653
- /**
654
- * Holds if type-tracking should step from `pred` to `succ` if inside a content matched by `filter`.
655
- */
656
- predicate withContentStep ( Node pred , Node succ , ContentFilter filter ) {
657
- any ( TypeTrackingStep st ) .withContentStep ( pred , succ , filter )
658
- }
659
- }
0 commit comments