Skip to content

Commit 66faa15

Browse files
committed
Unified: Add Callable type
1 parent f70e0b5 commit 66faa15

3 files changed

Lines changed: 25 additions & 7 deletions

File tree

unified/extractor/ast_types.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ supertypes:
7373
- while_stmt
7474
- do_while_stmt
7575
- labeled_stmt
76+
callable:
77+
- top_level
78+
- function_expr
79+
- function_declaration
80+
- constructor_declaration
81+
- destructor_declaration
82+
- accessor_declaration
83+
- initializer_declaration
7684
# A member is anything that can appear in the body of a class-like declaration
7785
member:
7886
- constructor_declaration

unified/ql/lib/codeql/unified/internal/Ast.qll

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ module Unified {
9696
}
9797

9898
/** A class representing `accessor_declaration` nodes. */
99-
class AccessorDeclaration extends @unified_accessor_declaration, F::Member, F::Stmt {
99+
class AccessorDeclaration extends @unified_accessor_declaration, F::Callable, F::Member, F::Stmt {
100100
/** Gets the name of the primary QL class for this element. */
101101
final override string getAPrimaryQlClass() { result = "AccessorDeclaration" }
102102

@@ -373,6 +373,8 @@ module Unified {
373373
}
374374
}
375375

376+
class Callable extends @unified_callable, F::AstNode { }
377+
376378
/** A class representing `catch_clause` nodes. */
377379
class CatchClause extends @unified_catch_clause, F::AstNode {
378380
/** Gets the name of the primary QL class for this element. */
@@ -503,7 +505,9 @@ module Unified {
503505
}
504506

505507
/** A class representing `constructor_declaration` nodes. */
506-
class ConstructorDeclaration extends @unified_constructor_declaration, F::Member, F::Stmt {
508+
class ConstructorDeclaration extends @unified_constructor_declaration, F::Callable, F::Member,
509+
F::Stmt
510+
{
507511
/** Gets the name of the primary QL class for this element. */
508512
final override string getAPrimaryQlClass() { result = "ConstructorDeclaration" }
509513

@@ -581,7 +585,9 @@ module Unified {
581585
}
582586

583587
/** A class representing `destructor_declaration` nodes. */
584-
class DestructorDeclaration extends @unified_destructor_declaration, F::Member, F::Stmt {
588+
class DestructorDeclaration extends @unified_destructor_declaration, F::Callable, F::Member,
589+
F::Stmt
590+
{
585591
/** Gets the name of the primary QL class for this element. */
586592
final override string getAPrimaryQlClass() { result = "DestructorDeclaration" }
587593

@@ -718,7 +724,7 @@ module Unified {
718724
}
719725

720726
/** A class representing `function_declaration` nodes. */
721-
class FunctionDeclaration extends @unified_function_declaration, F::Member, F::Stmt {
727+
class FunctionDeclaration extends @unified_function_declaration, F::Callable, F::Member, F::Stmt {
722728
/** Gets the name of the primary QL class for this element. */
723729
final override string getAPrimaryQlClass() { result = "FunctionDeclaration" }
724730

@@ -774,7 +780,7 @@ module Unified {
774780
}
775781

776782
/** A class representing `function_expr` nodes. */
777-
class FunctionExpr extends @unified_function_expr, F::Expr {
783+
class FunctionExpr extends @unified_function_expr, F::Callable, F::Expr {
778784
/** Gets the name of the primary QL class for this element. */
779785
final override string getAPrimaryQlClass() { result = "FunctionExpr" }
780786

@@ -949,7 +955,7 @@ module Unified {
949955
}
950956

951957
/** A class representing `initializer_declaration` nodes. */
952-
class InitializerDeclaration extends @unified_initializer_declaration, F::Member {
958+
class InitializerDeclaration extends @unified_initializer_declaration, F::Callable, F::Member {
953959
/** Gets the name of the primary QL class for this element. */
954960
final override string getAPrimaryQlClass() { result = "InitializerDeclaration" }
955961

@@ -1350,7 +1356,7 @@ module Unified {
13501356
}
13511357

13521358
/** A class representing `top_level` nodes. */
1353-
class TopLevel extends @unified_top_level, F::AstNode {
1359+
class TopLevel extends @unified_top_level, F::Callable {
13541360
/** Gets the name of the primary QL class for this element. */
13551361
final override string getAPrimaryQlClass() { result = "TopLevel" }
13561362

@@ -2071,6 +2077,8 @@ module UnifiedFinal {
20712077

20722078
final class CallExpr = F::CallExpr;
20732079

2080+
final class Callable = F::Callable;
2081+
20742082
final class CatchClause = F::CatchClause;
20752083

20762084
final class ClassLikeDeclaration = F::ClassLikeDeclaration;

unified/ql/lib/unified.dbscheme

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,8 @@ unified_call_expr_def(
292292
int callee: @unified_expr_or_type ref
293293
);
294294

295+
@unified_callable = @unified_accessor_declaration | @unified_constructor_declaration | @unified_destructor_declaration | @unified_function_declaration | @unified_function_expr | @unified_initializer_declaration | @unified_top_level
296+
295297
#keyset[unified_catch_clause, index]
296298
unified_catch_clause_modifier(
297299
int unified_catch_clause: @unified_catch_clause ref,

0 commit comments

Comments
 (0)