From 94dbf2b7b49f378f2b9c0976c296f6362170b55e Mon Sep 17 00:00:00 2001 From: Anders Schack-Mulligen Date: Wed, 13 Oct 2021 12:48:38 +0000 Subject: [PATCH] Expose transitive closure syntax. --- ql/src/codeql_ql/ast/Ast.qll | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ql/src/codeql_ql/ast/Ast.qll b/ql/src/codeql_ql/ast/Ast.qll index 13f2bead10e..76961793738 100644 --- a/ql/src/codeql_ql/ast/Ast.qll +++ b/ql/src/codeql_ql/ast/Ast.qll @@ -783,6 +783,9 @@ class Call extends TCall, Expr, Formula { final int getNumberOfArguments() { result = count(this.getArgument(_)) } + /** Holds if this call is a transitive closure of `kind` either `+` or `*`. */ + predicate isClosure(string kind) { none() } + /** * Gets the module that contains the predicate. * E.g. for `Foo::bar()` the result is `Foo`. @@ -814,6 +817,10 @@ class PredicateCall extends TPredicateCall, Call { override string getAPrimaryQlClass() { result = "PredicateCall" } + override predicate isClosure(string kind) { + kind = expr.getChild(_).(Generated::Closure).getValue() + } + /** * Gets the name of the predicate called. * E.g. for `foo()` the result is "foo". @@ -850,6 +857,10 @@ class MemberCall extends TMemberCall, Call { result = expr.getChild(_).(Generated::QualifiedRhs).getName().getValue() } + override predicate isClosure(string kind) { + kind = expr.getChild(_).(Generated::QualifiedRhs).getChild(_).(Generated::Closure).getValue() + } + /** * Gets the supertype referenced in this call, that is the `Foo` in `Foo.super.bar(...)`. *