@@ -872,8 +872,6 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
872872 or
873873 exists ( Node n | this .isImplicitReadNode ( n ) | result = n .toString ( ) + " [Ext]" )
874874 or
875- result = this .asParamReturnNode ( ) .toString ( ) + " [Return]"
876- or
877875 // exists(boolean b | result = this.asNodeReverse(b).toString() + " [Reverse, " + b + "]")
878876 result = this .asNodeReverse ( _) .toString ( ) + " [Reverse]"
879877 }
@@ -887,12 +885,9 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
887885
888886 predicate isImplicitReadNode ( Node n ) { this = TNodeImplicitRead ( n ) }
889887
890- ParameterNode asParamReturnNode ( ) { this = TParamReturnNode ( result ) }
891-
892888 Node projectToNode ( ) {
893889 this = TNodeNormal ( result ) or
894890 this = TNodeImplicitRead ( result ) or
895- this = TParamReturnNode ( result ) or
896891 this = TNodeReverse ( result , _)
897892 }
898893
@@ -911,8 +906,6 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
911906 nodeDataFlowType ( this .asNode ( ) , result )
912907 or
913908 nodeDataFlowType ( this .asNodeReverse ( _) , result )
914- or
915- nodeDataFlowType ( this .asParamReturnNode ( ) , result )
916909 }
917910
918911 pragma [ inline]
@@ -981,12 +974,9 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
981974 this .asNode ( ) .( ArgNode ) .argumentOf ( call_ .asDataFlowCall ( true ) , pos_ .asArgumentPosition ( ) )
982975 or
983976 exists ( boolean b |
984- // this.asNodeReverse() = getAnOutNodeExt(call_, pos_.asReturnKind()) and
985- this .asNodeReverse ( b ) =
986- getAnOutNode ( call_ .asDataFlowCall ( b ) , pos_ .asReturnKind ( ) .( ValueReturnKind ) .getKind ( ) ) //and //and
977+ pragma [ only_bind_into ] ( this .asNodeReverse ( b ) ) =
978+ getAnOutNode ( call_ .asDataFlowCall ( b ) , pos_ .asReturnKind ( ) .( ValueReturnKind ) .getKind ( ) )
987979 )
988- // not this.asNodeReverse() instanceof PostUpdateNode // needed for swift
989- // call_.toString().matches("%GetBox1%")
990980 }
991981
992982 predicate argumentOf ( DataFlowCallEx call , ArgumentPositionEx pos ) {
@@ -1084,8 +1074,8 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
10841074 }
10851075
10861076 cached
1087- SndLevelScopeOption getSecondLevelScopeEx ( NodeEx n ) {
1088- result = getSecondLevelScope0 ( n .asNode ( ) )
1077+ SndLevelScopeOption getSecondLevelScopeEx ( RetNodeEx n ) {
1078+ result = getSecondLevelScope0 ( [ n .asNode ( ) , n . asNodeReverse ( _ ) ] )
10891079 }
10901080
10911081 cached
@@ -1139,7 +1129,7 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
11391129
11401130 cached
11411131 predicate hiddenNode ( NodeEx n ) {
1142- nodeIsHidden ( [ n .asNode ( ) , n .asNodeReverse ( _) , n . asParamReturnNode ( ) ] )
1132+ nodeIsHidden ( [ n .asNode ( ) , n .asNodeReverse ( _) ] )
11431133 or
11441134 n instanceof TNodeImplicitRead
11451135 }
@@ -1156,19 +1146,18 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
11561146
11571147 cached
11581148 OutNodeEx getAnOutNodeEx ( DataFlowCallEx call , ReturnKindExt k ) {
1159- result .asNode ( ) = getAnOutNodeExt ( call .asDataFlowCall ( _) , k )
1160- or
1161- // todo
1162- exists ( ArgumentPosition apos , ParameterPosition ppos , ArgNode arg , boolean b |
1163- parameterMatch ( ppos , apos ) and
1164- k = TParamReverse ( ppos ) and
1165- arg .argumentOf ( call .asDataFlowCall ( b ) , apos )
1166- |
1167- b = false and
1168- result .asNodeReverse ( _) = arg
1149+ exists ( DataFlowCall c , boolean b | c = call .asDataFlowCall ( b ) |
1150+ result .asNode ( ) = getAnOutNode ( c , k .( ValueReturnKind ) .getKind ( ) )
11691151 or
1170- b = true and
1171- result .asNode ( ) .( PostUpdateNode ) .getPreUpdateNode ( ) = arg
1152+ exists ( ArgNode arg |
1153+ arg .argumentOf ( c , k .( ParamUpdateReturnKind ) .getAMatchingArgumentPosition ( ) )
1154+ |
1155+ b = false and
1156+ result .asNodeReverse ( _) = arg
1157+ or
1158+ b = true and
1159+ result .asNode ( ) .( PostUpdateNode ) .getPreUpdateNode ( ) = arg
1160+ )
11721161 )
11731162 }
11741163
@@ -1205,10 +1194,7 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
12051194 }
12061195
12071196 cached
1208- predicate castingNodeEx ( NodeEx n ) {
1209- [ n .asNode ( ) , n .asNodeReverse ( _) ] instanceof CastingNode or
1210- exists ( n .asParamReturnNode ( ) )
1211- }
1197+ predicate castingNodeEx ( NodeEx n ) { [ n .asNode ( ) , n .asNodeReverse ( _) ] instanceof CastingNode }
12121198
12131199 cached
12141200 predicate parameterNode ( Node p , DataFlowCallable c , ParameterPosition pos ) {
@@ -1790,7 +1776,10 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
17901776 predicate readEx ( NodeEx node1 , ContentSet c , NodeEx node2 ) {
17911777 readSet ( pragma [ only_bind_into ] ( node1 .asNode ( ) ) , c , pragma [ only_bind_into ] ( node2 .asNode ( ) ) )
17921778 or
1793- exists ( boolean b | storeSet ( node2 .asNodeReverse ( b ) , c , node1 .asNodeReverse ( b ) , _, _) )
1779+ exists ( boolean b |
1780+ storeSet ( pragma [ only_bind_into ] ( node2 .asNodeReverse ( b ) ) , c ,
1781+ pragma [ only_bind_into ] ( node1 .asNodeReverse ( b ) ) , _, _)
1782+ )
17941783 }
17951784
17961785 cached
@@ -1949,9 +1938,6 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
19491938 hasValueReturnKindIn ( _, kind , c )
19501939 or
19511940 hasParamReturnKindIn ( _, kind , c )
1952- } or
1953- TReverseReturnPosition ( DataFlowCallable c , ParameterPosition ppos ) {
1954- parameterNode ( _, c , ppos )
19551941 }
19561942
19571943 cached
@@ -1986,8 +1972,7 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
19861972 cached
19871973 newtype TReturnKindExt =
19881974 TValueReturn ( ReturnKind kind ) or
1989- TParamUpdate ( ParameterPosition pos ) { exists ( ParamNode p | p .isParameterOf ( _, pos ) ) } or
1990- TParamReverse ( ParameterPosition pos ) { exists ( ParamNode p | p .isParameterOf ( _, pos ) ) } // todo: reuse `ParamUpdate`?
1975+ TParamUpdate ( ParameterPosition pos ) { exists ( ParamNode p | p .isParameterOf ( _, pos ) ) }
19911976
19921977 cached
19931978 newtype TBooleanOption =
@@ -2028,11 +2013,7 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
20282013 cached
20292014 newtype TNodeEx =
20302015 TNodeNormal ( Node n ) or
2031- TNodeImplicitRead ( Node n ) or // will be restricted to nodes with actual implicit reads in `DataFlowImpl.qll`
2032- // TParamReturnNode(ParameterNode p, SndLevelScopeOption scope) {
2033- // paramReturnNode(_, p, scope, _)
2034- // } or
2035- TParamReturnNode ( ParameterNode p ) or
2016+ TNodeImplicitRead ( Node n ) or
20362017 TNodeReverse ( Node n , Boolean b )
20372018
20382019 /**
@@ -2046,17 +2027,6 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
20462027 simpleLocalFlowStepExt ( pragma [ only_bind_into ] ( n1 ) , pragma [ only_bind_into ] ( n2 ) , model )
20472028 )
20482029 or
2049- // or
2050- // exists(Node n1, Node n2, SndLevelScopeOption scope |
2051- // node1.asNode() = n1 and
2052- // node2 = TParamReturnNode(n2, scope) and
2053- // paramReturnNode(pragma[only_bind_into](n1), pragma[only_bind_into](n2),
2054- // pragma[only_bind_into](scope), _) and
2055- // model = ""
2056- // )
2057- // node2 = TParamReturnNode(node1.asNodeReverse()) and
2058- // model = ""
2059- // or
20602030 exists ( Node n1 , Node n2 |
20612031 node1 .asNodeReverse ( _) = n1 and
20622032 node2 .asNodeReverse ( false ) = n2 and
@@ -2071,16 +2041,7 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
20712041 ReturnPosition getReturnPositionEx ( NodeEx ret ) {
20722042 result = getValueReturnPosition ( ret .asNode ( ) )
20732043 or
2074- exists ( ParamNode p |
2075- ret = TParamReturnNode ( p ) and
2076- result = getParamReturnPosition ( p )
2077- )
2078- or
2079- exists ( DataFlowCallable c , ParameterPosition ppos |
2080- parameterNode ( ret .asNodeReverse ( _) , c , ppos ) and
2081- result = TReverseReturnPosition ( c , ppos ) //and
2082- // c.toString().matches("%GetBox1%")
2083- )
2044+ result = getParamReturnPosition ( ret .asNodeReverse ( _) )
20842045 }
20852046 }
20862047
@@ -2604,16 +2565,6 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
26042565 OutNodeExt ( ) { outNodeExt ( this ) }
26052566 }
26062567
2607- pragma [ nomagic]
2608- OutNodeExt getAnOutNodeExt ( DataFlowCall call , ReturnKindExt k ) {
2609- result = getAnOutNode ( call , k .( ValueReturnKind ) .getKind ( ) )
2610- or
2611- exists ( ArgNode arg |
2612- result .( PostUpdateNode ) .getPreUpdateNode ( ) = arg and
2613- arg .argumentOf ( call , k .( ParamUpdateReturnKind ) .getAMatchingArgumentPosition ( ) )
2614- )
2615- }
2616-
26172568 /**
26182569 * An extended return kind. A return kind describes how data can be returned
26192570 * from a callable. This can either be through a returned value or an updated
@@ -2650,31 +2601,12 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
26502601 override string toString ( ) { result = "param update " + pos }
26512602 }
26522603
2653- class ParamReverseReturnKind extends ReturnKindExt , TParamReverse {
2654- private ParameterPosition pos ;
2655-
2656- ParamReverseReturnKind ( ) { this = TParamReverse ( pos ) }
2657-
2658- ParameterPosition getPosition ( ) { result = pos }
2659-
2660- // pragma[nomagic]
2661- // ArgumentPosition getAMatchingArgumentPosition() { parameterMatch(pos, result) }
2662- override string toString ( ) { result = "param reverse " + pos }
2663- }
2664-
26652604 /** A callable tagged with a relevant return kind. */
26662605 class ReturnPosition extends TReturnPosition {
26672606 private DataFlowCallable c ;
26682607 private ReturnKindExt kind ;
26692608
2670- ReturnPosition ( ) {
2671- this = TReturnPosition0 ( c , kind )
2672- or
2673- exists ( ParameterPosition ppos |
2674- this = TReverseReturnPosition ( c , ppos ) and
2675- kind = TParamReverse ( ppos )
2676- )
2677- }
2609+ ReturnPosition ( ) { this = TReturnPosition0 ( c , kind ) }
26782610
26792611 /** Gets the callable. */
26802612 DataFlowCallable getCallable ( ) { result = c }
0 commit comments