Skip to content

Commit d8fb01b

Browse files
committed
Unified: Regenerate AST library, dbscheme and test outputs
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 4bbbc6c commit d8fb01b

9 files changed

Lines changed: 96 additions & 13 deletions

File tree

‎unified/extractor/tests/corpus/swift/functions/attributed-parameter-types.output‎

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,26 +186,53 @@ top_level source="⟨body⟩"
186186
parameter:
187187
parameter source="⟨external_name_node⟩⟨pattern⟩: ⟨type⟩"
188188
external_name_node: identifier "a" source="a"
189-
type: unsupported_node "inout D" source="inout D"
189+
type:
190+
modified_type_expr source="⟨modifier⟩ ⟨type⟩"
191+
modifier: modifier "inout" source="inout"
192+
type: identifier "D" source="D"
190193
pattern: identifier "a" source="a"
191194
parameter source="⟨external_name_node⟩⟨pattern⟩: ⟨type⟩"
192195
external_name_node: identifier "b" source="b"
193-
type: unsupported_node "sending T" source="sending T"
196+
type:
197+
modified_type_expr source="⟨modifier⟩ ⟨type⟩"
198+
modifier: modifier "sending" source="sending"
199+
type: identifier "T" source="T"
194200
pattern: identifier "b" source="b"
195201
parameter source="⟨external_name_node⟩⟨pattern⟩: ⟨type⟩"
196202
external_name_node: identifier "c" source="c"
197-
type: unsupported_node "borrowing T" source="borrowing T"
203+
type:
204+
modified_type_expr source="⟨modifier⟩ ⟨type⟩"
205+
modifier: modifier "borrowing" source="borrowing"
206+
type: identifier "T" source="T"
198207
pattern: identifier "c" source="c"
199208
parameter source="⟨external_name_node⟩⟨pattern⟩: ⟨type⟩"
200209
external_name_node: identifier "d" source="d"
201-
type: unsupported_node "consuming T" source="consuming T"
210+
type:
211+
modified_type_expr source="⟨modifier⟩ ⟨type⟩"
212+
modifier: modifier "consuming" source="consuming"
213+
type: identifier "T" source="T"
202214
pattern: identifier "d" source="d"
203215
parameter source="⟨external_name_node⟩⟨pattern⟩: ⟨type⟩"
204216
external_name_node: identifier "e" source="e"
205-
type: unsupported_node "@escaping (T) -> Void" source="@escaping (T) -> Void"
217+
type:
218+
modified_type_expr source="⟨modifier⟩ ⟨type⟩"
219+
modifier: modifier "@escaping" source="@escaping"
220+
type:
221+
function_expr source="(⟨parameter⟩) -> ⟨return_type⟩"
222+
parameter:
223+
parameter source="⟨type⟩"
224+
type: identifier "T" source="T"
225+
return_type: identifier "Void" source="Void"
206226
pattern: identifier "e" source="e"
207227
parameter source="⟨external_name_node⟩⟨pattern⟩: ⟨type⟩"
208228
external_name_node: identifier "g" source="g"
209-
type: unsupported_node "@Sendable @escaping () -> D" source="@Sendable @escaping () -> D"
229+
type:
230+
modified_type_expr source="⟨modifier⟩ ⟨modifier⟩ ⟨type⟩"
231+
modifier:
232+
modifier "@Sendable" source="@Sendable"
233+
modifier "@escaping" source="@escaping"
234+
type:
235+
function_expr source="() -> ⟨return_type⟩"
236+
return_type: identifier "D" source="D"
210237
pattern: identifier "g" source="g"
211238
body: block "{}" source="{}"

‎unified/extractor/tests/corpus/swift/functions/function-with-inout-parameter.output‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ top_level source="⟨body⟩"
6666
parameter:
6767
parameter source="⟨external_name_node⟩ ⟨pattern⟩: ⟨type⟩"
6868
external_name_node: identifier "_" source="_"
69-
type: unsupported_node "inout Int" source="inout Int"
69+
type:
70+
modified_type_expr source="⟨modifier⟩ ⟨type⟩"
71+
modifier: modifier "inout" source="inout"
72+
type: identifier "Int" source="Int"
7073
pattern: identifier "x" source="x"
7174
body:
7275
block source="{\n ⟨stmt⟩\n}"

