From e09a01206483fb050c2d0a870e6cef149ea5e150 Mon Sep 17 00:00:00 2001 From: Taus Date: Thu, 27 May 2021 14:01:21 +0000 Subject: [PATCH 1/2] Support class unions --- ql/src/codeql_ql/ast/Ast.qll | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ql/src/codeql_ql/ast/Ast.qll b/ql/src/codeql_ql/ast/Ast.qll index 229bfa24c8b..78ad68225c3 100644 --- a/ql/src/codeql_ql/ast/Ast.qll +++ b/ql/src/codeql_ql/ast/Ast.qll @@ -218,6 +218,8 @@ class Type extends TType, AstNode { result.(InlineCast).getType() = this or result.(Class).getAliasType() = this + or + result.(Class).getUnionMember() = this } } @@ -328,6 +330,11 @@ class Class extends TClass, AstNode, ModuleMember { Type getAliasType() { toGenerated(result) = cls.getChild(_).(Generated::TypeAliasBody).getChild() } + + /** Gets the type of one of the members that this class is defined to be a union of. */ + Type getUnionMember() { + toGenerated(result) = cls.getChild(_).(Generated::TypeUnionBody).getChild(_) + } } /** From 2882f6d37cb59ea2644684f7164a3f604397a8d6 Mon Sep 17 00:00:00 2001 From: Taus Date: Thu, 27 May 2021 14:11:20 +0000 Subject: [PATCH 2/2] Link up `ModuleExpr` with `PredicateCall` --- ql/src/codeql_ql/ast/Ast.qll | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ql/src/codeql_ql/ast/Ast.qll b/ql/src/codeql_ql/ast/Ast.qll index 78ad68225c3..77a78695dd4 100644 --- a/ql/src/codeql_ql/ast/Ast.qll +++ b/ql/src/codeql_ql/ast/Ast.qll @@ -968,4 +968,11 @@ class ModuleExpr extends TModuleExpr, ModuleRef { final override FileOrModule getResolvedModule() { resolveModuleExpr(this, result) } final override string toString() { result = this.getName() } + + override string getAPrimaryQlClass() { result = "ModuleExpr" } + + override AstNode getParent() { + result = super.getParent() or + result.(PredicateCall).getQualifier() = this + } }