@@ -196,26 +196,38 @@ module Node {
196196 result = this .getSummaryNode ( ) .getSourceNode ( )
197197 }
198198
199+ /** Gets the sink node that this node belongs to, if any */
200+ FlowSummaryImpl:: Public:: SinkNode getSinkNode ( ) { result = this .getSummaryNode ( ) .getSinkNode ( ) }
201+
199202 /** Holds is this node is a source node of kind `kind`. */
200203 predicate isSource ( string kind ) {
201204 this .getSummaryNode ( ) .( FlowSummaryImpl:: Private:: SourceOutputNode ) .isEntry ( kind )
202205 }
203206
207+ /** Holds is this node is a sink node of kind `kind`. */
208+ predicate isSink ( string kind ) {
209+ this .getSummaryNode ( ) .( FlowSummaryImpl:: Private:: SinkInputNode ) .isExit ( kind )
210+ }
211+
204212 override CfgScope getCfgScope ( ) {
205213 result = this .getSummaryNode ( ) .getSourceNode ( ) .getEnclosingCfgScope ( )
214+ or
215+ result = this .getSummaryNode ( ) .getSinkNode ( ) .getEnclosingCfgScope ( )
206216 }
207217
208218 override DataFlowCallable getEnclosingCallable ( ) {
209219 result .asLibraryCallable ( ) = this .getSummarizedCallable ( )
210220 or
211- result .asCfgScope ( ) = this .getSummaryNode ( ) . getSourceNode ( ) . getEnclosingCfgScope ( )
221+ result .asCfgScope ( ) = this .getCfgScope ( )
212222 }
213223
214224 override Location getLocation ( ) {
215225 exists ( this .getSummarizedCallable ( ) ) and
216226 result instanceof EmptyLocation
217227 or
218228 result = this .getSourceNode ( ) .getLocation ( )
229+ or
230+ result = this .getSinkNode ( ) .getLocation ( )
219231 }
220232
221233 override string toString ( ) { result = this .getSummaryNode ( ) .toString ( ) }
@@ -545,14 +557,17 @@ private ExprCfgNode getALastEvalNode(ExprCfgNode e) {
545557}
546558
547559module LocalFlow {
548- predicate flowSummaryLocalStep ( Node:: FlowSummaryNode nodeFrom , Node nodeTo , string model ) {
560+ predicate flowSummaryLocalStep ( Node nodeFrom , Node nodeTo , string model ) {
549561 exists ( FlowSummaryImpl:: Public:: SummarizedCallable c |
550- FlowSummaryImpl:: Private:: Steps:: summaryLocalStep ( nodeFrom .getSummaryNode ( ) ,
551- nodeTo .( Node:: FlowSummaryNode ) .getSummaryNode ( ) , true , model ) and
552- c = nodeFrom .getSummarizedCallable ( )
562+ FlowSummaryImpl:: Private:: Steps:: summaryLocalStep ( nodeFrom
563+ .( Node:: FlowSummaryNode )
564+ .getSummaryNode ( ) , nodeTo .( Node:: FlowSummaryNode ) .getSummaryNode ( ) , true , model ) and
565+ c = nodeFrom .( Node:: FlowSummaryNode ) .getSummarizedCallable ( )
553566 )
554567 or
555568 FlowSummaryImpl:: Private:: localSourceNodeStep ( nodeFrom , nodeTo , model )
569+ or
570+ FlowSummaryImpl:: Private:: localSinkNodeStep ( nodeFrom , nodeTo , model )
556571 }
557572
558573 pragma [ nomagic]
@@ -886,6 +901,8 @@ module RustDataFlow implements InputSig<Location> {
886901 )
887902 or
888903 FlowSummaryImpl:: Private:: localSourceNodeStep ( _, node , _)
904+ or
905+ FlowSummaryImpl:: Private:: localSinkNodeStep ( node , _, _)
889906 }
890907
891908 class DataFlowExpr = ExprCfgNode ;
@@ -1525,6 +1542,10 @@ private module Cached {
15251542 /** Holds if `n` is a flow source of kind `kind`. */
15261543 cached
15271544 predicate sourceNode ( Node n , string kind ) { n .( Node:: FlowSummaryNode ) .isSource ( kind ) }
1545+
1546+ /** Holds if `n` is a flow sink of kind `kind`. */
1547+ cached
1548+ predicate sinkNode ( Node n , string kind ) { n .( Node:: FlowSummaryNode ) .isSink ( kind ) }
15281549}
15291550
15301551import Cached
0 commit comments