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(
149
149
// Interface methods calls may be passed strictly to that exact method's model receiver:
150
150
arg .getPosition ( ) != - 1
151
151
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 ( ) )
157
158
}
Original file line number Diff line number Diff line change @@ -489,13 +489,9 @@ module Public {
489
489
* interface type.
490
490
*/
491
491
Callable getACalleeIncludingExternals ( ) {
492
- result . asFunction ( ) = this .getTarget ( )
492
+ result = this .getACalleeWithoutVirtualDispatch ( )
493
493
or
494
494
exists ( DataFlow:: Node calleeSource | calleeSource = this .getACalleeSource ( ) |
495
- result .asFuncLit ( ) = calleeSource .asExpr ( )
496
- or
497
- calleeSource = result .asFunction ( ) .getARead ( )
498
- or
499
495
exists ( Method declared , Method actual |
500
496
calleeSource = declared .getARead ( ) and
501
497
actual .implements ( declared ) and
@@ -510,6 +506,19 @@ module Public {
510
506
*/
511
507
FuncDef getACallee ( ) { result = this .getACalleeIncludingExternals ( ) .getFuncDef ( ) }
512
508
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
+
513
522
/**
514
523
* Gets the name of the function, method or variable that is being called.
515
524
*
You can’t perform that action at this time.
0 commit comments