Skip to content

Commit a43b023

Browse files
committed
do the type thing
1 parent 925fd92 commit a43b023

File tree

1 file changed

+40
-22
lines changed

1 file changed

+40
-22
lines changed

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

Lines changed: 40 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,21 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
928928
nodeDataFlowType(this.asNode(), result)
929929
or
930930
nodeDataFlowType(this.asParamReturnNode(), result)
931-
//TODO
931+
or
932+
nodeDataFlowType(this.asLambdaInstancePostUpdateNode(), result)
933+
or
934+
nodeDataFlowType(this.asLambdaMallocNode(), result)
935+
or
936+
exists(
937+
DataFlowCall synthcall, ArgumentPosition apos, DataFlowCallable c, ParameterNode p,
938+
ParameterPosition ppos
939+
|
940+
this.isLambdaArgNode(synthcall, apos, _) and
941+
lambdaCreation(_, _, c, synthcall) and
942+
isParameterNode(p, c, ppos) and
943+
parameterMatch(ppos, apos) and
944+
nodeDataFlowType(p, result)
945+
)
932946
}
933947

934948
pragma[inline]
@@ -1745,26 +1759,28 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
17451759
contentType, containerType)
17461760
)
17471761
or
1748-
exists(
1749-
DataFlowCall call, LambdaCallKind k, Node receiver, ReturnKind kind, ArgumentPosition apos
1750-
|
1751-
lambdaCall(call, k, receiver) and
1752-
node2.asNode().(PostUpdateNode).getPreUpdateNode() = receiver and
1753-
c = getLambdaArgumentContent(k, apos) and
1754-
node1.asNode().(ArgNode).argumentOf(call, apos)
1755-
)
1756-
or
1757-
exists(DataFlowCallable lambda, LambdaCallKind k, ReturnKind kind |
1758-
lambdaCreation(_, k, lambda, _) and
1759-
hasSimpleReturnKindIn(node1.asNode(), kind, lambda) and
1760-
nodeGetEnclosingCallable(node2.asLambdaInstancePostUpdateNode()) = lambda and
1761-
c = getLambdaReturnContent(k, kind)
1762-
)
1763-
or
1764-
exists(DataFlowCall synthcall, LambdaCallKind k, ArgumentPosition apos |
1765-
lambdaCreation(node2.asNode(), k, _, synthcall) and
1766-
node1.isLambdaArgNode(synthcall, apos, true) and
1767-
c = getLambdaArgumentContent(k, apos)
1762+
contentType = node1.getDataFlowType() and
1763+
containerType = node2.getDataFlowType() and
1764+
(
1765+
exists(DataFlowCall call, LambdaCallKind k, Node receiver, ArgumentPosition apos |
1766+
lambdaCall(call, k, receiver) and
1767+
node2.asNode().(PostUpdateNode).getPreUpdateNode() = receiver and
1768+
c = getLambdaArgumentContent(k, apos) and
1769+
node1.asNode().(ArgNode).argumentOf(call, apos)
1770+
)
1771+
or
1772+
exists(DataFlowCallable lambda, LambdaCallKind k, ReturnKind kind |
1773+
lambdaCreation(_, k, lambda, _) and
1774+
hasSimpleReturnKindIn(node1.asNode(), kind, lambda) and
1775+
nodeGetEnclosingCallable(node2.asLambdaInstancePostUpdateNode()) = lambda and
1776+
c = getLambdaReturnContent(k, kind)
1777+
)
1778+
or
1779+
exists(DataFlowCall synthcall, LambdaCallKind k, ArgumentPosition apos |
1780+
lambdaCreation(node2.asNode(), k, _, synthcall) and
1781+
node1.isLambdaArgNode(synthcall, apos, true) and
1782+
c = getLambdaArgumentContent(k, apos)
1783+
)
17681784
)
17691785
}
17701786

@@ -1800,7 +1816,9 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
18001816
}
18011817

18021818
cached
1803-
predicate allowParameterReturnInSelfCached(ParamNode p) { allowParameterReturnInSelf(p) }
1819+
predicate allowParameterReturnInSelfCached(ParamNode p) {
1820+
allowParameterReturnInSelf(p) or isLambdaInstanceParameter(p)
1821+
}
18041822

18051823
cached
18061824
predicate paramMustFlow(ParamNode p, ArgNode arg) { localMustFlowStep+(p, arg) }

0 commit comments

Comments
 (0)