@@ -119,7 +119,7 @@ private module LambdaFlow {
119
119
) {
120
120
revLambdaFlow0 ( lambdaCall , kind , node , t , toReturn , toJump , lastCall ) and
121
121
if node instanceof CastNode or node instanceof ArgumentNode or node instanceof ReturnNode
122
- then compatibleTypes ( t , getNodeType ( node ) )
122
+ then compatibleTypes ( t , getNodeDataFlowType ( node ) )
123
123
else any ( )
124
124
}
125
125
@@ -129,7 +129,7 @@ private module LambdaFlow {
129
129
boolean toJump , DataFlowCallOption lastCall
130
130
) {
131
131
lambdaCall ( lambdaCall , kind , node ) and
132
- t = getNodeType ( node ) and
132
+ t = getNodeDataFlowType ( node ) and
133
133
toReturn = false and
134
134
toJump = false and
135
135
lastCall = TDataFlowCallNone ( )
@@ -146,7 +146,7 @@ private module LambdaFlow {
146
146
getNodeEnclosingCallable ( node ) = getNodeEnclosingCallable ( mid )
147
147
|
148
148
preservesValue = false and
149
- t = getNodeType ( node )
149
+ t = getNodeDataFlowType ( node )
150
150
or
151
151
preservesValue = true and
152
152
t = t0
@@ -168,7 +168,7 @@ private module LambdaFlow {
168
168
getNodeEnclosingCallable ( node ) != getNodeEnclosingCallable ( mid )
169
169
|
170
170
preservesValue = false and
171
- t = getNodeType ( node )
171
+ t = getNodeDataFlowType ( node )
172
172
or
173
173
preservesValue = true and
174
174
t = t0
@@ -250,6 +250,9 @@ private module Cached {
250
250
c = call .getEnclosingCallable ( )
251
251
}
252
252
253
+ cached
254
+ predicate nodeDataFlowType ( Node n , DataFlowType t ) { t = getNodeType ( n ) }
255
+
253
256
/**
254
257
* Gets a viable target for the lambda call `call`.
255
258
*
@@ -282,7 +285,7 @@ private module Cached {
282
285
exists ( int i |
283
286
viableParam ( call , i , p ) and
284
287
arg .argumentOf ( call , i ) and
285
- compatibleTypes ( getNodeType ( arg ) , getNodeType ( p ) )
288
+ compatibleTypes ( getNodeDataFlowType ( arg ) , getNodeDataFlowType ( p ) )
286
289
)
287
290
}
288
291
@@ -430,10 +433,10 @@ private module Cached {
430
433
then
431
434
// normal flow through
432
435
read = TReadStepTypesNone ( ) and
433
- compatibleTypes ( getNodeType ( p ) , getNodeType ( node ) )
436
+ compatibleTypes ( getNodeDataFlowType ( p ) , getNodeDataFlowType ( node ) )
434
437
or
435
438
// getter
436
- compatibleTypes ( read .getContentType ( ) , getNodeType ( node ) )
439
+ compatibleTypes ( read .getContentType ( ) , getNodeDataFlowType ( node ) )
437
440
else any ( )
438
441
}
439
442
@@ -455,7 +458,7 @@ private module Cached {
455
458
readStepWithTypes ( mid , read .getContainerType ( ) , read .getContent ( ) , node ,
456
459
read .getContentType ( ) ) and
457
460
Cand:: parameterValueFlowReturnCand ( p , _, true ) and
458
- compatibleTypes ( getNodeType ( p ) , read .getContainerType ( ) )
461
+ compatibleTypes ( getNodeDataFlowType ( p ) , read .getContainerType ( ) )
459
462
)
460
463
or
461
464
parameterValueFlow0_0 ( TReadStepTypesNone ( ) , p , node , read )
@@ -511,11 +514,11 @@ private module Cached {
511
514
|
512
515
// normal flow through
513
516
read = TReadStepTypesNone ( ) and
514
- compatibleTypes ( getNodeType ( arg ) , getNodeType ( out ) )
517
+ compatibleTypes ( getNodeDataFlowType ( arg ) , getNodeDataFlowType ( out ) )
515
518
or
516
519
// getter
517
- compatibleTypes ( getNodeType ( arg ) , read .getContainerType ( ) ) and
518
- compatibleTypes ( read .getContentType ( ) , getNodeType ( out ) )
520
+ compatibleTypes ( getNodeDataFlowType ( arg ) , read .getContainerType ( ) ) and
521
+ compatibleTypes ( read .getContentType ( ) , getNodeDataFlowType ( out ) )
519
522
)
520
523
}
521
524
@@ -653,8 +656,8 @@ private module Cached {
653
656
) {
654
657
storeStep ( node1 , c , node2 ) and
655
658
readStep ( _, c , _) and
656
- contentType = getNodeType ( node1 ) and
657
- containerType = getNodeType ( node2 )
659
+ contentType = getNodeDataFlowType ( node1 ) and
660
+ containerType = getNodeDataFlowType ( node2 )
658
661
or
659
662
exists ( Node n1 , Node n2 |
660
663
n1 = node1 .( PostUpdateNode ) .getPreUpdateNode ( ) and
@@ -663,8 +666,8 @@ private module Cached {
663
666
argumentValueFlowsThrough ( n2 , TReadStepTypesSome ( containerType , c , contentType ) , n1 )
664
667
or
665
668
readStep ( n2 , c , n1 ) and
666
- contentType = getNodeType ( n1 ) and
667
- containerType = getNodeType ( n2 )
669
+ contentType = getNodeDataFlowType ( n1 ) and
670
+ containerType = getNodeDataFlowType ( n2 )
668
671
)
669
672
}
670
673
@@ -784,8 +787,8 @@ private predicate readStepWithTypes(
784
787
Node n1 , DataFlowType container , Content c , Node n2 , DataFlowType content
785
788
) {
786
789
readStep ( n1 , c , n2 ) and
787
- container = getNodeType ( n1 ) and
788
- content = getNodeType ( n2 )
790
+ container = getNodeDataFlowType ( n1 ) and
791
+ content = getNodeDataFlowType ( n2 )
789
792
}
790
793
791
794
private newtype TReadStepTypesOption =
@@ -1023,10 +1026,13 @@ class ReturnPosition extends TReturnPosition0 {
1023
1026
*/
1024
1027
pragma [ inline]
1025
1028
DataFlowCallable getNodeEnclosingCallable ( Node n ) {
1026
- exists ( Node n0 |
1027
- pragma [ only_bind_into ] ( n0 ) = n and
1028
- nodeEnclosingCallable ( n0 , pragma [ only_bind_into ] ( result ) )
1029
- )
1029
+ nodeEnclosingCallable ( pragma [ only_bind_out ] ( n ) , pragma [ only_bind_into ] ( result ) )
1030
+ }
1031
+
1032
+ /** Gets the type of `n` used for type pruning. */
1033
+ pragma [ inline]
1034
+ DataFlowType getNodeDataFlowType ( Node n ) {
1035
+ nodeDataFlowType ( pragma [ only_bind_out ] ( n ) , pragma [ only_bind_into ] ( result ) )
1030
1036
}
1031
1037
1032
1038
pragma [ noinline]
0 commit comments