Skip to content

Commit cca5bd9

Browse files
committed
C++: Update 'mayBenefitFromCallContext' to not use the old virtual dispatch local flow predicate.
1 parent 383799c commit cca5bd9

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowDispatch.qll

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,12 @@ predicate mayBenefitFromCallContext(DataFlowPrivate::DataFlowCall call) {
330330
mayBenefitFromCallContext(call, _, _)
331331
}
332332

333+
private predicate localLambdaFlowStep(Node nodeFrom, Node nodeTo) {
334+
localFlowStep(nodeFrom, nodeTo)
335+
or
336+
DataFlowPrivate::additionalLambdaFlowStep(nodeFrom, nodeTo, _)
337+
}
338+
333339
/**
334340
* Holds if `call` is a call through a function pointer, and the pointer
335341
* value is given as the `arg`'th argument to `f`.
@@ -339,9 +345,13 @@ private predicate mayBenefitFromCallContext(
339345
) {
340346
f = pragma[only_bind_out](call).getEnclosingCallable() and
341347
exists(InitializeParameterInstruction init |
342-
not exists(call.getStaticCallTarget()) and
348+
not exists(call.getStaticCallTarget())
349+
or
350+
exists(call.getStaticCallSourceTarget().(VirtualFunction).getAnOverridingFunction())
351+
|
343352
init.getEnclosingFunction() = f.getUnderlyingCallable() and
344-
call.flowsFrom(instructionNode(init), _) and
353+
localLambdaFlowStep+(instructionNode(init),
354+
operandNode(call.asCallInstruction().getCallTargetOperand())) and
345355
init.getParameter().getIndex() = arg
346356
)
347357
}

0 commit comments

Comments
 (0)