Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Commit 1c58028

Browse files
author
Max Schaefer
committed
Expose receiver type in isInterfaceCallReceiver.
1 parent 0e5e116 commit 1c58028

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

ql/src/semmle/go/dataflow/internal/DataFlowDispatch.qll

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,20 @@ private import go
22
private import DataFlowPrivate
33

44
/**
5-
* Holds if `call` is an interface call to method `m`, meaning that its receiver `recv` has an
6-
* interface type.
5+
* Holds if `call` is an interface call to method `m`, meaning that its receiver `recv` has
6+
* interface type `tp`.
77
*/
8-
private predicate isInterfaceCallReceiver(DataFlow::CallNode call, DataFlow::Node recv, string m) {
8+
private predicate isInterfaceCallReceiver(
9+
DataFlow::CallNode call, DataFlow::Node recv, InterfaceType tp, string m
10+
) {
911
call.getReceiver() = recv and
10-
recv.getType().getUnderlyingType() instanceof InterfaceType and
12+
recv.getType().getUnderlyingType() = tp and
1113
m = call.getCalleeName()
1214
}
1315

1416
/** Gets a data-flow node that may flow into the receiver value of `call`, which is an interface value. */
1517
private DataFlow::Node getInterfaceCallReceiverSource(DataFlow::CallNode call) {
16-
isInterfaceCallReceiver(call, result.getASuccessor*(), _)
18+
isInterfaceCallReceiver(call, result.getASuccessor*(), _, _)
1719
}
1820

1921
/** Gets the type of `nd`, which must be a valid type and not an interface type. */
@@ -44,7 +46,7 @@ private predicate isConcreteValue(DataFlow::Node nd) {
4446
* types of `recv` can be established by local reasoning.
4547
*/
4648
private predicate isConcreteInterfaceCall(DataFlow::Node call, DataFlow::Node recv, string m) {
47-
isInterfaceCallReceiver(call, recv, m) and isConcreteValue(recv)
49+
isInterfaceCallReceiver(call, recv, _, m) and isConcreteValue(recv)
4850
}
4951

5052
/**

0 commit comments

Comments
 (0)