Skip to content

Commit 38d65d3

Browse files
committed
Swift: make ConstructorDecl's name include params
In order to distinguish overloads of the constructor and for consistency with other function calls, `ConstructorDecl` string representation uses the name which includes parentheses and parameter labels. For consistency also the destructor got the same change, which means all `DestructorDecl`s will now show as `deinit()` rather than `deinit`.
1 parent f5471e4 commit 38d65d3

File tree

21 files changed

+335
-337
lines changed

21 files changed

+335
-337
lines changed
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1+
// generated by codegen/codegen.py, remove this comment if you wish to edit this file
12
private import codeql.swift.generated.decl.ConstructorDecl
23

3-
class ConstructorDecl extends ConstructorDeclBase {
4-
override string toString() { result = "init" }
5-
}
4+
class ConstructorDecl extends ConstructorDeclBase { }
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1+
// generated by codegen/codegen.py, remove this comment if you wish to edit this file
12
private import codeql.swift.generated.decl.DestructorDecl
23

3-
class DestructorDecl extends DestructorDeclBase {
4-
override string toString() { result = "deinit" }
5-
}
4+
class DestructorDecl extends DestructorDeclBase { }

swift/ql/test/extractor-tests/declarations/all.expected

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
| declarations.swift:1:1:7:1 | Foo |
2-
| declarations.swift:1:8:1:8 | init |
3-
| declarations.swift:1:8:1:8 | init |
2+
| declarations.swift:1:8:1:8 | init() |
3+
| declarations.swift:1:8:1:8 | init(x:) |
44
| declarations.swift:1:8:1:8 | self |
55
| declarations.swift:1:8:1:8 | self |
66
| declarations.swift:1:8:1:8 | x |
@@ -23,8 +23,8 @@
2323
| declarations.swift:5:5:5:38 | set |
2424
| declarations.swift:5:9:5:9 | newValue |
2525
| declarations.swift:9:1:9:34 | Bar |
26-
| declarations.swift:9:7:9:7 | deinit |
27-
| declarations.swift:9:7:9:7 | init |
26+
| declarations.swift:9:7:9:7 | deinit() |
27+
| declarations.swift:9:7:9:7 | init() |
2828
| declarations.swift:9:7:9:7 | self |
2929
| declarations.swift:9:7:9:7 | self |
3030
| declarations.swift:9:13:9:30 | var ... = ... |
@@ -95,9 +95,9 @@
9595
| declarations.swift:41:7:41:7 | set |
9696
| declarations.swift:41:7:41:7 | value |
9797
| declarations.swift:42:3:42:3 | self |
98-
| declarations.swift:42:3:44:3 | init |
98+
| declarations.swift:42:3:44:3 | init() |
9999
| declarations.swift:46:3:46:3 | self |
100-
| declarations.swift:46:3:48:3 | deinit |
100+
| declarations.swift:46:3:48:3 | deinit() |
101101
| declarations.swift:50:3:52:3 | +-(_:) |
102102
| declarations.swift:50:22:50:22 | self |
103103
| declarations.swift:50:26:50:33 | other |
@@ -106,7 +106,7 @@
106106
| declarations.swift:64:7:64:16 | +++ |
107107
| declarations.swift:66:7:66:21 | *** |
108108
| declarations.swift:68:18:74:1 | ZeroWrapper |
109-
| declarations.swift:68:25:68:25 | init |
109+
| declarations.swift:68:25:68:25 | init() |
110110
| declarations.swift:68:25:68:25 | self |
111111
| declarations.swift:69:3:73:3 | var ... = ... |
112112
| declarations.swift:69:7:69:7 | wrappedValue |
@@ -123,7 +123,7 @@
123123
| declarations.swift:81:8:81:8 | hasDidSet2 |
124124
| declarations.swift:81:8:81:8 | hasWillSet1 |
125125
| declarations.swift:81:8:81:8 | hasWillSet2 |
126-
| declarations.swift:81:8:81:8 | init |
126+
| declarations.swift:81:8:81:8 | init(normalField:hasWillSet1:hasWillSet2:hasDidSet1:hasDidSet2:hasBoth:) |
127127
| declarations.swift:81:8:81:8 | normalField |
128128
| declarations.swift:81:8:81:8 | self |
129129
| declarations.swift:82:3:87:3 | var ... = ... |

