@@ -186,18 +186,49 @@ module Node {
186
186
class FlowSummaryNode extends Node , TFlowSummaryNode {
187
187
FlowSummaryImpl:: Private:: SummaryNode getSummaryNode ( ) { this = TFlowSummaryNode ( result ) }
188
188
189
- /** Gets the summarized callable that this node belongs to. */
189
+ /** Gets the summarized callable that this node belongs to, if any . */
190
190
FlowSummaryImpl:: Public:: SummarizedCallable getSummarizedCallable ( ) {
191
191
result = this .getSummaryNode ( ) .getSummarizedCallable ( )
192
192
}
193
193
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
+ }
195
217
196
218
override DataFlowCallable getEnclosingCallable ( ) {
197
219
result .asLibraryCallable ( ) = this .getSummarizedCallable ( )
220
+ or
221
+ result .asCfgScope ( ) = this .getCfgScope ( )
198
222
}
199
223
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
+ }
201
232
202
233
override string toString ( ) { result = this .getSummaryNode ( ) .toString ( ) }
203
234
}
@@ -526,13 +557,20 @@ private ExprCfgNode getALastEvalNode(ExprCfgNode e) {
526
557
}
527
558
528
559
module 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 )
536
574
}
537
575
538
576
pragma [ nomagic]
@@ -848,7 +886,7 @@ module RustDataFlow implements InputSig<Location> {
848
886
predicate nodeIsHidden ( Node node ) {
849
887
node instanceof Node:: SsaNode
850
888
or
851
- node instanceof Node:: FlowSummaryNode
889
+ node . ( Node:: FlowSummaryNode ) . getSummaryNode ( ) . isHidden ( )
852
890
or
853
891
node instanceof Node:: CaptureNode
854
892
or
@@ -864,6 +902,10 @@ module RustDataFlow implements InputSig<Location> {
864
902
node .asExpr ( ) = match .getScrutinee ( ) or
865
903
node .asExpr ( ) = match .getArmPat ( _)
866
904
)
905
+ or
906
+ FlowSummaryImpl:: Private:: Steps:: sourceLocalStep ( _, node , _)
907
+ or
908
+ FlowSummaryImpl:: Private:: Steps:: sinkLocalStep ( node , _, _)
867
909
}
868
910
869
911
class DataFlowExpr = ExprCfgNode ;
@@ -944,7 +986,7 @@ module RustDataFlow implements InputSig<Location> {
944
986
) and
945
987
model = ""
946
988
or
947
- LocalFlow:: flowSummaryLocalStep ( nodeFrom , nodeTo , _ , model )
989
+ LocalFlow:: flowSummaryLocalStep ( nodeFrom , nodeTo , model )
948
990
}
949
991
950
992
/**
@@ -1499,6 +1541,14 @@ private module Cached {
1499
1541
1500
1542
cached
1501
1543
newtype TContentSet = TSingletonContentSet ( Content c )
1544
+
1545
+ /** Holds if `n` is a flow source of kind `kind`. */
1546
+ cached
1547
+ predicate sourceNode ( Node n , string kind ) { n .( Node:: FlowSummaryNode ) .isSource ( kind ) }
1548
+
1549
+ /** Holds if `n` is a flow sink of kind `kind`. */
1550
+ cached
1551
+ predicate sinkNode ( Node n , string kind ) { n .( Node:: FlowSummaryNode ) .isSink ( kind ) }
1502
1552
}
1503
1553
1504
1554
import Cached
0 commit comments