@@ -34,7 +34,15 @@ Function viableCallable(CallInstruction call) {
3434private module VirtualDispatch {
3535 /** A call that may dispatch differently depending on the qualifier value. */
3636 abstract class DataSensitiveCall extends DataFlowCall {
37- abstract DataFlow:: Node getSrc ( ) ;
37+ /**
38+ * Gets the node whose value determines the target of this call. This node
39+ * could be the qualifier of a virtual dispatch or the function-pointer
40+ * expression in a call to a function pointer. What they have in common is
41+ * that we need to find out which data flows there, and then it's up to the
42+ * `resolve` predicate to stitch that information together and resolve the
43+ * call.
44+ */
45+ abstract DataFlow:: Node getDispatchValue ( ) ;
3846
3947 /** Gets a candidate target for this call. */
4048 cached
@@ -43,12 +51,12 @@ private module VirtualDispatch {
4351 /**
4452 * Whether `src` can flow to this call.
4553 *
46- * Searches backwards from `getSrc ()` to `src`. The `allowFromArg`
54+ * Searches backwards from `getDispatchValue ()` to `src`. The `allowFromArg`
4755 * parameter is true when the search is allowed to continue backwards into
4856 * a parameter; non-recursive callers should pass `_` for `allowFromArg`.
4957 */
5058 predicate flowsFrom ( DataFlow:: Node src , boolean allowFromArg ) {
51- src = this .getSrc ( ) and allowFromArg = true
59+ src = this .getDispatchValue ( ) and allowFromArg = true
5260 or
5361 exists ( DataFlow:: Node other , boolean allowOtherFromArg |
5462 this .flowsFrom ( other , allowOtherFromArg )
@@ -95,7 +103,7 @@ private module VirtualDispatch {
95103 private class DataSensitiveExprCall extends DataSensitiveCall {
96104 DataSensitiveExprCall ( ) { not exists ( this .getStaticCallTarget ( ) ) }
97105
98- override DataFlow:: Node getSrc ( ) { result .asInstruction ( ) = this .getCallTarget ( ) }
106+ override DataFlow:: Node getDispatchValue ( ) { result .asInstruction ( ) = this .getCallTarget ( ) }
99107
100108 override Function resolve ( ) {
101109 exists ( FunctionInstruction fi |
@@ -111,7 +119,7 @@ private module VirtualDispatch {
111119 exists ( this .getStaticCallTarget ( ) .( VirtualFunction ) .getAnOverridingFunction ( ) )
112120 }
113121
114- override DataFlow:: Node getSrc ( ) { result .asInstruction ( ) = this .getThisArgument ( ) }
122+ override DataFlow:: Node getDispatchValue ( ) { result .asInstruction ( ) = this .getThisArgument ( ) }
115123
116124 override MemberFunction resolve ( ) {
117125 exists ( Class overridingClass |
0 commit comments