swift/ql/test/extractor-tests/expressions/all.expected

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@
4444
| expressions.swift:21:6:21:16 | call to failure(_:) | CallExpr |
4545
| expressions.swift:21:14:21:14 | 11 | IntegerLiteralExpr |
4646
| expressions.swift:27:13:27:13 | Klass.Type | TypeExpr |
47-
| expressions.swift:27:13:27:13 | call to init | ConstructorRefCallExpr |
48-
| expressions.swift:27:13:27:13 | init | DeclRefExpr |
49-
| expressions.swift:27:13:27:19 | call to init | CallExpr |
47+
| expressions.swift:27:13:27:13 | call to init() | ConstructorRefCallExpr |
48+
| expressions.swift:27:13:27:13 | init() | DeclRefExpr |
49+
| expressions.swift:27:13:27:19 | call to init() | CallExpr |
5050
| expressions.swift:29:9:29:19 | [...] | DictionaryExpr |
5151
| expressions.swift:29:10:29:10 | 1 | StringLiteralExpr |
5252
| expressions.swift:29:10:29:16 | (...) | TupleExpr |
@@ -159,12 +159,12 @@
159159
| expressions.swift:79:5:79:11 | call to ... | DotSyntaxCallExpr |
160160
| expressions.swift:79:5:79:21 | call to ... | CallExpr |
161161
| expressions.swift:79:5:79:21 | self = ... | RebindSelfInConstructorExpr |
162-
| expressions.swift:79:11:79:11 | init | OtherConstructorDeclRefExpr |
162+
| expressions.swift:79:11:79:11 | init(x:) | OtherConstructorDeclRefExpr |
163163
| expressions.swift:79:19:79:19 | 22 | IntegerLiteralExpr |
164164
| expressions.swift:83:15:83:15 | Derived.Type | TypeExpr |
165-
| expressions.swift:83:15:83:15 | call to init | ConstructorRefCallExpr |
166-
| expressions.swift:83:15:83:15 | init | DeclRefExpr |
167-
| expressions.swift:83:15:83:23 | call to init | CallExpr |
165+
| expressions.swift:83:15:83:15 | call to init() | ConstructorRefCallExpr |
166+
| expressions.swift:83:15:83:15 | init() | DeclRefExpr |
167+
| expressions.swift:83:15:83:23 | call to init() | CallExpr |
168168
| expressions.swift:84:1:84:1 | _ | DiscardAssignmentExpr |
169169
| expressions.swift:84:1:84:13 | ... = ... | AssignExpr |
170170
| expressions.swift:84:5:84:5 | (Base) ... | DerivedToBaseExpr |
@@ -183,9 +183,9 @@
183183
| expressions.swift:92:14:92:55 | call to toOpaque() | CallExpr |
184184
| expressions.swift:92:24:92:24 | passRetained(_:) | DeclRefExpr |
185185
| expressions.swift:92:37:92:37 | ToPtr.Type | TypeExpr |
186-
| expressions.swift:92:37:92:37 | call to init | ConstructorRefCallExpr |
187-
| expressions.swift:92:37:92:37 | init | DeclRefExpr |
188-
| expressions.swift:92:37:92:43 | call to init | CallExpr |
186+
| expressions.swift:92:37:92:37 | call to init() | ConstructorRefCallExpr |
187+
| expressions.swift:92:37:92:37 | init() | DeclRefExpr |
188+
| expressions.swift:92:37:92:43 | call to init() | CallExpr |
189189
| expressions.swift:92:46:92:46 | toOpaque() | DeclRefExpr |
190190
| expressions.swift:93:1:93:16 | Unmanaged<ToPtr>.Type | TypeExpr |
191191
| expressions.swift:93:1:93:18 | .fromOpaque(_:) | MethodRefExpr |