‎unified/extractor/tests/corpus/swift/types/function-type-with-convention-attribute.output‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,12 @@ top_level source="⟨body⟩"
6565
variable_declaration source="⟨modifier⟩ ⟨pattern⟩: ⟨type⟩ = ⟨value⟩"
6666
modifier: modifier "let" source="let"
6767
pattern: identifier "callback" source="callback"
68-
type: unsupported_node "@convention(c) () -> Void" source="@convention(c) () -> Void"
68+
type:
69+
modified_type_expr source="⟨modifier⟩ ⟨type⟩"
70+
modifier: modifier "@convention(c)" source="@convention(c)"
71+
type:
72+
function_expr source="() -> ⟨return_type⟩"
73+
return_type: identifier "Void" source="Void"
6974
value:
7075
function_expr source="{}"
7176
body: block source=""

‎unified/extractor/tests/corpus/swift/types/function-type-with-inout-parameter.output‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ top_level source="⟨body⟩"
7070
function_expr source="(⟨parameter⟩) -> ⟨return_type⟩"
7171
parameter:
7272
parameter source="⟨type⟩"
73-
type: unsupported_node "inout Int" source="inout Int"
73+
type:
74+
modified_type_expr source="⟨modifier⟩ ⟨type⟩"
75+
modifier: modifier "inout" source="inout"
76+
type: identifier "Int" source="Int"
7477
return_type: identifier "Void" source="Void"
7578
value:
7679
function_expr source="{ ⟨parameter⟩ in }"

‎unified/extractor/tests/corpus/swift/types/function-type-with-sendable-attribute.output‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,12 @@ top_level source="⟨body⟩"
5858
variable_declaration source="⟨modifier⟩ ⟨pattern⟩: ⟨type⟩ = ⟨value⟩"
5959
modifier: modifier "let" source="let"
6060
pattern: identifier "handler" source="handler"
61-
type: unsupported_node "@Sendable () -> Void" source="@Sendable () -> Void"
61+
type:
62+
modified_type_expr source="⟨modifier⟩ ⟨type⟩"
63+
modifier: modifier "@Sendable" source="@Sendable"
64+
type:
65+
function_expr source="() -> ⟨return_type⟩"
66+
return_type: identifier "Void" source="Void"
6267
value:
6368
function_expr source="{}"
6469
body: block source=""

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,27 @@ module Unified {
10411041
}
10421042
}
10431043

