@@ -25,42 +25,60 @@ class AnnotatedFunction extends Function {
25
25
}
26
26
27
27
/** A function annotated with `calls:NAME` */
28
- class AnnotatedCall extends InvokeExpr {
28
+ class AnnotatedCall extends DataFlow :: SourceNode {
29
29
string calls ;
30
+ string kind ;
30
31
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
+ }
32
41
33
42
string getCallTargetName ( ) { result = calls }
34
43
35
- AnnotatedFunction getAnExpectedCallee ( ) { result .getCalleeName ( ) = getCallTargetName ( ) }
44
+ AnnotatedFunction getAnExpectedCallee ( string kind_ ) {
45
+ result .getCalleeName ( ) = getCallTargetName ( ) and
46
+ kind = kind_
47
+ }
36
48
37
- int getBoundArgs ( ) { result = getAnnotation ( this , "boundArgs" ) .toInt ( ) }
49
+ int getBoundArgs ( ) { result = getAnnotation ( this . getAstNode ( ) , "boundArgs" ) .toInt ( ) }
38
50
39
51
int getBoundArgsOrMinusOne ( ) {
40
52
result = getBoundArgs ( )
41
53
or
42
54
not exists ( getBoundArgs ( ) ) and
43
55
result = - 1
44
56
}
57
+
58
+ string getKind ( ) {
59
+ result = kind
60
+ }
45
61
}
46
62
47
63
predicate callEdge ( AnnotatedCall call , AnnotatedFunction target , int boundArgs ) {
48
- FlowSteps:: calls ( call . flow ( ) , target ) and boundArgs = - 1
64
+ FlowSteps:: calls ( call , target ) and boundArgs = - 1
49
65
or
50
- FlowSteps:: callsBound ( call . flow ( ) , target , boundArgs )
66
+ FlowSteps:: callsBound ( call , target , boundArgs )
51
67
}
52
68
53
- query predicate spuriousCallee ( AnnotatedCall call , AnnotatedFunction target , int boundArgs ) {
69
+ query predicate spuriousCallee ( AnnotatedCall call , AnnotatedFunction target , int boundArgs , string kind ) {
54
70
callEdge ( call , target , boundArgs ) and
71
+ kind = call .getKind ( ) and
55
72
not (
56
- target = call .getAnExpectedCallee ( ) and
73
+ target = call .getAnExpectedCallee ( kind ) and
57
74
boundArgs = call .getBoundArgsOrMinusOne ( )
58
75
)
59
76
}
60
77
61
- query predicate missingCallee ( AnnotatedCall call , AnnotatedFunction target , int boundArgs ) {
78
+ query predicate missingCallee ( AnnotatedCall call , AnnotatedFunction target , int boundArgs , string kind ) {
62
79
not callEdge ( call , target , boundArgs ) and
63
- target = call .getAnExpectedCallee ( ) and
80
+ kind = call .getKind ( ) and
81
+ target = call .getAnExpectedCallee ( kind ) and
64
82
boundArgs = call .getBoundArgsOrMinusOne ( )
65
83
}
66
84
0 commit comments