swift/ql/test/extractor-tests/expressions/semantics.expected

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
| expressions.swift:16:19:16:19 | failed | OrdinarySemantics |
99
| expressions.swift:20:6:20:6 | failure(_:) | OrdinarySemantics |
1010
| expressions.swift:21:6:21:6 | failure(_:) | OrdinarySemantics |
11-
| expressions.swift:27:13:27:13 | init | OrdinarySemantics |
11+
| expressions.swift:27:13:27:13 | init() | OrdinarySemantics |
1212
| expressions.swift:35:1:35:1 | print(_:separator:terminator:) | OrdinarySemantics |
1313
| expressions.swift:35:7:35:7 | d | OrdinarySemantics |
1414
| expressions.swift:35:7:35:12 | ...[...] | OrdinarySemantics |
@@ -41,14 +41,14 @@
4141
| expressions.swift:73:5:73:5 | self | OrdinarySemantics |
4242
| expressions.swift:73:10:73:10 | x | OrdinarySemantics |
4343
| expressions.swift:77:7:77:7 | _unimplementedInitializer(className:initName:file:line:column:) | OrdinarySemantics |
44-
| expressions.swift:83:15:83:15 | init | OrdinarySemantics |
44+
| expressions.swift:83:15:83:15 | init() | OrdinarySemantics |
4545
| expressions.swift:84:5:84:5 | derived | OrdinarySemantics |
4646
| expressions.swift:84:5:84:13 | .xx | OrdinarySemantics |
4747
| expressions.swift:87:1:87:1 | opt | OrdinarySemantics |
4848
| expressions.swift:88:1:88:1 | d | OrdinarySemantics |
4949
| expressions.swift:88:1:88:6 | ...[...] | OrdinarySemantics |
5050
| expressions.swift:92:24:92:24 | passRetained(_:) | OrdinarySemantics |
51-
| expressions.swift:92:37:92:37 | init | OrdinarySemantics |
51+
| expressions.swift:92:37:92:37 | init() | OrdinarySemantics |
5252
| expressions.swift:92:46:92:46 | toOpaque() | OrdinarySemantics |
5353
| expressions.swift:93:18:93:18 | fromOpaque(_:) | OrdinarySemantics |
5454
| expressions.swift:93:29:93:29 | opaque | OrdinarySemantics |
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
| class.swift:1:1:7:1 | Foo | 0 | class.swift:2:5:2:16 | var ... = ... |
22
| class.swift:1:1:7:1 | Foo | 1 | class.swift:2:9:2:9 | field |
3-
| class.swift:1:1:7:1 | Foo | 2 | class.swift:4:5:6:5 | init |
4-
| class.swift:1:1:7:1 | Foo | 3 | class.swift:1:7:1:7 | deinit |
3+
| class.swift:1:1:7:1 | Foo | 2 | class.swift:4:5:6:5 | init() |
4+
| class.swift:1:1:7:1 | Foo | 3 | class.swift:1:7:1:7 | deinit() |
55
| class.swift:11:1:14:1 | Generic | 0 | class.swift:12:5:12:13 | var ... = ... |
66
| class.swift:11:1:14:1 | Generic | 1 | class.swift:12:9:12:9 | x |
77
| class.swift:11:1:14:1 | Generic | 2 | class.swift:13:5:13:13 | var ... = ... |
88
| class.swift:11:1:14:1 | Generic | 3 | class.swift:13:9:13:9 | y |
9-
| class.swift:11:1:14:1 | Generic | 4 | class.swift:11:7:11:7 | deinit |
10-
| class.swift:11:1:14:1 | Generic | 5 | class.swift:11:7:11:7 | init |
11-
| class.swift:16:1:17:1 | Baz | 0 | class.swift:16:21:16:21 | init |
12-
| class.swift:16:1:17:1 | Baz | 1 | class.swift:16:7:16:7 | deinit |
9+
| class.swift:11:1:14:1 | Generic | 4 | class.swift:11:7:11:7 | deinit() |
10+
| class.swift:11:1:14:1 | Generic | 5 | class.swift:11:7:11:7 | init() |
11+
| class.swift:16:1:17:1 | Baz | 0 | class.swift:16:21:16:21 | init() |
12+
| class.swift:16:1:17:1 | Baz | 1 | class.swift:16:7:16:7 | deinit() |

