@@ -318,8 +318,8 @@ private module Cached {
318
318
} or
319
319
TSynthSplatParameterElementNode ( DataFlowCallable c , int n ) {
320
320
exists ( c .asCallable ( ) ) and // exclude library callables
321
- exists ( ArgumentPosition p | p .isPositional ( n ) ) and
322
- isParameterNode ( _ , c , any ( ParameterPosition p | p . isSplat ( _ ) ) )
321
+ isParameterNode ( _ , c , any ( ParameterPosition p | p .isSplat ( _ ) ) ) and
322
+ n in [ 0 .. 10 ]
323
323
} or
324
324
TExprPostUpdateNode ( CfgNodes:: ExprCfgNode n ) {
325
325
// filter out nodes that clearly don't need post-update nodes
@@ -892,7 +892,20 @@ private module ParameterNodes {
892
892
893
893
SynthSplatParameterElementNode ( ) { this = TSynthSplatParameterElementNode ( callable , pos ) }
894
894
895
- int getPosition ( ) { result = pos }
895
+ pragma [ nomagic]
896
+ NormalParameterNode getSplatParameterNode ( int splatPos ) {
897
+ result
898
+ .isParameterOf ( this .getEnclosingCallable ( ) , any ( ParameterPosition p | p .isSplat ( splatPos ) ) )
899
+ }
900
+
901
+ int getStorePosition ( ) { result = pos }
902
+
903
+ int getReadPosition ( ) {
904
+ exists ( int splatPos |
905
+ exists ( this .getSplatParameterNode ( splatPos ) ) and
906
+ result = pos + splatPos
907
+ )
908
+ }
896
909
897
910
final override Parameter getParameter ( ) { none ( ) }
898
911
@@ -1070,14 +1083,14 @@ private module ArgumentNodes {
1070
1083
* 2. We match this to an analogous parameter node `SynthSplatArgParameterNode` on the callee side
1071
1084
* (see `parameterMatch`).
1072
1085
* 3. For each content element stored in the `SynthSplatArgParameterNode`, we add a read step to a separate
1073
- * `SynthSplatParameterElementNode`, which is parameterised by the element index (see `readStep`).
1086
+ * `SynthSplatParameterElementNode`, which is parameterized by the element index (see `readStep`).
1074
1087
* 4. Finally, we add store steps from these `SynthSplatParameterElementNode`s to the real splat parameter node
1075
1088
* (see `storeStep`).
1076
1089
* We only add store steps for elements that will not flow to the earlier positional parameters.
1077
1090
* In practice that means we ignore elements at index `<= N`, where `N` is the index of the splat parameter.
1078
1091
* For the remaining elements we subtract `N` from their index and store them in the splat parameter.
1079
1092
*/
1080
- class SynthSplatArgumentNode extends ArgumentNode , TSynthSplatArgumentNode {
1093
+ class SynthSplatArgumentNode extends ArgumentNode , NodeImpl , TSynthSplatArgumentNode {
1081
1094
CfgNodes:: ExprNodes:: CallCfgNode c ;
1082
1095
1083
1096
SynthSplatArgumentNode ( ) { this = TSynthSplatArgumentNode ( c ) }
@@ -1090,12 +1103,6 @@ private module ArgumentNodes {
1090
1103
call = c and
1091
1104
pos .isSynthSplat ( )
1092
1105
}
1093
- }
1094
-
1095
- private class SynthSplatArgumentNodeImpl extends NodeImpl , TSynthSplatArgumentNode {
1096
- CfgNodes:: ExprNodes:: CallCfgNode c ;
1097
-
1098
- SynthSplatArgumentNodeImpl ( ) { this = TSynthSplatArgumentNode ( c ) }
1099
1106
1100
1107
override CfgScope getCfgScope ( ) { result = c .getExpr ( ) .getCfgScope ( ) }
1101
1108
@@ -1346,16 +1353,11 @@ predicate storeStepCommon(Node node1, ContentSet c, Node node2) {
1346
1353
exists ( int n | pos .isPositional ( n ) and c = getPositionalContent ( n ) )
1347
1354
)
1348
1355
or
1349
- // Store from SynthSplatParameterElementNode[n] into SplatParameterNode[m]
1350
- // where m = n - <position of SplatParameterNode>
1351
- exists ( SynthSplatParameterElementNode elemNode , NormalParameterNode splatNode , int splatPos |
1352
- elemNode = node1 and splatNode = node2
1353
- |
1354
- splatNode
1355
- .isParameterOf ( elemNode .getEnclosingCallable ( ) ,
1356
- any ( ParameterPosition p | p .isSplat ( splatPos ) ) ) and
1357
- c = getPositionalContent ( elemNode .getPosition ( ) - splatPos )
1358
- )
1356
+ node1 =
1357
+ any ( SynthSplatParameterElementNode elemNode |
1358
+ node2 = elemNode .getSplatParameterNode ( _) and
1359
+ c = getPositionalContent ( elemNode .getStorePosition ( ) )
1360
+ )
1359
1361
}
1360
1362
1361
1363
/**
@@ -1421,19 +1423,17 @@ predicate readStep(Node node1, ContentSet c, Node node2) {
1421
1423
or
1422
1424
node2 = node1 .( SynthHashSplatParameterNode ) .getAKeywordParameter ( c )
1423
1425
or
1424
- node2 = node1 .( SynthSplatParameterNode ) .getAParameter ( c )
1425
- or
1426
1426
FlowSummaryImpl:: Private:: Steps:: summaryReadStep ( node1 .( FlowSummaryNode ) .getSummaryNode ( ) , c ,
1427
1427
node2 .( FlowSummaryNode ) .getSummaryNode ( ) )
1428
1428
or
1429
+ node2 = node1 .( SynthSplatParameterNode ) .getAParameter ( c )
1430
+ or
1429
1431
// Read from SynthSplatArgParameterNode into SynthSplatParameterElementNode
1430
- exists ( SynthSplatArgParameterNode fromNode , SynthSplatParameterElementNode toNode , int pos |
1431
- node1 = fromNode and node2 = toNode
1432
- |
1433
- fromNode .isParameterOf ( toNode .getEnclosingCallable ( ) , _) and
1434
- c = getPositionalContent ( pos ) and
1435
- toNode .getPosition ( ) = pos
1436
- )
1432
+ node2 =
1433
+ any ( SynthSplatParameterElementNode e |
1434
+ node1 .( SynthSplatArgParameterNode ) .isParameterOf ( e .getEnclosingCallable ( ) , _) and
1435
+ c = getPositionalContent ( e .getReadPosition ( ) )
1436
+ )
1437
1437
}
1438
1438
1439
1439
/**
0 commit comments