Skip to content

Commit 3f56fc9

Browse files
committed
Address review comments
1 parent 5f9b8c0 commit 3f56fc9

File tree

1 file changed

+21
-26
lines changed

1 file changed

+21
-26
lines changed

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

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -628,8 +628,6 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
628628
override string toString() {
629629
exists(DataFlowCall call | this = TReturn(_, call) | result = "CcReturn(" + call + ")")
630630
}
631-
632-
predicate isReturn(DataFlowCallable c, DataFlowCall call) { this = TReturn(c, call) }
633631
}
634632

635633
pragma[nomagic]
@@ -1435,27 +1433,19 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
14351433
string model, CachedCallContextSensitivity::CcNoCall ctx
14361434
) {
14371435
exists(
1438-
DataFlowCall call, DataFlowCallable callable, ArgNode arg, string model1, string model2,
1439-
CachedCallContextSensitivity::CcNoCall ctx1, CachedCallContextSensitivity::CcNoCall ctx2
1436+
ArgNode arg, string model1, string model2, CachedCallContextSensitivity::CcNoCall ctx1,
1437+
CachedCallContextSensitivity::CcNoCall ctx2
14401438
|
14411439
model = mergeModels(model1, model2) and
1442-
(
1443-
// call may restrict the set of call sites that can be returned to
1444-
ctx2.(CachedCallContextSensitivity::CcReturn).isReturn(callable, call)
1445-
or
1446-
// call does not restrict the set of call sites that can be returned to
1447-
not exists(CachedCallContextSensitivity::CcReturn ret | ret.isReturn(callable, call)) and
1448-
CachedCallContextSensitivity::viableImplNotCallContextReducedReverse(ctx2)
1449-
) and
14501440
ctx = mergeContexts(ctx1, ctx2)
14511441
|
14521442
// flow through: no prior read
14531443
parameterValueFlowArg(p, arg, mustBeNone, model1, ctx1) and
1454-
argumentValueFlowsThrough(call, callable, arg, read, node, model2)
1444+
argumentValueFlowsThrough(arg, read, node, model2, ctx2)
14551445
or
14561446
// flow through: no read inside method
14571447
parameterValueFlowArg(p, arg, read, model1, ctx1) and
1458-
argumentValueFlowsThrough(call, callable, arg, mustBeNone, node, model2)
1448+
argumentValueFlowsThrough(arg, mustBeNone, node, model2, ctx2)
14591449
)
14601450
}
14611451

@@ -1470,27 +1460,32 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
14701460

14711461
pragma[nomagic]
14721462
private predicate argumentValueFlowsThrough0(
1473-
DataFlowCall call, DataFlowCallable callable, ArgNode arg, ReturnKind kind,
1474-
ReadStepTypesOption read, string model
1463+
DataFlowCall call, ArgNode arg, ReturnKind kind, ReadStepTypesOption read, string model,
1464+
CachedCallContextSensitivity::CcNoCall outerCtx
14751465
) {
1476-
exists(ParamNode param, CachedCallContextSensitivity::CcNoCall ctx |
1466+
exists(
1467+
ParamNode param, DataFlowCallable callable,
1468+
CachedCallContextSensitivity::CcNoCall innerCtx
1469+
|
14771470
viableParamArg(call, param, arg) and
1478-
parameterValueFlowReturn(param, kind, read, model, ctx) and
1479-
callable = nodeGetEnclosingCallable(param)
1471+
parameterValueFlowReturn(param, kind, read, model, innerCtx) and
1472+
callable = nodeGetEnclosingCallable(param) and
1473+
outerCtx = CachedCallContextSensitivity::getCallContextReturn(callable, call)
14801474
|
1481-
CachedCallContextSensitivity::viableImplNotCallContextReducedReverse(ctx)
1475+
CachedCallContextSensitivity::viableImplNotCallContextReducedReverse(innerCtx)
14821476
or
1483-
call = CachedCallContextSensitivity::viableImplCallContextReducedReverse(callable, ctx)
1477+
call =
1478+
CachedCallContextSensitivity::viableImplCallContextReducedReverse(callable, innerCtx)
14841479
)
14851480
}
14861481

14871482
pragma[nomagic]
14881483
private predicate argumentValueFlowsThrough(
1489-
DataFlowCall call, DataFlowCallable callable, ArgNode arg, ReadStepTypesOption read,
1490-
Node out, string model
1484+
ArgNode arg, ReadStepTypesOption read, Node out, string model,
1485+
CachedCallContextSensitivity::CcNoCall ctx
14911486
) {
1492-
exists(ReturnKind kind |
1493-
argumentValueFlowsThrough0(call, callable, arg, kind, read, model) and
1487+
exists(DataFlowCall call, ReturnKind kind |
1488+
argumentValueFlowsThrough0(call, arg, kind, read, model, ctx) and
14941489
out = getAnOutNode(call, kind)
14951490
|
14961491
// normal flow through
@@ -1515,7 +1510,7 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
15151510
predicate argumentValueFlowsThrough(
15161511
ArgNode arg, ReadStepTypesOption read, Node out, string model
15171512
) {
1518-
argumentValueFlowsThrough(_, _, arg, read, out, model)
1513+
argumentValueFlowsThrough(arg, read, out, model, _)
15191514
}
15201515

15211516
/**

0 commit comments

Comments
 (0)