Skip to content

Commit 42fcfca

Browse files
committed
C++: Remove the old virtual dispatch case from 'defaultViableCallable' and slightly reorganize the code in preparation for the next commit.
1 parent c1b91db commit 42fcfca

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,15 @@ private import DataFlowImplCommon as DataFlowImplCommon
1111
* from `AdditionalCallTarget` into account.
1212
*/
1313
cached
14-
DataFlowCallable defaultViableCallable(DataFlowCall call) {
14+
DataFlowPrivate::DataFlowCallable defaultViableCallable(DataFlowPrivate::DataFlowCall call) {
15+
result = defaultViableCallableWithoutLambda(call)
16+
or
17+
result = DataFlowImplCommon::viableCallableLambda(call, _)
18+
}
19+
20+
private DataFlowPrivate::DataFlowCallable defaultViableCallableWithoutLambda(
21+
DataFlowPrivate::DataFlowCall call
22+
) {
1523
DataFlowImplCommon::forceCachingInSameStage() and
1624
result = call.getStaticCallTarget()
1725
or
@@ -26,17 +34,13 @@ DataFlowCallable defaultViableCallable(DataFlowCall call) {
2634
functionSignatureWithBody(qualifiedName, nparams, result.getUnderlyingCallable()) and
2735
strictcount(Function other | functionSignatureWithBody(qualifiedName, nparams, other)) = 1
2836
)
29-
or
30-
// Virtual dispatch
31-
result.asSourceCallable() = call.(VirtualDispatch::DataSensitiveCall).resolve()
3237
}
3338

3439
/**
3540
* Gets a function that might be called by `call`.
3641
*/
37-
cached
38-
DataFlowCallable viableCallable(DataFlowCall call) {
39-
result = defaultViableCallable(call)
42+
private DataFlowPrivate::DataFlowCallable nonVirtualDispatch(DataFlowPrivate::DataFlowCall call) {
43+
result = defaultViableCallableWithoutLambda(call)
4044
or
4145
// Additional call targets
4246
result.getUnderlyingCallable() =

0 commit comments

Comments
 (0)