Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions unified/extractor/src/languages/swift/swift.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1274,13 +1274,15 @@ fn translation_rules() -> Vec<Rule<SwiftContext>> {
// nest under `signature` (as for `functionDecl`).
rule!(
(initializerDecl
initKeyword: @initK
modifiers: _* @mods
signature: (functionSignature
parameterClause: (functionParameterClause parameters: _* @params))
body: (codeBlock statements: _* @body_stmts)?)
=>
(constructor_declaration
modifier: {mods}
name_node: (identifier #{initK})
parameter: {params}
body: (block stmt: {body_stmts}))
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ top_level source="⟨body⟩"
modifier: modifier "var" source="var"
pattern: identifier "x" source="x"
type: identifier "Int" source="Int"
constructor_declaration source="⟨body⟩⟨parameter⟩"
constructor_declaration source="⟨name_node⟩⟨body⟩⟨parameter⟩"
name_node: identifier "init" source="init"
parameter:
parameter source="⟨pattern⟩: ⟨type⟩"
type: identifier "Int" source="Int"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ top_level source="⟨body⟩"
modifier: modifier "struct" source="struct"
name_node: identifier "Size" source="Size"
member:
constructor_declaration source="⟨body⟩⟨parameter⟩⟨parameter⟩"
constructor_declaration source="⟨name_node⟩⟨body⟩⟨parameter⟩⟨parameter⟩"
name_node: identifier "init" source="init"
parameter:
parameter source="⟨external_name_node⟩ ⟨pattern⟩: ⟨type⟩,"
external_name_node: identifier "width" source="width"
Expand Down
4 changes: 4 additions & 0 deletions unified/ql/test/library-tests/controlflow/cfg.expected
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,11 @@ noCfg
| cfg.swift:358:6:358:28 | loop_with_identity_expr |
| cfg.swift:371:8:371:18 | getOptional |
| cfg.swift:380:45:380:47 | Int |
| cfg.swift:391:3:391:6 | init |
| cfg.swift:408:3:408:6 | init |
| cfg.swift:421:6:421:22 | localDeclarations |
| cfg.swift:424:5:424:8 | init |
| cfg.swift:431:5:431:8 | init |
| cfg.swift:468:6:468:17 | testIfConfig |
| cfg.swift:497:6:497:18 | testAvailable |
| cfg.swift:524:6:524:17 | testAsyncFor |
Expand Down
8 changes: 4 additions & 4 deletions unified/ql/test/library-tests/controlflow/cfg.swift
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ func testTupleElement(t : (a: Int, Int, c: Int)) -> Int {
}

class Derived : C { // $ nonSimple='ClassLikeDeclaration -V Derived -^ BaseType -V C'
init() {
init() { // $ noCfg
super.init(n: 0)
}
}
Expand All @@ -405,7 +405,7 @@ func doWithoutCatch(x : Int) throws -> Int {

class Structors {
var field: Int
init() {
init() { // $ noCfg
field = 10
}

Expand All @@ -421,14 +421,14 @@ func dictionaryLiteral(x: Int, y: Int) -> [String: Int] {
func localDeclarations() -> Int { // $ noCfg
class MyLocalClass {
var x: Int
init() {
init() { // $ noCfg
x = 10
}
}

struct MyLocalStruct {
var x: Int
init() {
init() { // $ noCfg
x = 10
}
}
Expand Down
Loading