Skip to content

Commit 6e31214

Browse files
authored
Merge pull request github#18618 from MathiasVP/18592-follow-follow-up-up
C++: Don't infer lambda calls when there is a static dispatch
2 parents e141b4e + be2777b commit 6e31214

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1339,7 +1339,12 @@ predicate lambdaCreation(Node creation, LambdaCallKind kind, DataFlowCallable c)
13391339
/** Holds if `call` is a lambda call of kind `kind` where `receiver` is the lambda expression. */
13401340
predicate lambdaCall(DataFlowCall call, LambdaCallKind kind, Node receiver) {
13411341
(
1342-
call.(SummaryCall).getReceiver() = receiver.(FlowSummaryNode).getSummaryNode() or
1342+
call.(SummaryCall).getReceiver() = receiver.(FlowSummaryNode).getSummaryNode()
1343+
or
1344+
// No need to infer a lambda call if we already have a static dispatch target.
1345+
// We only need to check this in the disjunct since a `SummaryCall` never
1346+
// has a result for `getStaticCallTarget`.
1347+
not exists(call.getStaticCallTarget()) and
13431348
call.asCallInstruction().getCallTargetOperand() = receiver.asOperand()
13441349
) and
13451350
exists(kind)

0 commit comments

Comments
 (0)