Skip to content

Commit 5dcc161

Browse files
authored
add getEnclosingPredicate utility predicate
1 parent fb50ba4 commit 5dcc161

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

ql/src/codeql_ql/ast/Ast.qll

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ class AstNode extends TAstNode {
5656
* Gets the primary QL class for the ast node.
5757
*/
5858
string getAPrimaryQlClass() { result = "???" }
59+
60+
/**
61+
* Gets the predicate that contains this AST node.
62+
*/
63+
pragma[noinline]
64+
Predicate getEnclosingPredicate() {
65+
not this instanceof Predicate and
66+
toGenerated(result) = toGenerated(this).getParent+()
67+
}
5968
}
6069

6170
/** A toplevel QL program, i.e. a file. */

0 commit comments

Comments
 (0)