Skip to content

Commit ce6d80c

Browse files
committed
wip
1 parent 5dbdc9f commit ce6d80c

File tree

2 files changed

+13
-51
lines changed

2 files changed

+13
-51
lines changed

shared/dataflow/codeql/dataflow/internal/DataFlowImpl.qll

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,16 +1143,8 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
11431143
) {
11441144
exists(RetNodeEx ret |
11451145
flowOutOfCallNodeCand1(call, ret, _, out) and
1146-
c = ret.getEnclosingCallable()
1147-
|
1146+
c = ret.getEnclosingCallable() and
11481147
scope = getSecondLevelScopeEx(ret)
1149-
or
1150-
// ret = TParamReturnNode(_, scope)
1151-
ret = TParamReturnNode(_) and
1152-
scope.isNone() // todo
1153-
or
1154-
parameterNode(ret.asNodeReverse(_), _, _) and
1155-
scope.isNone() // todo
11561148
)
11571149
}
11581150

@@ -3481,7 +3473,7 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
34813473

34823474
/** Gets the parameter node through which data is returned, if any. */
34833475
final ParameterNode asParameterReturnNode() {
3484-
result = super.getNodeEx().asParamReturnNode()
3476+
result = super.getNodeEx().asNodeReverse(_)
34853477
}
34863478

34873479
/** Gets the `FlowState` of this node. */

shared/dataflow/codeql/dataflow/internal/DataFlowImplCommon.qll

Lines changed: 11 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}
@@ -1205,10 +1195,7 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
12051195
}
12061196

12071197
cached
1208-
predicate castingNodeEx(NodeEx n) {
1209-
[n.asNode(), n.asNodeReverse(_)] instanceof CastingNode or
1210-
exists(n.asParamReturnNode())
1211-
}
1198+
predicate castingNodeEx(NodeEx n) { [n.asNode(), n.asNodeReverse(_)] instanceof CastingNode }
12121199

12131200
cached
12141201
predicate parameterNode(Node p, DataFlowCallable c, ParameterPosition pos) {
@@ -1790,7 +1777,10 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
17901777
predicate readEx(NodeEx node1, ContentSet c, NodeEx node2) {
17911778
readSet(pragma[only_bind_into](node1.asNode()), c, pragma[only_bind_into](node2.asNode()))
17921779
or
1793-
exists(boolean b | storeSet(node2.asNodeReverse(b), c, node1.asNodeReverse(b), _, _))
1780+
exists(boolean b |
1781+
storeSet(pragma[only_bind_into](node2.asNodeReverse(b)), c,
1782+
pragma[only_bind_into](node1.asNodeReverse(b)), _, _)
1783+
)
17941784
}
17951785

17961786
cached
@@ -2028,11 +2018,7 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
20282018
cached
20292019
newtype TNodeEx =
20302020
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
2021+
TNodeImplicitRead(Node n) or
20362022
TNodeReverse(Node n, Boolean b)
20372023

20382024
/**
@@ -2046,17 +2032,6 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
20462032
simpleLocalFlowStepExt(pragma[only_bind_into](n1), pragma[only_bind_into](n2), model)
20472033
)
20482034
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
20602035
exists(Node n1, Node n2 |
20612036
node1.asNodeReverse(_) = n1 and
20622037
node2.asNodeReverse(false) = n2 and
@@ -2071,11 +2046,6 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
20712046
ReturnPosition getReturnPositionEx(NodeEx ret) {
20722047
result = getValueReturnPosition(ret.asNode())
20732048
or
2074-
exists(ParamNode p |
2075-
ret = TParamReturnNode(p) and
2076-
result = getParamReturnPosition(p)
2077-
)
2078-
or
20792049
exists(DataFlowCallable c, ParameterPosition ppos |
20802050
parameterNode(ret.asNodeReverse(_), c, ppos) and
20812051
result = TReverseReturnPosition(c, ppos) //and

0 commit comments

Comments
 (0)