@@ -119,7 +119,7 @@ private module LambdaFlow {
119119 ) {
120120 revLambdaFlow0 ( lambdaCall , kind , node , t , toReturn , toJump , lastCall ) and
121121 if node instanceof CastNode or node instanceof ArgumentNode or node instanceof ReturnNode
122- then compatibleTypes ( t , getNodeType ( node ) )
122+ then compatibleTypes ( t , getNodeDataFlowType ( node ) )
123123 else any ( )
124124 }
125125
@@ -129,7 +129,7 @@ private module LambdaFlow {
129129 boolean toJump , DataFlowCallOption lastCall
130130 ) {
131131 lambdaCall ( lambdaCall , kind , node ) and
132- t = getNodeType ( node ) and
132+ t = getNodeDataFlowType ( node ) and
133133 toReturn = false and
134134 toJump = false and
135135 lastCall = TDataFlowCallNone ( )
@@ -146,7 +146,7 @@ private module LambdaFlow {
146146 getNodeEnclosingCallable ( node ) = getNodeEnclosingCallable ( mid )
147147 |
148148 preservesValue = false and
149- t = getNodeType ( node )
149+ t = getNodeDataFlowType ( node )
150150 or
151151 preservesValue = true and
152152 t = t0
@@ -168,7 +168,7 @@ private module LambdaFlow {
168168 getNodeEnclosingCallable ( node ) != getNodeEnclosingCallable ( mid )
169169 |
170170 preservesValue = false and
171- t = getNodeType ( node )
171+ t = getNodeDataFlowType ( node )
172172 or
173173 preservesValue = true and
174174 t = t0
@@ -250,6 +250,9 @@ private module Cached {
250250 c = call .getEnclosingCallable ( )
251251 }
252252
253+ cached
254+ predicate nodeDataFlowType ( Node n , DataFlowType t ) { t = getNodeType ( n ) }
255+
253256 /**
254257 * Gets a viable target for the lambda call `call`.
255258 *
@@ -282,7 +285,7 @@ private module Cached {
282285 exists ( int i |
283286 viableParam ( call , i , p ) and
284287 arg .argumentOf ( call , i ) and
285- compatibleTypes ( getNodeType ( arg ) , getNodeType ( p ) )
288+ compatibleTypes ( getNodeDataFlowType ( arg ) , getNodeDataFlowType ( p ) )
286289 )
287290 }
288291
@@ -430,10 +433,10 @@ private module Cached {
430433 then
431434 // normal flow through
432435 read = TReadStepTypesNone ( ) and
433- compatibleTypes ( getNodeType ( p ) , getNodeType ( node ) )
436+ compatibleTypes ( getNodeDataFlowType ( p ) , getNodeDataFlowType ( node ) )
434437 or
435438 // getter
436- compatibleTypes ( read .getContentType ( ) , getNodeType ( node ) )
439+ compatibleTypes ( read .getContentType ( ) , getNodeDataFlowType ( node ) )
437440 else any ( )
438441 }
439442
@@ -455,7 +458,7 @@ private module Cached {
455458 readStepWithTypes ( mid , read .getContainerType ( ) , read .getContent ( ) , node ,
456459 read .getContentType ( ) ) and
457460 Cand:: parameterValueFlowReturnCand ( p , _, true ) and
458- compatibleTypes ( getNodeType ( p ) , read .getContainerType ( ) )
461+ compatibleTypes ( getNodeDataFlowType ( p ) , read .getContainerType ( ) )
459462 )
460463 or
461464 parameterValueFlow0_0 ( TReadStepTypesNone ( ) , p , node , read )
@@ -511,11 +514,11 @@ private module Cached {
511514 |
512515 // normal flow through
513516 read = TReadStepTypesNone ( ) and
514- compatibleTypes ( getNodeType ( arg ) , getNodeType ( out ) )
517+ compatibleTypes ( getNodeDataFlowType ( arg ) , getNodeDataFlowType ( out ) )
515518 or
516519 // 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 ) )
519522 )
520523 }
521524
@@ -653,8 +656,8 @@ private module Cached {
653656 ) {
654657 storeStep ( node1 , c , node2 ) and
655658 readStep ( _, c , _) and
656- contentType = getNodeType ( node1 ) and
657- containerType = getNodeType ( node2 )
659+ contentType = getNodeDataFlowType ( node1 ) and
660+ containerType = getNodeDataFlowType ( node2 )
658661 or
659662 exists ( Node n1 , Node n2 |
660663 n1 = node1 .( PostUpdateNode ) .getPreUpdateNode ( ) and
@@ -663,8 +666,8 @@ private module Cached {
663666 argumentValueFlowsThrough ( n2 , TReadStepTypesSome ( containerType , c , contentType ) , n1 )
664667 or
665668 readStep ( n2 , c , n1 ) and
666- contentType = getNodeType ( n1 ) and
667- containerType = getNodeType ( n2 )
669+ contentType = getNodeDataFlowType ( n1 ) and
670+ containerType = getNodeDataFlowType ( n2 )
668671 )
669672 }
670673
@@ -784,8 +787,8 @@ private predicate readStepWithTypes(
784787 Node n1 , DataFlowType container , Content c , Node n2 , DataFlowType content
785788) {
786789 readStep ( n1 , c , n2 ) and
787- container = getNodeType ( n1 ) and
788- content = getNodeType ( n2 )
790+ container = getNodeDataFlowType ( n1 ) and
791+ content = getNodeDataFlowType ( n2 )
789792}
790793
791794private newtype TReadStepTypesOption =
@@ -1023,10 +1026,13 @@ class ReturnPosition extends TReturnPosition0 {
10231026 */
10241027pragma [ inline]
10251028DataFlowCallable 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 ) )
10301036}
10311037
10321038pragma [ noinline]
0 commit comments