@@ -309,24 +309,16 @@ private module Cached {
309
309
n = any ( CfgNodes:: ExprNodes:: InstanceVariableAccessCfgNode v ) .getReceiver ( )
310
310
)
311
311
} or
312
- TSummaryNode (
313
- FlowSummaryImpl:: Public:: SummarizedCallable c ,
314
- FlowSummaryImpl:: Private:: SummaryNodeState state
315
- ) {
316
- FlowSummaryImpl:: Private:: summaryNodeRange ( c , state )
317
- } or
318
- TSummaryParameterNode ( FlowSummaryImpl:: Public:: SummarizedCallable c , ParameterPosition pos ) {
319
- FlowSummaryImpl:: Private:: summaryParameterNodeRange ( c , pos )
320
- } or
312
+ TFlowSummaryNode ( FlowSummaryImpl:: Private:: SummaryNode sn ) or
321
313
TSynthHashSplatArgumentNode ( CfgNodes:: ExprNodes:: CallCfgNode c ) {
322
314
exists ( Argument arg | arg .isArgumentOf ( c , any ( ArgumentPosition pos | pos .isKeyword ( _) ) ) )
323
315
or
324
316
c .getAnArgument ( ) instanceof CfgNodes:: ExprNodes:: PairCfgNode
325
317
}
326
318
327
- class TParameterNode =
319
+ class TSourceParameterNode =
328
320
TNormalParameterNode or TBlockParameterNode or TSelfParameterNode or
329
- TSynthHashSplatParameterNode or TSummaryParameterNode ;
321
+ TSynthHashSplatParameterNode ;
330
322
331
323
cached
332
324
Location getLocation ( NodeImpl n ) { result = n .getLocationImpl ( ) }
@@ -355,7 +347,8 @@ private module Cached {
355
347
exprFrom = nodeFrom .( PostUpdateNode ) .getPreUpdateNode ( ) .asExpr ( )
356
348
)
357
349
or
358
- FlowSummaryImpl:: Private:: Steps:: summaryLocalStep ( nodeFrom , nodeTo , true )
350
+ FlowSummaryImpl:: Private:: Steps:: summaryLocalStep ( nodeFrom .( FlowSummaryNode ) .getSummaryNode ( ) ,
351
+ nodeTo .( FlowSummaryNode ) .getSummaryNode ( ) , true )
359
352
}
360
353
361
354
/** This is the local flow predicate that is exposed. */
@@ -412,7 +405,9 @@ private module Cached {
412
405
413
406
cached
414
407
predicate isLocalSourceNode ( Node n ) {
415
- n instanceof TParameterNode
408
+ n instanceof TSourceParameterNode
409
+ or
410
+ n instanceof SummaryParameterNode
416
411
or
417
412
// Expressions that can't be reached from another entry definition or expression
418
413
n instanceof ExprNode and
@@ -514,9 +509,7 @@ predicate nodeIsHidden(Node n) {
514
509
or
515
510
isDesugarNode ( n .( ExprNode ) .getExprNode ( ) .getExpr ( ) )
516
511
or
517
- n instanceof SummaryNode
518
- or
519
- n instanceof SummaryParameterNode
512
+ n instanceof FlowSummaryNode
520
513
or
521
514
n instanceof SynthHashSplatParameterNode
522
515
or
@@ -757,47 +750,43 @@ private module ParameterNodes {
757
750
}
758
751
759
752
/** A parameter for a library callable with a flow summary. */
760
- class SummaryParameterNode extends ParameterNodeImpl , TSummaryParameterNode {
761
- private FlowSummaryImpl:: Public:: SummarizedCallable sc ;
762
- private ParameterPosition pos_ ;
753
+ class SummaryParameterNode extends ParameterNodeImpl , FlowSummaryNode {
754
+ SummaryParameterNode ( ) {
755
+ FlowSummaryImpl:: Private:: summaryParameterNode ( this .getSummaryNode ( ) , _)
756
+ }
763
757
764
- SummaryParameterNode ( ) { this = TSummaryParameterNode ( sc , pos_ ) }
758
+ private ParameterPosition getPosition ( ) {
759
+ FlowSummaryImpl:: Private:: summaryParameterNode ( this .getSummaryNode ( ) , result )
760
+ }
765
761
766
762
override Parameter getParameter ( ) { none ( ) }
767
763
768
764
override predicate isParameterOf ( DataFlowCallable c , ParameterPosition pos ) {
769
- sc = c .asLibraryCallable ( ) and pos = pos_
765
+ this . getSummarizedCallable ( ) = c .asLibraryCallable ( ) and pos = this . getPosition ( )
770
766
}
771
-
772
- override CfgScope getCfgScope ( ) { none ( ) }
773
-
774
- override DataFlowCallable getEnclosingCallable ( ) { result .asLibraryCallable ( ) = sc }
775
-
776
- override EmptyLocation getLocationImpl ( ) { any ( ) }
777
-
778
- override string toStringImpl ( ) { result = "parameter " + pos_ + " of " + sc }
779
767
}
780
768
}
781
769
782
770
import ParameterNodes
783
771
784
772
/** A data-flow node used to model flow summaries. */
785
- class SummaryNode extends NodeImpl , TSummaryNode {
786
- FlowSummaryImpl:: Public:: SummarizedCallable c ;
787
- FlowSummaryImpl:: Private:: SummaryNodeState state ;
788
-
789
- SummaryNode ( ) { this = TSummaryNode ( c , state ) }
773
+ class FlowSummaryNode extends NodeImpl , TFlowSummaryNode {
774
+ FlowSummaryImpl:: Private:: SummaryNode getSummaryNode ( ) { this = TFlowSummaryNode ( result ) }
790
775
791
776
/** Gets the summarized callable that this node belongs to. */
792
- FlowSummaryImpl:: Public:: SummarizedCallable getSummarizedCallable ( ) { result = c }
777
+ FlowSummaryImpl:: Public:: SummarizedCallable getSummarizedCallable ( ) {
778
+ result = this .getSummaryNode ( ) .getSummarizedCallable ( )
779
+ }
793
780
794
781
override CfgScope getCfgScope ( ) { none ( ) }
795
782
796
- override DataFlowCallable getEnclosingCallable ( ) { result .asLibraryCallable ( ) = c }
783
+ override DataFlowCallable getEnclosingCallable ( ) {
784
+ result .asLibraryCallable ( ) = this .getSummarizedCallable ( )
785
+ }
797
786
798
787
override EmptyLocation getLocationImpl ( ) { any ( ) }
799
788
800
- override string toStringImpl ( ) { result = "[summary] " + state + " in " + c }
789
+ override string toStringImpl ( ) { result = this . getSummaryNode ( ) . toString ( ) }
801
790
}
802
791
803
792
/** A data-flow node that represents a call argument. */
@@ -857,15 +846,17 @@ private module ArgumentNodes {
857
846
}
858
847
}
859
848
860
- private class SummaryArgumentNode extends SummaryNode , ArgumentNode {
861
- SummaryArgumentNode ( ) { FlowSummaryImpl:: Private:: summaryArgumentNode ( _, this , _) }
849
+ private class SummaryArgumentNode extends FlowSummaryNode , ArgumentNode {
850
+ SummaryArgumentNode ( ) {
851
+ FlowSummaryImpl:: Private:: summaryArgumentNode ( _, this .getSummaryNode ( ) , _)
852
+ }
862
853
863
854
override predicate sourceArgumentOf ( CfgNodes:: ExprNodes:: CallCfgNode call , ArgumentPosition pos ) {
864
855
none ( )
865
856
}
866
857
867
858
override predicate argumentOf ( DataFlowCall call , ArgumentPosition pos ) {
868
- FlowSummaryImpl:: Private:: summaryArgumentNode ( call , this , pos )
859
+ FlowSummaryImpl:: Private:: summaryArgumentNode ( call , this . getSummaryNode ( ) , pos )
869
860
}
870
861
}
871
862
@@ -1029,16 +1020,16 @@ private module ReturnNodes {
1029
1020
override ReturnKind getKind ( ) { result instanceof NewReturnKind }
1030
1021
}
1031
1022
1032
- private class SummaryReturnNode extends SummaryNode , ReturnNode {
1023
+ private class SummaryReturnNode extends FlowSummaryNode , ReturnNode {
1033
1024
private ReturnKind rk ;
1034
1025
1035
- SummaryReturnNode ( ) { FlowSummaryImpl:: Private:: summaryReturnNode ( this , rk ) }
1026
+ SummaryReturnNode ( ) { FlowSummaryImpl:: Private:: summaryReturnNode ( this . getSummaryNode ( ) , rk ) }
1036
1027
1037
1028
override ReturnKind getKind ( ) {
1038
1029
result = rk
1039
1030
or
1040
1031
exists ( NewCall new |
1041
- TLibraryCallable ( c ) = viableLibraryCallable ( new ) and
1032
+ TLibraryCallable ( this . getSummarizedCallable ( ) ) = viableLibraryCallable ( new ) and
1042
1033
result instanceof NewReturnKind
1043
1034
)
1044
1035
}
@@ -1071,11 +1062,11 @@ private module OutNodes {
1071
1062
}
1072
1063
}
1073
1064
1074
- private class SummaryOutNode extends SummaryNode , OutNode {
1075
- SummaryOutNode ( ) { FlowSummaryImpl:: Private:: summaryOutNode ( _, this , _) }
1065
+ private class SummaryOutNode extends FlowSummaryNode , OutNode {
1066
+ SummaryOutNode ( ) { FlowSummaryImpl:: Private:: summaryOutNode ( _, this . getSummaryNode ( ) , _) }
1076
1067
1077
1068
override DataFlowCall getCall ( ReturnKind kind ) {
1078
- FlowSummaryImpl:: Private:: summaryOutNode ( result , this , kind )
1069
+ FlowSummaryImpl:: Private:: summaryOutNode ( result , this . getSummaryNode ( ) , kind )
1079
1070
}
1080
1071
}
1081
1072
}
@@ -1091,7 +1082,8 @@ predicate jumpStep(Node pred, Node succ) {
1091
1082
or
1092
1083
succ .asExpr ( ) .getExpr ( ) .( ConstantReadAccess ) .getValue ( ) = pred .asExpr ( ) .getExpr ( )
1093
1084
or
1094
- FlowSummaryImpl:: Private:: Steps:: summaryJumpStep ( pred , succ )
1085
+ FlowSummaryImpl:: Private:: Steps:: summaryJumpStep ( pred .( FlowSummaryNode ) .getSummaryNode ( ) ,
1086
+ succ .( FlowSummaryNode ) .getSummaryNode ( ) )
1095
1087
or
1096
1088
any ( AdditionalJumpStep s ) .step ( pred , succ )
1097
1089
}
@@ -1156,7 +1148,8 @@ predicate storeStep(Node node1, ContentSet c, Node node2) {
1156
1148
) )
1157
1149
) .getReceiver ( )
1158
1150
or
1159
- FlowSummaryImpl:: Private:: Steps:: summaryStoreStep ( node1 , c , node2 )
1151
+ FlowSummaryImpl:: Private:: Steps:: summaryStoreStep ( node1 .( FlowSummaryNode ) .getSummaryNode ( ) , c ,
1152
+ node2 .( FlowSummaryNode ) .getSummaryNode ( ) )
1160
1153
or
1161
1154
storeStepCommon ( node1 , c , node2 )
1162
1155
}
@@ -1190,7 +1183,8 @@ predicate readStep(Node node1, ContentSet c, Node node2) {
1190
1183
or
1191
1184
node2 = node1 .( SynthHashSplatParameterNode ) .getAKeywordParameter ( c )
1192
1185
or
1193
- FlowSummaryImpl:: Private:: Steps:: summaryReadStep ( node1 , c , node2 )
1186
+ FlowSummaryImpl:: Private:: Steps:: summaryReadStep ( node1 .( FlowSummaryNode ) .getSummaryNode ( ) , c ,
1187
+ node2 .( FlowSummaryNode ) .getSummaryNode ( ) )
1194
1188
}
1195
1189
1196
1190
/**
@@ -1199,7 +1193,7 @@ predicate readStep(Node node1, ContentSet c, Node node2) {
1199
1193
* in `x.f = newValue`.
1200
1194
*/
1201
1195
predicate clearsContent ( Node n , ContentSet c ) {
1202
- FlowSummaryImpl:: Private:: Steps:: summaryClearsContent ( n , c )
1196
+ FlowSummaryImpl:: Private:: Steps:: summaryClearsContent ( n . ( FlowSummaryNode ) . getSummaryNode ( ) , c )
1203
1197
or
1204
1198
// Filter out keyword arguments that are part of the method signature from
1205
1199
// the hash-splat parameter
@@ -1220,7 +1214,7 @@ predicate clearsContent(Node n, ContentSet c) {
1220
1214
* at node `n`.
1221
1215
*/
1222
1216
predicate expectsContent ( Node n , ContentSet c ) {
1223
- FlowSummaryImpl:: Private:: Steps:: summaryExpectsContent ( n , c )
1217
+ FlowSummaryImpl:: Private:: Steps:: summaryExpectsContent ( n . ( FlowSummaryNode ) . getSummaryNode ( ) , c )
1224
1218
}
1225
1219
1226
1220
private newtype TDataFlowType =
@@ -1277,10 +1271,12 @@ private module PostUpdateNodes {
1277
1271
override string toStringImpl ( ) { result = "[post] " + e .toString ( ) }
1278
1272
}
1279
1273
1280
- private class SummaryPostUpdateNode extends SummaryNode , PostUpdateNodeImpl {
1281
- private Node pre ;
1274
+ private class SummaryPostUpdateNode extends FlowSummaryNode , PostUpdateNodeImpl {
1275
+ private FlowSummaryNode pre ;
1282
1276
1283
- SummaryPostUpdateNode ( ) { FlowSummaryImpl:: Private:: summaryPostUpdateNode ( this , pre ) }
1277
+ SummaryPostUpdateNode ( ) {
1278
+ FlowSummaryImpl:: Private:: summaryPostUpdateNode ( this .getSummaryNode ( ) , pre .getSummaryNode ( ) )
1279
+ }
1284
1280
1285
1281
override Node getPreUpdateNode ( ) { result = pre }
1286
1282
}
@@ -1355,7 +1351,7 @@ predicate lambdaSourceCall(CfgNodes::ExprNodes::CallCfgNode call, LambdaCallKind
1355
1351
predicate lambdaCall ( DataFlowCall call , LambdaCallKind kind , Node receiver ) {
1356
1352
lambdaSourceCall ( call .asCall ( ) , kind , receiver )
1357
1353
or
1358
- receiver = call .( SummaryCall ) .getReceiver ( ) and
1354
+ receiver . ( FlowSummaryNode ) . getSummaryNode ( ) = call .( SummaryCall ) .getReceiver ( ) and
1359
1355
if receiver .( ParameterNodeImpl ) .isParameterOf ( _, any ( ParameterPosition pos | pos .isBlock ( ) ) )
1360
1356
then kind = TYieldCallKind ( )
1361
1357
else kind = TLambdaCallKind ( )
0 commit comments