@@ -186,18 +186,49 @@ module Node {
186186 class FlowSummaryNode extends Node , TFlowSummaryNode {
187187 FlowSummaryImpl:: Private:: SummaryNode getSummaryNode ( ) { this = TFlowSummaryNode ( result ) }
188188
189- /** Gets the summarized callable that this node belongs to. */
189+ /** Gets the summarized callable that this node belongs to, if any . */
190190 FlowSummaryImpl:: Public:: SummarizedCallable getSummarizedCallable ( ) {
191191 result = this .getSummaryNode ( ) .getSummarizedCallable ( )
192192 }
193193
194- override CfgScope getCfgScope ( ) { none ( ) }
194+ /** Gets the source node that this node belongs to, if any */
195+ FlowSummaryImpl:: Public:: SourceNode getSourceNode ( ) {
196+ result = this .getSummaryNode ( ) .getSourceNode ( )
197+ }
198+
199+ /** Gets the sink node that this node belongs to, if any */
200+ FlowSummaryImpl:: Public:: SinkNode getSinkNode ( ) { result = this .getSummaryNode ( ) .getSinkNode ( ) }
201+
202+ /** Holds is this node is a source node of kind `kind`. */
203+ predicate isSource ( string kind ) {
204+ this .getSummaryNode ( ) .( FlowSummaryImpl:: Private:: SourceOutputNode ) .isEntry ( kind )
205+ }
206+
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+
212+ override CfgScope getCfgScope ( ) {
213+ result = this .getSummaryNode ( ) .getSourceNode ( ) .getEnclosingCfgScope ( )
214+ or
215+ result = this .getSummaryNode ( ) .getSinkNode ( ) .getEnclosingCfgScope ( )
216+ }
195217
196218 override DataFlowCallable getEnclosingCallable ( ) {
197219 result .asLibraryCallable ( ) = this .getSummarizedCallable ( )
220+ or
221+ result .asCfgScope ( ) = this .getCfgScope ( )
198222 }
199223
200- override EmptyLocation getLocation ( ) { any ( ) }
224+ override Location getLocation ( ) {
225+ exists ( this .getSummarizedCallable ( ) ) and
226+ result instanceof EmptyLocation
227+ or
228+ result = this .getSourceNode ( ) .getLocation ( )
229+ or
230+ result = this .getSinkNode ( ) .getLocation ( )
231+ }
201232
202233 override string toString ( ) { result = this .getSummaryNode ( ) .toString ( ) }
203234 }
@@ -526,13 +557,20 @@ private ExprCfgNode getALastEvalNode(ExprCfgNode e) {
526557}
527558
528559module LocalFlow {
529- predicate flowSummaryLocalStep (
530- Node:: FlowSummaryNode nodeFrom , Node:: FlowSummaryNode nodeTo ,
531- FlowSummaryImpl:: Public:: SummarizedCallable c , string model
532- ) {
533- FlowSummaryImpl:: Private:: Steps:: summaryLocalStep ( nodeFrom .getSummaryNode ( ) ,
534- nodeTo .getSummaryNode ( ) , true , model ) and
535- c = nodeFrom .getSummarizedCallable ( )
560+ predicate flowSummaryLocalStep ( Node nodeFrom , Node nodeTo , string model ) {
561+ exists ( FlowSummaryImpl:: Public:: SummarizedCallable c |
562+ FlowSummaryImpl:: Private:: Steps:: summaryLocalStep ( nodeFrom
563+ .( Node:: FlowSummaryNode )
564+ .getSummaryNode ( ) , nodeTo .( Node:: FlowSummaryNode ) .getSummaryNode ( ) , true , model ) and
565+ c = nodeFrom .( Node:: FlowSummaryNode ) .getSummarizedCallable ( )
566+ )
567+ or
568+ FlowSummaryImpl:: Private:: Steps:: sourceLocalStep ( nodeFrom
569+ .( Node:: FlowSummaryNode )
570+ .getSummaryNode ( ) , nodeTo , model )
571+ or
572+ FlowSummaryImpl:: Private:: Steps:: sinkLocalStep ( nodeFrom ,
573+ nodeTo .( Node:: FlowSummaryNode ) .getSummaryNode ( ) , model )
536574 }
537575
538576 pragma [ nomagic]
@@ -853,7 +891,7 @@ module RustDataFlow implements InputSig<Location> {
853891 predicate nodeIsHidden ( Node node ) {
854892 node instanceof Node:: SsaNode
855893 or
856- node instanceof Node:: FlowSummaryNode
894+ node . ( Node:: FlowSummaryNode ) . getSummaryNode ( ) . isHidden ( )
857895 or
858896 node instanceof Node:: CaptureNode
859897 or
@@ -869,6 +907,10 @@ module RustDataFlow implements InputSig<Location> {
869907 node .asExpr ( ) = match .getScrutinee ( ) or
870908 node .asExpr ( ) = match .getArmPat ( _)
871909 )
910+ or
911+ FlowSummaryImpl:: Private:: Steps:: sourceLocalStep ( _, node , _)
912+ or
913+ FlowSummaryImpl:: Private:: Steps:: sinkLocalStep ( node , _, _)
872914 }
873915
874916 class DataFlowExpr = ExprCfgNode ;
@@ -949,7 +991,7 @@ module RustDataFlow implements InputSig<Location> {
949991 ) and
950992 model = ""
951993 or
952- LocalFlow:: flowSummaryLocalStep ( nodeFrom , nodeTo , _ , model )
994+ LocalFlow:: flowSummaryLocalStep ( nodeFrom , nodeTo , model )
953995 }
954996
955997 /**
@@ -1528,6 +1570,14 @@ private module Cached {
15281570
15291571 cached
15301572 newtype TContentSet = TSingletonContentSet ( Content c )
1573+
1574+ /** Holds if `n` is a flow source of kind `kind`. */
1575+ cached
1576+ predicate sourceNode ( Node n , string kind ) { n .( Node:: FlowSummaryNode ) .isSource ( kind ) }
1577+
1578+ /** Holds if `n` is a flow sink of kind `kind`. */
1579+ cached
1580+ predicate sinkNode ( Node n , string kind ) { n .( Node:: FlowSummaryNode ) .isSink ( kind ) }
15311581}
15321582
15331583import Cached
0 commit comments