@@ -25,42 +25,60 @@ class AnnotatedFunction extends Function {
2525}
2626
2727/** A function annotated with `calls:NAME` */
28- class AnnotatedCall extends InvokeExpr {
28+ class AnnotatedCall extends DataFlow :: SourceNode {
2929 string calls ;
30+ string kind ;
3031
31- AnnotatedCall ( ) { calls = getAnnotation ( this , "calls" ) }
32+ AnnotatedCall ( ) {
33+ this instanceof DataFlow:: InvokeNode and
34+ calls = getAnnotation ( this .asExpr ( ) , kind ) and
35+ kind = "calls"
36+ or
37+ this instanceof DataFlow:: PropRef and
38+ calls = getAnnotation ( this .getAstNode ( ) , kind ) and
39+ kind = "callsAccessor"
40+ }
3241
3342 string getCallTargetName ( ) { result = calls }
3443
35- AnnotatedFunction getAnExpectedCallee ( ) { result .getCalleeName ( ) = getCallTargetName ( ) }
44+ AnnotatedFunction getAnExpectedCallee ( string kind_ ) {
45+ result .getCalleeName ( ) = getCallTargetName ( ) and
46+ kind = kind_
47+ }
3648
37- int getBoundArgs ( ) { result = getAnnotation ( this , "boundArgs" ) .toInt ( ) }
49+ int getBoundArgs ( ) { result = getAnnotation ( this . getAstNode ( ) , "boundArgs" ) .toInt ( ) }
3850
3951 int getBoundArgsOrMinusOne ( ) {
4052 result = getBoundArgs ( )
4153 or
4254 not exists ( getBoundArgs ( ) ) and
4355 result = - 1
4456 }
57+
58+ string getKind ( ) {
59+ result = kind
60+ }
4561}
4662
4763predicate callEdge ( AnnotatedCall call , AnnotatedFunction target , int boundArgs ) {
48- FlowSteps:: calls ( call . flow ( ) , target ) and boundArgs = - 1
64+ FlowSteps:: calls ( call , target ) and boundArgs = - 1
4965 or
50- FlowSteps:: callsBound ( call . flow ( ) , target , boundArgs )
66+ FlowSteps:: callsBound ( call , target , boundArgs )
5167}
5268
53- query predicate spuriousCallee ( AnnotatedCall call , AnnotatedFunction target , int boundArgs ) {
69+ query predicate spuriousCallee ( AnnotatedCall call , AnnotatedFunction target , int boundArgs , string kind ) {
5470 callEdge ( call , target , boundArgs ) and
71+ kind = call .getKind ( ) and
5572 not (
56- target = call .getAnExpectedCallee ( ) and
73+ target = call .getAnExpectedCallee ( kind ) and
5774 boundArgs = call .getBoundArgsOrMinusOne ( )
5875 )
5976}
6077
61- query predicate missingCallee ( AnnotatedCall call , AnnotatedFunction target , int boundArgs ) {
78+ query predicate missingCallee ( AnnotatedCall call , AnnotatedFunction target , int boundArgs , string kind ) {
6279 not callEdge ( call , target , boundArgs ) and
63- target = call .getAnExpectedCallee ( ) and
80+ kind = call .getKind ( ) and
81+ target = call .getAnExpectedCallee ( kind ) and
6482 boundArgs = call .getBoundArgsOrMinusOne ( )
6583}
6684
0 commit comments