@@ -238,7 +238,12 @@ private module TrackVirtualDispatch<methodDispatchSig/1 virtualDispatch0> {
238238
239239 private import TypeTracking< Location , TtInput > :: TypeTrack< qualifierSource / 1 > :: Graph< qualifierOfVirtualCall / 1 >
240240
241- private predicate edgePlus ( PathNode n1 , PathNode n2 ) = fastTC( edges / 2 ) ( n1 , n2 )
241+ private predicate isSource ( PathNode n ) { n .isSource ( ) }
242+
243+ private predicate isSink ( PathNode n ) { n .isSink ( ) }
244+
245+ private predicate edgePlus ( PathNode n1 , PathNode n2 ) =
246+ doublyBoundedFastTC( edges / 2 , isSource / 1 , isSink / 1 ) ( n1 , n2 )
242247
243248 /**
244249 * Gets the most specific implementation of `mf` that may be called when the
@@ -255,6 +260,15 @@ private module TrackVirtualDispatch<methodDispatchSig/1 virtualDispatch0> {
255260 )
256261 }
257262
263+ pragma [ nomagic]
264+ private MemberFunction mostSpecificForSource ( PathNode p1 , MemberFunction mf ) {
265+ p1 .isSource ( ) and
266+ exists ( Class derived |
267+ qualifierSourceImpl ( p1 .getNode ( ) , derived ) and
268+ result = mostSpecific ( mf , derived )
269+ )
270+ }
271+
258272 /**
259273 * Gets a possible pair of end-points `(p1, p2)` where:
260274 * - `p1` is a derived-to-base conversion that converts from some
@@ -264,16 +278,16 @@ private module TrackVirtualDispatch<methodDispatchSig/1 virtualDispatch0> {
264278 * - `callable` is the most specific implementation that may be called when
265279 * the qualifier has type `derived`.
266280 */
281+ bindingset [ p1, p2]
282+ pragma [ inline_late]
267283 private predicate pairCand (
268284 PathNode p1 , PathNode p2 , DataFlowPrivate:: DataFlowCallable callable ,
269285 DataFlowPrivate:: DataFlowCall call
270286 ) {
271- exists ( Class derived , MemberFunction mf |
272- qualifierSourceImpl ( p1 . getNode ( ) , derived ) and
287+ p2 . isSink ( ) and
288+ exists ( MemberFunction mf |
273289 qualifierOfVirtualCallImpl ( p2 .getNode ( ) , call .asCallInstruction ( ) , mf ) and
274- p1 .isSource ( ) and
275- p2 .isSink ( ) and
276- callable .asSourceCallable ( ) = mostSpecific ( mf , derived )
290+ callable .asSourceCallable ( ) = mostSpecificForSource ( p1 , mf )
277291 )
278292 }
279293
0 commit comments