swift/ql/test/extractor-tests/generated/decl/EnumDecl/EnumDecl_getMember.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
| enums.swift:7:1:10:1 | EnumValuesWithBase | 4 | enums.swift:9:10:9:10 | value3 |
1717
| enums.swift:7:1:10:1 | EnumValuesWithBase | 5 | enums.swift:9:18:9:18 | value4 |
1818
| enums.swift:7:1:10:1 | EnumValuesWithBase | 6 | enums.swift:9:26:9:26 | value5 |
19-
| enums.swift:7:1:10:1 | EnumValuesWithBase | 7 | file://:0:0:0:0 | init |
19+
| enums.swift:7:1:10:1 | EnumValuesWithBase | 7 | file://:0:0:0:0 | init(rawValue:) |
2020
| enums.swift:7:1:10:1 | EnumValuesWithBase | 8 | file://:0:0:0:0 | var ... = ... |
2121
| enums.swift:7:1:10:1 | EnumValuesWithBase | 9 | file://:0:0:0:0 | RawValue |
2222
| enums.swift:7:1:10:1 | EnumValuesWithBase | 10 | file://:0:0:0:0 | rawValue |
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
| constructor_ref_calls.swift:7:9:7:9 | call to init | getFunction: | constructor_ref_calls.swift:7:9:7:9 | init | getBase: | constructor_ref_calls.swift:7:9:7:9 | X.Type |
2-
| constructor_ref_calls.swift:8:10:8:10 | call to init | getFunction: | constructor_ref_calls.swift:8:10:8:10 | init | getBase: | constructor_ref_calls.swift:8:10:8:10 | Y.Type |
3-
| constructor_ref_calls.swift:9:10:9:10 | call to init | getFunction: | constructor_ref_calls.swift:9:10:9:10 | init | getBase: | constructor_ref_calls.swift:9:10:9:10 | Y.Type |
1+
| constructor_ref_calls.swift:7:9:7:9 | call to init() | getFunction: | constructor_ref_calls.swift:7:9:7:9 | init() | getBase: | constructor_ref_calls.swift:7:9:7:9 | X.Type |
2+
| constructor_ref_calls.swift:8:10:8:10 | call to init(_:) | getFunction: | constructor_ref_calls.swift:8:10:8:10 | init(_:) | getBase: | constructor_ref_calls.swift:8:10:8:10 | Y.Type |
3+
| constructor_ref_calls.swift:9:10:9:10 | call to init() | getFunction: | constructor_ref_calls.swift:9:10:9:10 | init() | getBase: | constructor_ref_calls.swift:9:10:9:10 | Y.Type |
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
| constructor_ref_calls.swift:7:9:7:9 | call to init | 0 | constructor_ref_calls.swift:7:9:7:9 | : X.Type |
2-
| constructor_ref_calls.swift:8:10:8:10 | call to init | 0 | constructor_ref_calls.swift:8:10:8:10 | : Y.Type |
3-
| constructor_ref_calls.swift:9:10:9:10 | call to init | 0 | constructor_ref_calls.swift:9:10:9:10 | : Y.Type |
1+
| constructor_ref_calls.swift:7:9:7:9 | call to init() | 0 | constructor_ref_calls.swift:7:9:7:9 | : X.Type |
2+
| constructor_ref_calls.swift:8:10:8:10 | call to init(_:) | 0 | constructor_ref_calls.swift:8:10:8:10 | : Y.Type |
3+
| constructor_ref_calls.swift:9:10:9:10 | call to init() | 0 | constructor_ref_calls.swift:9:10:9:10 | : Y.Type |
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
| constructor_ref_calls.swift:7:9:7:9 | call to init | () -> X |
2-
| constructor_ref_calls.swift:8:10:8:10 | call to init | (Int) -> Y |
3-
| constructor_ref_calls.swift:9:10:9:10 | call to init | () -> Y |
1+
| constructor_ref_calls.swift:7:9:7:9 | call to init() | () -> X |
2+
| constructor_ref_calls.swift:8:10:8:10 | call to init(_:) | (Int) -> Y |
3+
| constructor_ref_calls.swift:9:10:9:10 | call to init() | () -> Y |
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
| dot_syntax_call.swift:7:13:7:13 | call to ... | getFunction: | dot_syntax_call.swift:7:13:7:13 | { ... } | getBase: | dot_syntax_call.swift:7:13:7:13 | self |
22
| dot_syntax_call.swift:15:9:15:11 | call to ... | getFunction: | dot_syntax_call.swift:15:11:15:11 | { ... } | getBase: | dot_syntax_call.swift:15:9:15:9 | X.Type |
3-
| dot_syntax_call.swift:16:9:16:13 | call to ... | getFunction: | dot_syntax_call.swift:16:13:16:13 | { ... } | getBase: | dot_syntax_call.swift:16:9:16:11 | call to init |
3+
| dot_syntax_call.swift:16:9:16:13 | call to ... | getFunction: | dot_syntax_call.swift:16:13:16:13 | { ... } | getBase: | dot_syntax_call.swift:16:9:16:11 | call to init() |
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
| dot_syntax_call.swift:7:13:7:13 | call to ... | 0 | dot_syntax_call.swift:7:13:7:13 | : self |
22
| dot_syntax_call.swift:15:9:15:11 | call to ... | 0 | dot_syntax_call.swift:15:9:15:9 | : X.Type |
3-
| dot_syntax_call.swift:16:9:16:13 | call to ... | 0 | dot_syntax_call.swift:16:9:16:11 | : call to init |
3+
| dot_syntax_call.swift:16:9:16:13 | call to ... | 0 | dot_syntax_call.swift:16:9:16:11 | : call to init() |

