Skip to content

Commit 1239b1a

Browse files
committed
QL: fix getEnclosingModule, which broke the callgraph
1 parent c7aa89b commit 1239b1a

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

ql/src/codeql_ql/ast/internal/Module.qll

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -154,18 +154,13 @@ private predicate resolveSelectionName(Import imp, ContainerOrModule m, int i) {
154154

155155
cached
156156
private module Cached {
157-
private Module getEnclosingModule0(AstNode n) {
158-
not n instanceof Module and
159-
(
160-
n = result.getAChild(_)
161-
or
162-
exists(AstNode prev |
163-
result = getEnclosingModule0(prev) and
164-
n = prev.getAChild(_)
165-
)
166-
)
157+
private AstNode parent(AstNode n) {
158+
result = n.getParent() and
159+
not n instanceof Module
167160
}
168161

162+
private Module getEnclosingModule0(AstNode n) { result = parent*(n.getParent()) }
163+
169164
cached
170165
ContainerOrModule getEnclosingModule(AstNode n) {
171166
result = TModule(getEnclosingModule0(n))

ql/test/callgraph/callgraph.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
getTarget
2+
| Bar.qll:5:38:5:47 | PredicateCall | Bar.qll:8:3:8:31 | ClasslessPredicate snapshot |
23
| Foo.qll:5:26:5:30 | PredicateCall | Foo.qll:3:1:3:26 | ClasslessPredicate foo |
34
| Foo.qll:10:21:10:25 | PredicateCall | Foo.qll:8:3:8:28 | ClassPredicate bar |
45
| Foo.qll:14:30:14:40 | MemberCall | Foo.qll:10:3:10:27 | ClassPredicate baz |

0 commit comments

Comments
 (0)