QL: fix getEnclosingModule, which broke the callgraph

This commit is contained in:
Erik Krogh Kristensen
2021-10-15 19:48:28 +02:00
parent c7aa89b1d8
commit 1239b1aee1
2 changed files with 6 additions and 10 deletions

View File

@@ -154,18 +154,13 @@ private predicate resolveSelectionName(Import imp, ContainerOrModule m, int i) {
cached
private module Cached {
private Module getEnclosingModule0(AstNode n) {
not n instanceof Module and
(
n = result.getAChild(_)
or
exists(AstNode prev |
result = getEnclosingModule0(prev) and
n = prev.getAChild(_)
)
)
private AstNode parent(AstNode n) {
result = n.getParent() and
not n instanceof Module
}
private Module getEnclosingModule0(AstNode n) { result = parent*(n.getParent()) }
cached
ContainerOrModule getEnclosingModule(AstNode n) {
result = TModule(getEnclosingModule0(n))

View File

@@ -1,4 +1,5 @@
getTarget
| Bar.qll:5:38:5:47 | PredicateCall | Bar.qll:8:3:8:31 | ClasslessPredicate snapshot |
| Foo.qll:5:26:5:30 | PredicateCall | Foo.qll:3:1:3:26 | ClasslessPredicate foo |
| Foo.qll:10:21:10:25 | PredicateCall | Foo.qll:8:3:8:28 | ClassPredicate bar |
| Foo.qll:14:30:14:40 | MemberCall | Foo.qll:10:3:10:27 | ClassPredicate baz |