1044+
/** A class representing `modified_type_expr` nodes. */
1045+
class ModifiedTypeExpr extends @unified_modified_type_expr, F::Expr {
1046+
/** Gets the name of the primary QL class for this element. */
1047+
final override string getAPrimaryQlClass() { result = "ModifiedTypeExpr" }
1048+
1049+
/** Gets the node corresponding to the field `modifier`. */
1050+
final F::Modifier getModifier(int i) { unified_modified_type_expr_modifier(this, i, result) }
1051+
1052+
/** Gets the node corresponding to the field `modifier`. */
1053+
final F::Modifier getAModifier() { result = this.getModifier(_) }
1054+
1055+
/** Gets the node corresponding to the field `type`. */
1056+
final F::Expr getType() { unified_modified_type_expr_def(this, result) }
1057+
1058+
/** Gets a field or child node of this node. */
1059+
final override F::AstNode getAFieldOrChild() {
1060+
unified_modified_type_expr_modifier(this, _, result) or
1061+
unified_modified_type_expr_def(this, result)
1062+
}
1063+
}
1064+
10441065
/** A class representing `modifier` tokens. */
10451066
class Modifier extends @unified_token_modifier, F::AstNode, F::Token {
10461067
/** Gets the name of the primary QL class for this element. */
@@ -1781,6 +1802,10 @@ module Unified {
17811802
or
17821803
result = node.(MemberAccessExpr).getMemberNameNode() and i = -1 and name = "getMemberNameNode"
17831804
or
1805+
result = node.(ModifiedTypeExpr).getModifier(i) and name = "getModifier"
1806+
or
1807+
result = node.(ModifiedTypeExpr).getType() and i = -1 and name = "getType"
1808+
or
17841809
result = node.(NamedPattern).getModifier(i) and name = "getModifier"
17851810
or
17861811
result = node.(NamedPattern).getNameNode() and i = -1 and name = "getNameNode"
@@ -2004,6 +2029,8 @@ module UnifiedFinal {
20042029

20052030
final class MemberAccessExpr = F::MemberAccessExpr;
20062031

2032+
final class ModifiedTypeExpr = F::ModifiedTypeExpr;
2033+
20072034
final class Modifier = F::Modifier;
20082035

20092036
final class NamedPattern = F::NamedPattern;

‎unified/ql/lib/unified.dbscheme‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ unified_equality_type_constraint_def(
440440
int right: @unified_expr ref
441441
);
442442

443-
@unified_expr = @unified_array_literal | @unified_binary_expr | @unified_block | @unified_break_expr | @unified_bulk_importing_pattern | @unified_call_expr | @unified_conditional_pattern | @unified_continue_expr | @unified_expr_pattern | @unified_function_expr | @unified_generic_type_expr | @unified_if_expr | @unified_key_value_pair | @unified_macro_call_expr | @unified_map_literal | @unified_member_access_expr | @unified_named_pattern | @unified_or_pattern | @unified_pattern_guard_expr | @unified_return_expr | @unified_string_interpolation_expr | @unified_switch_expr | @unified_throw_expr | @unified_token_boolean_literal | @unified_token_builtin_expr | @unified_token_empty_expr | @unified_token_float_literal | @unified_token_identifier | @unified_token_ignore_pattern | @unified_token_inferred_type_expr | @unified_token_int_literal | @unified_token_regex_literal | @unified_token_string_literal | @unified_token_super_expr | @unified_token_unhandled_node | @unified_token_unsupported_node | @unified_try_expr | @unified_tuple_expr | @unified_type_cast_expr | @unified_type_test_expr | @unified_unary_expr | @unified_unresolved_operator_sequence
443+
@unified_expr = @unified_array_literal | @unified_binary_expr | @unified_block | @unified_break_expr | @unified_bulk_importing_pattern | @unified_call_expr | @unified_conditional_pattern | @unified_continue_expr | @unified_expr_pattern | @unified_function_expr | @unified_generic_type_expr | @unified_if_expr | @unified_key_value_pair | @unified_macro_call_expr | @unified_map_literal | @unified_member_access_expr | @unified_modified_type_expr | @unified_named_pattern | @unified_or_pattern | @unified_pattern_guard_expr | @unified_return_expr | @unified_string_interpolation_expr | @unified_switch_expr | @unified_throw_expr | @unified_token_boolean_literal | @unified_token_builtin_expr | @unified_token_empty_expr | @unified_token_float_literal | @unified_token_identifier | @unified_token_ignore_pattern | @unified_token_inferred_type_expr | @unified_token_int_literal | @unified_token_regex_literal | @unified_token_string_literal | @unified_token_super_expr | @unified_token_unhandled_node | @unified_token_unsupported_node | @unified_try_expr | @unified_tuple_expr | @unified_type_cast_expr | @unified_type_test_expr | @unified_unary_expr | @unified_unresolved_operator_sequence
444444

445445
@unified_expr_or_operator = @unified_expr | @unified_token_infix_operator
446446

@@ -669,6 +669,18 @@ unified_member_access_expr_def(
669669
int member_name_node: @unified_token_identifier ref
670670
);
671671

672+
#keyset[unified_modified_type_expr, index]
673+
unified_modified_type_expr_modifier(
674+
int unified_modified_type_expr: @unified_modified_type_expr ref,
675+
int index: int ref,
676+
unique int modifier: @unified_token_modifier ref
677+
);
678+
679+
unified_modified_type_expr_def(
680+
unique int id: @unified_modified_type_expr,
681+
int type__: @unified_expr ref
682+
);
683+
672684
#keyset[unified_named_pattern, index]
673685
unified_named_pattern_modifier(
674686
int unified_named_pattern: @unified_named_pattern ref,
@@ -1025,7 +1037,7 @@ unified_trivia_tokeninfo(
10251037
string value: string ref
10261038
);
10271039

1028-
@unified_ast_node = @unified_accessor_declaration | @unified_argument | @unified_array_literal | @unified_associated_type_declaration | @unified_base_type | @unified_binary_expr | @unified_block | @unified_bound_type_constraint | @unified_break_expr | @unified_bulk_importing_pattern | @unified_call_expr | @unified_catch_clause | @unified_class_like_declaration | @unified_conditional_pattern | @unified_constructor_declaration | @unified_continue_expr | @unified_defer_stmt | @unified_destructor_declaration | @unified_do_while_stmt | @unified_equality_type_constraint | @unified_expr_pattern | @unified_for_each_stmt | @unified_function_declaration | @unified_function_expr | @unified_generic_type_expr | @unified_guard_if_stmt | @unified_if_expr | @unified_import_declaration | @unified_initializer_declaration | @unified_key_value_pair | @unified_labeled_stmt | @unified_macro_call_expr | @unified_map_literal | @unified_member_access_expr | @unified_named_pattern | @unified_operator_syntax_declaration | @unified_or_pattern | @unified_parameter | @unified_pattern_guard_expr | @unified_return_expr | @unified_string_interpolation_expr | @unified_switch_case | @unified_switch_expr | @unified_throw_expr | @unified_token | @unified_top_level | @unified_trivia_token | @unified_try_expr | @unified_tuple_expr | @unified_type_alias_declaration | @unified_type_cast_expr | @unified_type_parameter | @unified_type_test_expr | @unified_unary_expr | @unified_unresolved_operator_sequence | @unified_variable_declaration | @unified_while_stmt
1040+
@unified_ast_node = @unified_accessor_declaration | @unified_argument | @unified_array_literal | @unified_associated_type_declaration | @unified_base_type | @unified_binary_expr | @unified_block | @unified_bound_type_constraint | @unified_break_expr | @unified_bulk_importing_pattern | @unified_call_expr | @unified_catch_clause | @unified_class_like_declaration | @unified_conditional_pattern | @unified_constructor_declaration | @unified_continue_expr | @unified_defer_stmt | @unified_destructor_declaration | @unified_do_while_stmt | @unified_equality_type_constraint | @unified_expr_pattern | @unified_for_each_stmt | @unified_function_declaration | @unified_function_expr | @unified_generic_type_expr | @unified_guard_if_stmt | @unified_if_expr | @unified_import_declaration | @unified_initializer_declaration | @unified_key_value_pair | @unified_labeled_stmt | @unified_macro_call_expr | @unified_map_literal | @unified_member_access_expr | @unified_modified_type_expr | @unified_named_pattern | @unified_operator_syntax_declaration | @unified_or_pattern | @unified_parameter | @unified_pattern_guard_expr | @unified_return_expr | @unified_string_interpolation_expr | @unified_switch_case | @unified_switch_expr | @unified_throw_expr | @unified_token | @unified_top_level | @unified_trivia_token | @unified_try_expr | @unified_tuple_expr | @unified_type_alias_declaration | @unified_type_cast_expr | @unified_type_parameter | @unified_type_test_expr | @unified_unary_expr | @unified_unresolved_operator_sequence | @unified_variable_declaration | @unified_while_stmt
10291041

10301042
unified_ast_node_location(
10311043
unique int node: @unified_ast_node ref,

‎unified/ql/test/library-tests/controlflow/cfg.expected‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ noCfg
157157
| cfg.swift:468:6:468:17 | testIfConfig |
158158
| cfg.swift:497:6:497:18 | testAvailable |
159159
| cfg.swift:524:6:524:17 | testAsyncFor |
160+
| cfg.swift:555:49:555:51 | Int |
160161
| cfg.swift:559:6:559:20 | autoclosureTest |
161162
nonSimple
162163
| cfg.swift:12:17:12:25 | withParam | 'withParam -? Block' |

‎unified/ql/test/library-tests/controlflow/cfg.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ func testNilCoalescing2(x: Bool?) -> Int {
552552
}
553553
}
554554

555-
func usesAutoclosure(_ expr: @autoclosure () -> Int) -> Int {
555+
func usesAutoclosure(_ expr: @autoclosure () -> Int) -> Int { // $ noCfg
556556
return expr()
557557
}
558558

0 commit comments

Comments
 (0)