Skip to content

Commit 96f4f76

Browse files
committed
C++: Update 'mayBenefitFromCallContext' to not use the old virtual dispatch local flow predicate.
1 parent aa251cf commit 96f4f76

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
@@ -328,6 +328,12 @@ predicate mayBenefitFromCallContext(DataFlowPrivate::DataFlowCall call) {
328328
mayBenefitFromCallContext(call, _, _)
329329
}
330330

331+
private predicate localLambdaFlowStep(Node nodeFrom, Node nodeTo) {
332+
localFlowStep(nodeFrom, nodeTo)
333+
or
334+
DataFlowPrivate::additionalLambdaFlowStep(nodeFrom, nodeTo, _)
335+
}
336+
331337
/**
332338
* Holds if `call` is a call through a function pointer, and the pointer
333339
* value is given as the `arg`'th argument to `f`.
@@ -337,9 +343,13 @@ private predicate mayBenefitFromCallContext(
337343
) {
338344
f = pragma[only_bind_out](call).getEnclosingCallable() and
339345
exists(InitializeParameterInstruction init |
340-
not exists(call.getStaticCallTarget()) and
346+
not exists(call.getStaticCallTarget())
347+
or
348+
exists(call.getStaticCallSourceTarget().(VirtualFunction).getAnOverridingFunction())
349+
|
341350
init.getEnclosingFunction() = f.getUnderlyingCallable() and
342-
call.flowsFrom(instructionNode(init), _) and
351+
localLambdaFlowStep+(instructionNode(init),
352+
operandNode(call.asCallInstruction().getCallTargetOperand())) and
343353
init.getParameter().getIndex() = arg
344354
)
345355
}

0 commit comments

Comments
 (0)