Skip to content

Commit a99d576

Browse files
committed
C++: Add a new API for getting the target of a 'Call' expression.
1 parent 2dbf75f commit a99d576

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ private import SsaInternals as Ssa
1717
private import DataFlowImplCommon as DataFlowImplCommon
1818
private import codeql.util.Unit
1919
private import Node0ToString
20+
private import DataFlowDispatch as DataFlowDispatch
2021
import ExprNodes
2122

2223
/**
@@ -2497,3 +2498,16 @@ class AdditionalCallTarget extends Unit {
24972498
*/
24982499
abstract Declaration viableTarget(Call call);
24992500
}
2501+
2502+
/**
2503+
* Gets a function that may be called by `call`.
2504+
*
2505+
* Note that `call` may be a call to a function pointer expression.
2506+
*/
2507+
Function getARuntimeTarget(Call call) {
2508+
exists(DataFlowCall dfCall | dfCall.asCallInstruction().getUnconvertedResultExpression() = call |
2509+
result = DataFlowDispatch::viableCallable(dfCall).asSourceCallable()
2510+
or
2511+
result = DataFlowImplCommon::viableCallableLambda(dfCall, _).asSourceCallable()
2512+
)
2513+
}

0 commit comments

Comments
 (0)