@@ -764,18 +764,20 @@ module TypeTracking<TypeTrackingInput I> {
764
764
* in a source-sink path and calculates the set of source-sink pairs.
765
765
*/
766
766
module Graph< endpoint / 1 sink> {
767
- private newtype TPathNode = MkPathNode ( Node node , TypeTracker tt ) { node = flow ( tt ) }
767
+ private newtype TPathNode =
768
+ TPathNodeMid ( Node node , TypeTracker tt ) { node = flow ( tt ) } or
769
+ TPathNodeSink ( Node node ) { sink ( node ) and flowsTo ( node ) }
768
770
769
771
/**
770
772
* A node on a path that is reachable from a source. This is a pair of a
771
- * `Node` and a `TypeTracker`.
773
+ * `Node` and a `TypeTracker` except at sinks for which there is no `TypeTracker` .
772
774
*/
773
775
class PathNodeFwd extends TPathNode {
774
776
/** Gets the node of this `PathNode`. */
775
- Node getNode ( ) { this = MkPathNode ( result , _) }
777
+ Node getNode ( ) { this = TPathNodeMid ( result , _) or this = TPathNodeSink ( result ) }
776
778
777
- /** Gets the typetracker of this `PathNode`. */
778
- TypeTracker getTypeTracker ( ) { this = MkPathNode ( _, result ) }
779
+ /** Gets the typetracker of this `PathNode`, if any . */
780
+ TypeTracker getTypeTracker ( ) { this = TPathNodeMid ( _, result ) }
779
781
780
782
private string ppContent ( ) {
781
783
exists ( ContentOption c | this .getTypeTracker ( ) = MkTypeTracker ( _, c ) |
@@ -784,6 +786,8 @@ module TypeTracking<TypeTrackingInput I> {
784
786
c instanceof ContentOption:: None and
785
787
result = ""
786
788
)
789
+ or
790
+ result = "" and this instanceof TPathNodeSink
787
791
}
788
792
789
793
/** Gets a textual representation of this node. */
@@ -793,7 +797,7 @@ module TypeTracking<TypeTrackingInput I> {
793
797
predicate isSource ( ) { source ( this .getNode ( ) ) and this .getTypeTracker ( ) .start ( ) }
794
798
795
799
/** Holds if this is a sink. */
796
- predicate isSink ( ) { sink ( this . getNode ( ) ) and this . getTypeTracker ( ) . end ( ) }
800
+ predicate isSink ( ) { this instanceof TPathNodeSink }
797
801
}
798
802
799
803
private predicate edgeCand ( Node n1 , TypeTracker tt1 , Node n2 , TypeTracker tt2 ) {
@@ -802,7 +806,17 @@ module TypeTracking<TypeTrackingInput I> {
802
806
}
803
807
804
808
private predicate edgeCand ( PathNodeFwd n1 , PathNodeFwd n2 ) {
805
- edgeCand ( n1 .getNode ( ) , n1 .getTypeTracker ( ) , n2 .getNode ( ) , n2 .getTypeTracker ( ) )
809
+ exists ( PathNodeFwd tgt |
810
+ edgeCand ( n1 .getNode ( ) , n1 .getTypeTracker ( ) , tgt .getNode ( ) , tgt .getTypeTracker ( ) )
811
+ |
812
+ n2 = tgt
813
+ or
814
+ n2 = TPathNodeSink ( tgt .getNode ( ) ) and tgt .getTypeTracker ( ) .end ( )
815
+ )
816
+ or
817
+ n1 .getTypeTracker ( ) .end ( ) and
818
+ flowsTo ( n1 .getNode ( ) , n2 .getNode ( ) ) and
819
+ n2 instanceof TPathNodeSink
806
820
}
807
821
808
822
private predicate reachRev ( PathNodeFwd n ) {
0 commit comments