Skip to content

Commit 9f8d10d

Browse files
authored
Merge pull request github#11851 from erik-krogh/jsFixMissingThis
JS: fix bad join-order in js/missing-this-qualifier
2 parents 1a4048d + 785c21f commit 9f8d10d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

javascript/ql/src/Declarations/MissingThisQualifier.ql

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,17 @@ predicate maybeMissingThis(CallExpr call, MethodDeclaration intendedTarget, Glob
2020
call.getCallee() = gv.getAnAccess() and
2121
call.getCalleeName() = intendedTarget.getName() and
2222
exists(MethodDefinition caller |
23-
caller.getBody() = call.getContainer() and
23+
caller.getBody() = getRelevantCallExprContainer(call) and
2424
intendedTarget.getDeclaringClass() = caller.getDeclaringClass()
2525
)
2626
}
2727

28+
pragma[noinline]
29+
private StmtContainer getRelevantCallExprContainer(CallExpr c) {
30+
result = c.getContainer() and
31+
c.getCallee() = any(GlobalVariable v).getAnAccess()
32+
}
33+
2834
from CallExpr call, MethodDeclaration intendedTarget, GlobalVariable gv
2935
where
3036
maybeMissingThis(call, intendedTarget, gv) and
@@ -46,7 +52,7 @@ where
4652
exists(Variable decl |
4753
decl.getName() = gv.getName() and
4854
decl.isNamespaceExport() and
49-
call.getContainer().getEnclosingContainer*() instanceof NamespaceDeclaration
55+
getRelevantCallExprContainer(call).getEnclosingContainer*() instanceof NamespaceDeclaration
5056
)
5157
or
5258
// call to global function with additional arguments

0 commit comments

Comments
 (0)