File tree Expand file tree Collapse file tree 2 files changed +20
-10
lines changed
go/ql/lib/semmle/go/dataflow/internal Expand file tree Collapse file tree 2 files changed +20
-10
lines changed Original file line number Diff line number Diff line change @@ -149,9 +149,10 @@ predicate golangSpecificParamArgFilter(
149149 // Interface methods calls may be passed strictly to that exact method's model receiver:
150150 arg .getPosition ( ) != - 1
151151 or
152- exists ( Function callTarget | callTarget = call .getNode ( ) .( DataFlow:: CallNode ) .getTarget ( ) |
153- not isInterfaceMethod ( callTarget )
154- or
155- callTarget = p .getCallable ( ) .asSummarizedCallable ( ) .asFunction ( )
156- )
152+ p instanceof DataFlow:: SummarizedParameterNode
153+ or
154+ not isInterfaceMethod ( call .getNode ( )
155+ .( DataFlow:: CallNode )
156+ .getACalleeWithoutVirtualDispatch ( )
157+ .asFunction ( ) )
157158}
Original file line number Diff line number Diff line change @@ -489,13 +489,9 @@ module Public {
489489 * interface type.
490490 */
491491 Callable getACalleeIncludingExternals ( ) {
492- result . asFunction ( ) = this .getTarget ( )
492+ result = this .getACalleeWithoutVirtualDispatch ( )
493493 or
494494 exists ( DataFlow:: Node calleeSource | calleeSource = this .getACalleeSource ( ) |
495- result .asFuncLit ( ) = calleeSource .asExpr ( )
496- or
497- calleeSource = result .asFunction ( ) .getARead ( )
498- or
499495 exists ( Method declared , Method actual |
500496 calleeSource = declared .getARead ( ) and
501497 actual .implements ( declared ) and
@@ -510,6 +506,19 @@ module Public {
510506 */
511507 FuncDef getACallee ( ) { result = this .getACalleeIncludingExternals ( ) .getFuncDef ( ) }
512508
509+ /**
510+ * Gets the definition of a possible target of this call, excluding targets reachable via virtual dispatch.
511+ */
512+ Callable getACalleeWithoutVirtualDispatch ( ) {
513+ result .asFunction ( ) = this .getTarget ( )
514+ or
515+ exists ( DataFlow:: Node calleeSource | calleeSource = this .getACalleeSource ( ) |
516+ result .asFuncLit ( ) = calleeSource .asExpr ( )
517+ or
518+ calleeSource = result .asFunction ( ) .getARead ( )
519+ )
520+ }
521+
513522 /**
514523 * Gets the name of the function, method or variable that is being called.
515524 *
You can’t perform that action at this time.
0 commit comments