swift/ql/test/extractor-tests/generated/expr/EnumIsCaseExpr/EnumIsCaseExpr.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
| enum_is_case.swift:21:1:21:5 | ... is some | getSubExpr: | enum_is_case.swift:21:1:21:5 | [...] | getElement: | file://:0:0:0:0 | some |
88
| enum_is_case.swift:22:1:22:10 | ... is some | getSubExpr: | enum_is_case.swift:22:1:22:10 | [...] | getElement: | file://:0:0:0:0 | some |
99
| enum_is_case.swift:23:1:23:10 | ... is some | getSubExpr: | enum_is_case.swift:23:1:23:10 | [...] | getElement: | file://:0:0:0:0 | some |
10-
| enum_is_case.swift:24:1:24:8 | ... is some | getSubExpr: | enum_is_case.swift:24:1:24:8 | call to init | getElement: | file://:0:0:0:0 | some |
10+
| enum_is_case.swift:24:1:24:8 | ... is some | getSubExpr: | enum_is_case.swift:24:1:24:8 | call to init() | getElement: | file://:0:0:0:0 | some |
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
| method_refs.swift:7:13:7:13 | .baz(_:) | getBase: | file://:0:0:0:0 | self |
22
| method_refs.swift:11:1:11:3 | .foo(_:_:) | getBase: | method_refs.swift:11:1:11:1 | X.Type |
33
| method_refs.swift:12:1:12:3 | .bar() | getBase: | method_refs.swift:12:1:12:1 | X.Type |
4-
| method_refs.swift:13:1:13:5 | .baz(_:) | getBase: | method_refs.swift:13:1:13:3 | call to init |
4+
| method_refs.swift:13:1:13:5 | .baz(_:) | getBase: | method_refs.swift:13:1:13:3 | call to init() |
55
| method_refs.swift:15:11:15:11 | .bar() | getBase: | file://:0:0:0:0 | self |
66
| method_refs.swift:16:13:16:13 | .baz(_:) | getBase: | file://:0:0:0:0 | self |

swift/ql/test/extractor-tests/types/Types.expected

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@
1313
| types.swift:3:9:3:9 | Int.Type | Int.Type |
1414
| types.swift:3:11:3:11 | 10 | Int |
1515
| types.swift:7:16:7:16 | X.Type | X.Type |
16-
| types.swift:7:16:7:16 | call to init | () -> X |
17-
| types.swift:7:16:7:16 | init | (X.Type) -> () -> X |
18-
| types.swift:7:16:7:18 | call to init | X |
16+
| types.swift:7:16:7:16 | call to init() | () -> X |
17+
| types.swift:7:16:7:16 | init() | (X.Type) -> () -> X |
18+
| types.swift:7:16:7:18 | call to init() | X |
1919
| types.swift:13:17:13:17 | C.Type | C.Type |
20-
| types.swift:13:17:13:17 | call to init | () -> C |
21-
| types.swift:13:17:13:17 | init | (C.Type) -> () -> C |
22-
| types.swift:13:17:13:19 | call to init | C |
20+
| types.swift:13:17:13:17 | call to init() | () -> C |
21+
| types.swift:13:17:13:17 | init() | (C.Type) -> () -> C |
22+
| types.swift:13:17:13:19 | call to init() | C |
2323
| types.swift:14:22:14:24 | C.Nested.Type | C.Nested.Type |
24-
| types.swift:14:22:14:24 | call to init | () -> C.Nested |
25-
| types.swift:14:22:14:31 | call to init | C.Nested |
26-
| types.swift:14:24:14:24 | init | (C.Nested.Type) -> () -> C.Nested |
24+
| types.swift:14:22:14:24 | call to init() | () -> C.Nested |
25+
| types.swift:14:22:14:31 | call to init() | C.Nested |
26+
| types.swift:14:24:14:24 | init() | (C.Nested.Type) -> () -> C.Nested |
2727
| types.swift:17:10:17:10 | x | Int |
2828
| types.swift:17:10:17:14 | ... .+(_:_:) ... | Int |
2929
| types.swift:17:12:17:12 | +(_:_:) | (Int.Type) -> (Int, Int) -> Int |

0 commit comments

Comments
 (0)