Skip to content

Commit a61d42e

Browse files
committed
JS: Make inline CG tests report call target if NONE was given
Previously it would only report a spurious callee if the target function was named. Now, if specifying 'calls:NONE' if will report any callee as spurious.
1 parent 98c755d commit a61d42e

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

javascript/ql/test/library-tests/CallGraphs/AnnotatedTest/Test.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
spuriousCallee
2+
| accessors.js:54:1:54:7 | new D() | accessors.js:32:9:32:8 | () {} | -1 | calls |
23
missingCallee
34
| constructor-field.ts:40:5:40:14 | f3.build() | constructor-field.ts:13:3:13:12 | build() {} | -1 | calls |
45
| constructor-field.ts:71:1:71:11 | bf3.build() | constructor-field.ts:13:3:13:12 | build() {} | -1 | calls |

javascript/ql/test/library-tests/CallGraphs/AnnotatedTest/Test.ql

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,23 @@ class AnnotatedCall extends DataFlow::Node {
5858
string getKind() { result = kind }
5959
}
6060

61-
predicate callEdge(AnnotatedCall call, AnnotatedFunction target, int boundArgs) {
61+
predicate callEdge(AnnotatedCall call, Function target, int boundArgs) {
6262
FlowSteps::calls(call, target) and boundArgs = -1
6363
or
6464
FlowSteps::callsBound(call, target, boundArgs)
6565
}
6666

67-
query predicate spuriousCallee(
68-
AnnotatedCall call, AnnotatedFunction target, int boundArgs, string kind
69-
) {
67+
query predicate spuriousCallee(AnnotatedCall call, Function target, int boundArgs, string kind) {
7068
callEdge(call, target, boundArgs) and
7169
kind = call.getKind() and
7270
not (
7371
target = call.getAnExpectedCallee(kind) and
7472
boundArgs = call.getBoundArgsOrMinusOne()
73+
) and
74+
(
75+
target instanceof AnnotatedFunction
76+
or
77+
call.getCallTargetName() = "NONE"
7578
)
7679
}
7780

0 commit comments

Comments
 (0)