From 66faa153649b9d971efe7192c36f60fba2e22e2b Mon Sep 17 00:00:00 2001 From: Anders Schack-Mulligen Date: Mon, 31 Aug 2026 12:48:42 +0200 Subject: [PATCH] Unified: Add Callable type --- unified/extractor/ast_types.yml | 8 +++++++ .../ql/lib/codeql/unified/internal/Ast.qll | 22 +++++++++++++------ unified/ql/lib/unified.dbscheme | 2 ++ 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/unified/extractor/ast_types.yml b/unified/extractor/ast_types.yml index 854829a17cb4..1c98bdeefe61 100644 --- a/unified/extractor/ast_types.yml +++ b/unified/extractor/ast_types.yml @@ -73,6 +73,14 @@ supertypes: - while_stmt - do_while_stmt - labeled_stmt + callable: + - top_level + - function_expr + - function_declaration + - constructor_declaration + - destructor_declaration + - accessor_declaration + - initializer_declaration # A member is anything that can appear in the body of a class-like declaration member: - constructor_declaration diff --git a/unified/ql/lib/codeql/unified/internal/Ast.qll b/unified/ql/lib/codeql/unified/internal/Ast.qll index d5ffa0218523..eb02d0434837 100644 --- a/unified/ql/lib/codeql/unified/internal/Ast.qll +++ b/unified/ql/lib/codeql/unified/internal/Ast.qll @@ -96,7 +96,7 @@ module Unified { } /** A class representing `accessor_declaration` nodes. */ - class AccessorDeclaration extends @unified_accessor_declaration, F::Member, F::Stmt { + class AccessorDeclaration extends @unified_accessor_declaration, F::Callable, F::Member, F::Stmt { /** Gets the name of the primary QL class for this element. */ final override string getAPrimaryQlClass() { result = "AccessorDeclaration" } @@ -373,6 +373,8 @@ module Unified { } } + class Callable extends @unified_callable, F::AstNode { } + /** A class representing `catch_clause` nodes. */ class CatchClause extends @unified_catch_clause, F::AstNode { /** Gets the name of the primary QL class for this element. */ @@ -503,7 +505,9 @@ module Unified { } /** A class representing `constructor_declaration` nodes. */ - class ConstructorDeclaration extends @unified_constructor_declaration, F::Member, F::Stmt { + class ConstructorDeclaration extends @unified_constructor_declaration, F::Callable, F::Member, + F::Stmt + { /** Gets the name of the primary QL class for this element. */ final override string getAPrimaryQlClass() { result = "ConstructorDeclaration" } @@ -581,7 +585,9 @@ module Unified { } /** A class representing `destructor_declaration` nodes. */ - class DestructorDeclaration extends @unified_destructor_declaration, F::Member, F::Stmt { + class DestructorDeclaration extends @unified_destructor_declaration, F::Callable, F::Member, + F::Stmt + { /** Gets the name of the primary QL class for this element. */ final override string getAPrimaryQlClass() { result = "DestructorDeclaration" } @@ -718,7 +724,7 @@ module Unified { } /** A class representing `function_declaration` nodes. */ - class FunctionDeclaration extends @unified_function_declaration, F::Member, F::Stmt { + class FunctionDeclaration extends @unified_function_declaration, F::Callable, F::Member, F::Stmt { /** Gets the name of the primary QL class for this element. */ final override string getAPrimaryQlClass() { result = "FunctionDeclaration" } @@ -774,7 +780,7 @@ module Unified { } /** A class representing `function_expr` nodes. */ - class FunctionExpr extends @unified_function_expr, F::Expr { + class FunctionExpr extends @unified_function_expr, F::Callable, F::Expr { /** Gets the name of the primary QL class for this element. */ final override string getAPrimaryQlClass() { result = "FunctionExpr" } @@ -949,7 +955,7 @@ module Unified { } /** A class representing `initializer_declaration` nodes. */ - class InitializerDeclaration extends @unified_initializer_declaration, F::Member { + class InitializerDeclaration extends @unified_initializer_declaration, F::Callable, F::Member { /** Gets the name of the primary QL class for this element. */ final override string getAPrimaryQlClass() { result = "InitializerDeclaration" } @@ -1350,7 +1356,7 @@ module Unified { } /** A class representing `top_level` nodes. */ - class TopLevel extends @unified_top_level, F::AstNode { + class TopLevel extends @unified_top_level, F::Callable { /** Gets the name of the primary QL class for this element. */ final override string getAPrimaryQlClass() { result = "TopLevel" } @@ -2071,6 +2077,8 @@ module UnifiedFinal { final class CallExpr = F::CallExpr; + final class Callable = F::Callable; + final class CatchClause = F::CatchClause; final class ClassLikeDeclaration = F::ClassLikeDeclaration; diff --git a/unified/ql/lib/unified.dbscheme b/unified/ql/lib/unified.dbscheme index c36721515d5c..825d9fd0ff61 100644 --- a/unified/ql/lib/unified.dbscheme +++ b/unified/ql/lib/unified.dbscheme @@ -292,6 +292,8 @@ unified_call_expr_def( int callee: @unified_expr_or_type ref ); +@unified_callable = @unified_accessor_declaration | @unified_constructor_declaration | @unified_destructor_declaration | @unified_function_declaration | @unified_function_expr | @unified_initializer_declaration | @unified_top_level + #keyset[unified_catch_clause, index] unified_catch_clause_modifier( int unified_catch_clause: @unified_catch_clause ref,