From 10908240eeb1044f8488eaea5869838c00ca4e4f Mon Sep 17 00:00:00 2001 From: Tom Hvitved Date: Wed, 30 Sep 2026 09:59:32 +0200 Subject: [PATCH] Unified: Implement `{Constructor,Function,Variable}Declaration.toString` --- .../lib/codeql/unified/internal/AstPlugin.qll | 43 +++ .../unified/internal/AstPluginSwift.qll | 22 ++ .../lib/codeql/unified/internal/FacadeAst.qll | 28 +- .../controlflow/basicblock-slices.expected | 286 +++++++++--------- .../library-tests/controlflow/cfg.expected | 4 +- .../test/library-tests/controlflow/cfg.swift | 4 +- 6 files changed, 235 insertions(+), 152 deletions(-) create mode 100644 unified/ql/lib/codeql/unified/internal/AstPlugin.qll create mode 100644 unified/ql/lib/codeql/unified/internal/AstPluginSwift.qll diff --git a/unified/ql/lib/codeql/unified/internal/AstPlugin.qll b/unified/ql/lib/codeql/unified/internal/AstPlugin.qll new file mode 100644 index 000000000000..d8958198ed71 --- /dev/null +++ b/unified/ql/lib/codeql/unified/internal/AstPlugin.qll @@ -0,0 +1,43 @@ +overlay[local] +module; + +private import unified +private import codeql.util.Unit + +private module Plugins { + private import AstPluginSwift +} + +class AstPlugin extends Unit { + bindingset[f] + string getFunctionDeclarationKeyword(FunctionDeclaration f) { none() } + + bindingset[c] + string getConstructorDeclarationKeyword(ConstructorDeclaration c) { none() } + + bindingset[cls] + string getClassLikeDeclarationKeyword(ClassLikeDeclaration cls) { none() } + + bindingset[decl] + string getVariableDeclarationKeyword(VariableDeclaration decl) { none() } +} + +bindingset[f] +string getFunctionDeclarationKeyword(FunctionDeclaration f) { + result = any(AstPlugin p).getFunctionDeclarationKeyword(f) +} + +bindingset[c] +string getConstructorDeclarationKeyword(ConstructorDeclaration c) { + result = any(AstPlugin p).getConstructorDeclarationKeyword(c) +} + +bindingset[cls] +string getClassLikeDeclarationKeyword(ClassLikeDeclaration cls) { + result = any(AstPlugin p).getClassLikeDeclarationKeyword(cls) +} + +bindingset[decl] +string getVariableDeclarationKeyword(VariableDeclaration decl) { + result = any(AstPlugin p).getVariableDeclarationKeyword(decl) +} diff --git a/unified/ql/lib/codeql/unified/internal/AstPluginSwift.qll b/unified/ql/lib/codeql/unified/internal/AstPluginSwift.qll new file mode 100644 index 000000000000..801055188218 --- /dev/null +++ b/unified/ql/lib/codeql/unified/internal/AstPluginSwift.qll @@ -0,0 +1,22 @@ +overlay[local] +module; + +private import unified +private import AstPlugin + +private class AstPluginSwift extends AstPlugin { + bindingset[f] + override string getFunctionDeclarationKeyword(FunctionDeclaration f) { + exists(f) and result = "func" + } + + override string getClassLikeDeclarationKeyword(ClassLikeDeclaration cls) { + cls.hasModifier(result) and + result in ["class", "struct", "enum", "actor", "extension", "protocol"] + } + + override string getVariableDeclarationKeyword(VariableDeclaration decl) { + decl.hasModifier(result) and + result in ["var", "let"] + } +} diff --git a/unified/ql/lib/codeql/unified/internal/FacadeAst.qll b/unified/ql/lib/codeql/unified/internal/FacadeAst.qll index aec293c462f2..44606bb41964 100644 --- a/unified/ql/lib/codeql/unified/internal/FacadeAst.qll +++ b/unified/ql/lib/codeql/unified/internal/FacadeAst.qll @@ -4,6 +4,7 @@ overlay[local?] module; +private import AstPlugin private import codeql.files.FileSystem private import codeql.unified.internal.NameBinding as NameBinding @@ -153,17 +154,18 @@ module Unified { NameBinding::getStaticBindingTargetFromRef(this.getABaseType().getType()) } - private string getKind() { - this.hasModifier(result) and - result in ["class", "struct", "interface", "enum", "actor", "extension", "protocol"] + override string toString() { + result = concat(getClassLikeDeclarationKeyword(this) + " ") + concat(this.getName()) } - - override string toString() { result = concat(this.getKind() + " ") + concat(this.getName()) } } class ConstructorDeclaration extends G::ConstructorDeclaration { /** Gets the name of this constructor. */ string getName() { result = this.getNameNode().getValue() } + + override string toString() { + result = concat(getConstructorDeclarationKeyword(this) + " ") + concat(this.getName()) + } } class ContinueExpr extends G::ContinueExpr { @@ -174,6 +176,22 @@ module Unified { class FunctionDeclaration extends G::FunctionDeclaration { /** Gets the name of this function. */ string getName() { result = this.getNameNode().getValue() } + + override string toString() { + result = concat(getFunctionDeclarationKeyword(this) + " ") + concat(this.getName()) + } + } + + class VariableDeclaration extends G::VariableDeclaration { + /** Gets the name node of this variable declaration, if any. */ + Identifier getNameNode() { result = this.getPattern() } + + /** Gets the name of the variable being declared, if any. */ + string getName() { result = this.getNameNode().getValue() } + + override string toString() { + result = concat(getVariableDeclarationKeyword(this) + " ") + concat(this.getName()) + } } class LabeledStmt extends G::LabeledStmt { diff --git a/unified/ql/test/library-tests/controlflow/basicblock-slices.expected b/unified/ql/test/library-tests/controlflow/basicblock-slices.expected index 18d5706acac5..2edaee1e3e28 100644 --- a/unified/ql/test/library-tests/controlflow/basicblock-slices.expected +++ b/unified/ql/test/library-tests/controlflow/basicblock-slices.expected @@ -1,18 +1,18 @@ -| 1 | cfg.swift:1:1:604:1 | Block | 'Block -V VariableDeclaration -V topLevelDecl -> Int -> 0' | +| 1 | cfg.swift:1:1:604:1 | Block | 'Block -V var topLevelDecl -V topLevelDecl -> Int -> 0' | | 2 | cfg.swift:2:1:2:1 | 0 | '0' | | 3 | cfg.swift:3:1:3:12 | topLevelDecl | 'topLevelDecl -> 1 -^ ... + ...' | -| 5 | cfg.swift:5:1:5:37 | FunctionDeclaration | 'FunctionDeclaration' | +| 5 | cfg.swift:5:1:5:37 | func returnZero | 'func returnZero' | | 5 | cfg.swift:5:26:5:37 | Block | 'Block -V 0 -^ ReturnExpr' | | 7 | cfg.swift:7:1:7:10 | returnZero | 'returnZero -^ returnZero(...)' | | 8 | cfg.swift:8:1:8:6 | Double | 'Double -> Argument -V topLevelDecl -^ Double(...)' | | 10 | cfg.swift:10:1:13:1 | enum MyError | 'enum MyError -V MyError -> BaseType -V Error' | -| 11 | cfg.swift:11:10:11:15 | VariableDeclaration | 'VariableDeclaration -V error1 -> VariableDeclaration -V error2' | -| 12 | cfg.swift:12:10:12:31 | error3 | 'error3 -V error3 -^ ConstructorDeclaration' | +| 11 | cfg.swift:11:10:11:15 | error1 | 'error1 -V error1 -> error2 -V error2' | +| 12 | cfg.swift:12:10:12:31 | error3 | 'error3 -V error3 -^ ' | | 12 | cfg.swift:12:17:12:25 | withParam | 'withParam -? Block' | -| 15 | cfg.swift:15:1:17:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 15 | cfg.swift:15:1:17:1 | func isZero | 'func isZero' | | 15 | cfg.swift:15:13:15:13 | x | 'x -> Block' | | 16 | cfg.swift:16:10:16:10 | x | 'x -> 0 -^ ... == ... -^ ReturnExpr' | -| 19 | cfg.swift:19:1:26:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 19 | cfg.swift:19:1:26:1 | func mightThrow | 'func mightThrow' | | 19 | cfg.swift:19:17:19:17 | x | 'x -> Block' | | 20 | cfg.swift:20:3:22:3 | GuardIfStmt | 'GuardIfStmt -V x -> 0 -^ ... >= ...' | | 20 | cfg.swift:20:21:22:3 | Block | 'Block' | @@ -20,7 +20,7 @@ | 23 | cfg.swift:23:3:25:3 | GuardIfStmt | 'GuardIfStmt -V x -> 0 -^ ... <= ...' | | 23 | cfg.swift:23:21:25:3 | Block | 'Block' | | 24 | cfg.swift:24:11:24:17 | MyError | 'MyError -^ ... .error3 -> Argument -V x -> 1 -^ ... + ... -^ ... .error3(...) -^ ThrowExpr' | -| 28 | cfg.swift:28:1:45:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 28 | cfg.swift:28:1:45:1 | func tryCatch | 'func tryCatch' | | 28 | cfg.swift:28:15:28:15 | x | 'x -> Block' | | 29 | cfg.swift:29:3:43:3 | TryExpr | 'TryExpr -V Block' | | 30 | cfg.swift:30:5:30:24 | try ... | 'try ...' | @@ -40,79 +40,79 @@ | 41 | cfg.swift:41:5:43:3 | CatchClause | 'CatchClause -V Block' | | 42 | cfg.swift:42:5:42:9 | print | 'print -> Argument -V Unknown error -> interpolation -> Argument -V error -^ interpolation(...) -> -^ StringInterpolationExpr -^ print(...)' | | 44 | cfg.swift:44:10:44:10 | 0 | '0 -^ ReturnExpr' | -| 47 | cfg.swift:47:1:51:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 47 | cfg.swift:47:1:51:1 | func createClosure1 | 'func createClosure1' | | 47 | cfg.swift:47:21:47:21 | s | 's -> Block' | | 48 | cfg.swift:48:10:50:3 | FunctionExpr | 'FunctionExpr -^ ReturnExpr' | | 49 | cfg.swift:49:5:49:17 | Block | 'Block -V s -> "" -^ ... + ... -^ ReturnExpr' | -| 53 | cfg.swift:53:1:58:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 53 | cfg.swift:53:1:58:1 | func createClosure2 | 'func createClosure2' | | 53 | cfg.swift:53:21:53:21 | x | 'x -> Block' | -| 54 | cfg.swift:54:3:56:3 | FunctionDeclaration | 'FunctionDeclaration' | +| 54 | cfg.swift:54:3:56:3 | func f | 'func f' | | 54 | cfg.swift:54:10:54:10 | y | 'y -> Block' | | 55 | cfg.swift:55:12:55:12 | x | 'x -> y -^ ... + ... -^ ReturnExpr' | | 57 | cfg.swift:57:10:57:10 | f | 'f -^ ReturnExpr' | -| 60 | cfg.swift:60:1:64:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 60 | cfg.swift:60:1:64:1 | func createClosure3 | 'func createClosure3' | | 60 | cfg.swift:60:21:60:21 | x | 'x -> Block' | | 61 | cfg.swift:61:10:63:3 | FunctionExpr | 'FunctionExpr -^ ReturnExpr' | | 62 | cfg.swift:62:6:62:6 | y | 'y -> Block -V x -> y -^ ... + ...' | -| 66 | cfg.swift:66:1:70:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 66 | cfg.swift:66:1:70:1 | func callClosures | 'func callClosures' | | 66 | cfg.swift:66:21:70:1 | Block | 'Block' | -| 67 | cfg.swift:67:3:67:34 | VariableDeclaration | 'VariableDeclaration -V x1 -> createClosure1 -> Argument -V "" -^ createClosure1(...) -^ ...(...)' | -| 68 | cfg.swift:68:3:68:35 | VariableDeclaration | 'VariableDeclaration -V x2 -> createClosure2 -> Argument -V 0 -^ createClosure2(...) -> Argument -V 10 -^ ...(...)' | -| 69 | cfg.swift:69:3:69:35 | VariableDeclaration | 'VariableDeclaration -V x3 -> createClosure3 -> Argument -V 0 -^ createClosure3(...) -> Argument -V 10 -^ ...(...)' | -| 72 | cfg.swift:72:1:75:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 67 | cfg.swift:67:3:67:34 | var x1 | 'var x1 -V x1 -> createClosure1 -> Argument -V "" -^ createClosure1(...) -^ ...(...)' | +| 68 | cfg.swift:68:3:68:35 | var x2 | 'var x2 -V x2 -> createClosure2 -> Argument -V 0 -^ createClosure2(...) -> Argument -V 10 -^ ...(...)' | +| 69 | cfg.swift:69:3:69:35 | var x3 | 'var x3 -V x3 -> createClosure3 -> Argument -V 0 -^ createClosure3(...) -> Argument -V 10 -^ ...(...)' | +| 72 | cfg.swift:72:1:75:1 | func maybeParseInt | 'func maybeParseInt' | | 72 | cfg.swift:72:20:72:20 | s | 's -> Block' | -| 73 | cfg.swift:73:3:73:23 | VariableDeclaration | 'VariableDeclaration -V n -> Optional -> Int -^ GenericTypeExpr -> Int -> Argument -V s -^ Int(...)' | +| 73 | cfg.swift:73:3:73:23 | var n | 'var n -V n -> Optional -> Int -^ GenericTypeExpr -> Int -> Argument -V s -^ Int(...)' | | 74 | cfg.swift:74:10:74:10 | n | 'n -^ ReturnExpr' | -| 77 | cfg.swift:77:1:81:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 77 | cfg.swift:77:1:81:1 | func forceAndBackToOptional | 'func forceAndBackToOptional' | | 77 | cfg.swift:77:39:81:1 | Block | 'Block' | -| 78 | cfg.swift:78:3:78:36 | VariableDeclaration | 'VariableDeclaration -V nBang -> maybeParseInt -> Argument -V "42" -^ maybeParseInt(...) -^ ... !' | -| 79 | cfg.swift:79:3:79:31 | VariableDeclaration | 'VariableDeclaration -V n -> maybeParseInt -> Argument -V "42" -^ maybeParseInt(...)' | +| 78 | cfg.swift:78:3:78:36 | var nBang | 'var nBang -V nBang -> maybeParseInt -> Argument -V "42" -^ maybeParseInt(...) -^ ... !' | +| 79 | cfg.swift:79:3:79:31 | var n | 'var n -V n -> maybeParseInt -> Argument -V "42" -^ maybeParseInt(...)' | | 80 | cfg.swift:80:10:80:14 | nBang | 'nBang -> n -^ ... ! -^ ... + ... -^ ReturnExpr' | -| 83 | cfg.swift:83:1:98:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 83 | cfg.swift:83:1:98:1 | func testInOut | 'func testInOut' | | 83 | cfg.swift:83:25:98:1 | Block | 'Block' | -| 84 | cfg.swift:84:3:84:15 | VariableDeclaration | 'VariableDeclaration -V temp -> 10' | -| 86 | cfg.swift:86:3:88:3 | FunctionDeclaration | 'FunctionDeclaration' | +| 84 | cfg.swift:84:3:84:15 | var temp | 'var temp -V temp -> 10' | +| 86 | cfg.swift:86:3:88:3 | func add | 'func add' | | 86 | cfg.swift:86:12:86:12 | a | 'a -> Block' | | 87 | cfg.swift:87:5:87:5 | a | 'a -> a -> 1 -^ ... + ... -^ ... = ...' | -| 90 | cfg.swift:90:3:92:3 | FunctionDeclaration | 'FunctionDeclaration' | +| 90 | cfg.swift:90:3:92:3 | func addOptional | 'func addOptional' | | 90 | cfg.swift:90:20:90:20 | a | 'a -> Block' | | 91 | cfg.swift:91:5:91:5 | a | 'a -> nil -^ ... = ...' | | 94 | cfg.swift:94:3:94:5 | add | 'add -> Argument -V -^ add(...)' | -| 95 | cfg.swift:95:3:95:30 | VariableDeclaration | 'VariableDeclaration -V tempOptional -> Optional -> Int -^ GenericTypeExpr -> 10' | +| 95 | cfg.swift:95:3:95:30 | var tempOptional | 'var tempOptional -V tempOptional -> Optional -> Int -^ GenericTypeExpr -> 10' | | 96 | cfg.swift:96:3:96:13 | addOptional | 'addOptional -> Argument -V -^ addOptional(...)' | | 97 | cfg.swift:97:10:97:13 | temp | 'temp -> tempOptional -^ ... ! -^ ... + ... -^ ReturnExpr' | | 100 | cfg.swift:100:1:109:1 | class C | 'class C -V C' | -| 101 | cfg.swift:101:3:101:16 | VariableDeclaration | 'VariableDeclaration -V myInt -> Int' | -| 102 | cfg.swift:102:3:104:3 | ConstructorDeclaration | 'ConstructorDeclaration' | +| 101 | cfg.swift:101:3:101:16 | let myInt | 'let myInt -V myInt -> Int' | +| 102 | cfg.swift:102:3:104:3 | init | 'init' | | 102 | cfg.swift:102:8:102:8 | n | 'n -> Block' | | 103 | cfg.swift:103:5:103:9 | myInt | 'myInt -> n -^ ... = ...' | -| 106 | cfg.swift:106:3:108:3 | FunctionDeclaration | 'FunctionDeclaration' | +| 106 | cfg.swift:106:3:108:3 | func getMyInt | 'func getMyInt' | | 106 | cfg.swift:106:26:108:3 | Block | 'Block' | | 107 | cfg.swift:107:12:107:16 | myInt | 'myInt -^ ReturnExpr' | -| 111 | cfg.swift:111:1:137:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 111 | cfg.swift:111:1:137:1 | func testMemberRef | 'func testMemberRef' | | 111 | cfg.swift:111:20:111:24 | param | 'param -> inoutParam -> opt -> Block' | -| 112 | cfg.swift:112:3:112:18 | VariableDeclaration | 'VariableDeclaration -V c -> C -> Argument -V 42 -^ C(...)' | -| 113 | cfg.swift:113:3:113:18 | VariableDeclaration | 'VariableDeclaration -V n1 -> c -^ ... .myInt' | -| 114 | cfg.swift:114:3:114:23 | VariableDeclaration | 'VariableDeclaration -V n2 -> c -^ ... .self -^ ... .myInt' | -| 115 | cfg.swift:115:3:115:23 | VariableDeclaration | 'VariableDeclaration -V n3 -> c -^ ... .getMyInt -^ ... .getMyInt(...)' | -| 116 | cfg.swift:116:3:116:28 | VariableDeclaration | 'VariableDeclaration -V n4 -> c -^ ... .self -^ ... .getMyInt -^ ... .getMyInt(...)' | -| 117 | cfg.swift:117:3:117:22 | VariableDeclaration | 'VariableDeclaration -V n5 -> param -^ ... .myInt' | -| 118 | cfg.swift:118:3:118:27 | VariableDeclaration | 'VariableDeclaration -V n6 -> param -^ ... .self -^ ... .myInt' | -| 120 | cfg.swift:120:3:120:32 | VariableDeclaration | 'VariableDeclaration -V n8 -> param -^ ... .self -^ ... .getMyInt -^ ... .getMyInt(...)' | -| 122 | cfg.swift:122:3:122:27 | VariableDeclaration | 'VariableDeclaration -V n9 -> inoutParam -^ ... .myInt' | -| 123 | cfg.swift:123:3:123:27 | VariableDeclaration | 'VariableDeclaration -V n7 -> param -^ ... .getMyInt -^ ... .getMyInt(...)' | -| 124 | cfg.swift:124:3:124:33 | VariableDeclaration | 'VariableDeclaration -V n10 -> inoutParam -^ ... .self -^ ... .myInt' | -| 125 | cfg.swift:125:3:125:33 | VariableDeclaration | 'VariableDeclaration -V n11 -> inoutParam -^ ... .getMyInt -^ ... .getMyInt(...)' | -| 126 | cfg.swift:126:3:126:38 | VariableDeclaration | 'VariableDeclaration -V n12 -> inoutParam -^ ... .self -^ ... .getMyInt -^ ... .getMyInt(...)' | -| 128 | cfg.swift:128:3:128:22 | VariableDeclaration | 'VariableDeclaration -V n13 -> opt -^ ... ! -^ ... .myInt' | -| 129 | cfg.swift:129:3:129:27 | VariableDeclaration | 'VariableDeclaration -V n14 -> opt -^ ... ! -^ ... .self -^ ... .myInt' | -| 130 | cfg.swift:130:3:130:27 | VariableDeclaration | 'VariableDeclaration -V n15 -> opt -^ ... ! -^ ... .getMyInt -^ ... .getMyInt(...)' | -| 131 | cfg.swift:131:3:131:32 | VariableDeclaration | 'VariableDeclaration -V n16 -> opt -^ ... ! -^ ... .self -^ ... .getMyInt -^ ... .getMyInt(...)' | -| 133 | cfg.swift:133:3:133:22 | VariableDeclaration | 'VariableDeclaration -V n17 -> opt -^ ... .myInt' | -| 134 | cfg.swift:134:3:134:27 | VariableDeclaration | 'VariableDeclaration -V n18 -> opt -^ ... .self -^ ... .myInt' | -| 135 | cfg.swift:135:3:135:27 | VariableDeclaration | 'VariableDeclaration -V n19 -> opt -^ ... .getMyInt -^ ... .getMyInt(...)' | -| 136 | cfg.swift:136:3:136:32 | VariableDeclaration | 'VariableDeclaration -V n20 -> opt -^ ... .self -^ ... .getMyInt -^ ... .getMyInt(...)' | -| 139 | cfg.swift:139:1:166:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 112 | cfg.swift:112:3:112:18 | let c | 'let c -V c -> C -> Argument -V 42 -^ C(...)' | +| 113 | cfg.swift:113:3:113:18 | let n1 | 'let n1 -V n1 -> c -^ ... .myInt' | +| 114 | cfg.swift:114:3:114:23 | let n2 | 'let n2 -V n2 -> c -^ ... .self -^ ... .myInt' | +| 115 | cfg.swift:115:3:115:23 | let n3 | 'let n3 -V n3 -> c -^ ... .getMyInt -^ ... .getMyInt(...)' | +| 116 | cfg.swift:116:3:116:28 | let n4 | 'let n4 -V n4 -> c -^ ... .self -^ ... .getMyInt -^ ... .getMyInt(...)' | +| 117 | cfg.swift:117:3:117:22 | let n5 | 'let n5 -V n5 -> param -^ ... .myInt' | +| 118 | cfg.swift:118:3:118:27 | let n6 | 'let n6 -V n6 -> param -^ ... .self -^ ... .myInt' | +| 120 | cfg.swift:120:3:120:32 | let n8 | 'let n8 -V n8 -> param -^ ... .self -^ ... .getMyInt -^ ... .getMyInt(...)' | +| 122 | cfg.swift:122:3:122:27 | let n9 | 'let n9 -V n9 -> inoutParam -^ ... .myInt' | +| 123 | cfg.swift:123:3:123:27 | let n7 | 'let n7 -V n7 -> param -^ ... .getMyInt -^ ... .getMyInt(...)' | +| 124 | cfg.swift:124:3:124:33 | let n10 | 'let n10 -V n10 -> inoutParam -^ ... .self -^ ... .myInt' | +| 125 | cfg.swift:125:3:125:33 | let n11 | 'let n11 -V n11 -> inoutParam -^ ... .getMyInt -^ ... .getMyInt(...)' | +| 126 | cfg.swift:126:3:126:38 | let n12 | 'let n12 -V n12 -> inoutParam -^ ... .self -^ ... .getMyInt -^ ... .getMyInt(...)' | +| 128 | cfg.swift:128:3:128:22 | let n13 | 'let n13 -V n13 -> opt -^ ... ! -^ ... .myInt' | +| 129 | cfg.swift:129:3:129:27 | let n14 | 'let n14 -V n14 -> opt -^ ... ! -^ ... .self -^ ... .myInt' | +| 130 | cfg.swift:130:3:130:27 | let n15 | 'let n15 -V n15 -> opt -^ ... ! -^ ... .getMyInt -^ ... .getMyInt(...)' | +| 131 | cfg.swift:131:3:131:32 | let n16 | 'let n16 -V n16 -> opt -^ ... ! -^ ... .self -^ ... .getMyInt -^ ... .getMyInt(...)' | +| 133 | cfg.swift:133:3:133:22 | let n17 | 'let n17 -V n17 -> opt -^ ... .myInt' | +| 134 | cfg.swift:134:3:134:27 | let n18 | 'let n18 -V n18 -> opt -^ ... .self -^ ... .myInt' | +| 135 | cfg.swift:135:3:135:27 | let n19 | 'let n19 -V n19 -> opt -^ ... .getMyInt -^ ... .getMyInt(...)' | +| 136 | cfg.swift:136:3:136:32 | let n20 | 'let n20 -V n20 -> opt -^ ... .self -^ ... .getMyInt -^ ... .getMyInt(...)' | +| 139 | cfg.swift:139:1:166:1 | func patterns | 'func patterns' | | 139 | cfg.swift:139:15:139:15 | x | 'x -> Block' | | 140 | cfg.swift:140:3:141:12 | ForEachStmt | 'ForEachStmt -V 0 -> 10 -^ ... ... ...' | | 140 | cfg.swift:140:7:140:7 | _ | '_' | @@ -127,12 +127,12 @@ | 150 | cfg.swift:150:7:150:17 | Block | 'Block -V true -^ ReturnExpr' | | 151 | cfg.swift:151:5:152:18 | SwitchCase | 'SwitchCase' | | 152 | cfg.swift:152:7:152:18 | Block | 'Block -V false -^ ReturnExpr' | -| 168 | cfg.swift:168:1:184:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 168 | cfg.swift:168:1:184:1 | func testDefer | 'func testDefer' | | 168 | cfg.swift:168:16:168:16 | x | 'x -> Block' | | 170 | cfg.swift:170:3:172:3 | | '' | | 174 | cfg.swift:174:3:176:3 | | '' | | 178 | cfg.swift:178:3:183:3 | | '' | -| 186 | cfg.swift:186:1:198:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 186 | cfg.swift:186:1:198:1 | func m1 | 'func m1' | | 186 | cfg.swift:186:9:186:9 | x | 'x -> Block' | | 187 | cfg.swift:187:3:197:3 | IfExpr | 'IfExpr -V x -> 2 -^ ... > ...' | | 187 | cfg.swift:187:12:189:3 | Block | 'Block' | @@ -144,13 +144,13 @@ | 193 | cfg.swift:193:5:193:9 | print | 'print -> Argument -V "x is 1" -^ print(...)' | | 195 | cfg.swift:195:8:197:3 | Block | 'Block' | | 196 | cfg.swift:196:5:196:9 | print | 'print -> Argument -V "I can't guess the number" -^ print(...)' | -| 200 | cfg.swift:200:1:205:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 200 | cfg.swift:200:1:205:1 | func m2 | 'func m2' | | 200 | cfg.swift:200:9:200:9 | b | 'b -> Block' | | 201 | cfg.swift:201:3:203:3 | IfExpr | 'IfExpr -V b' | | 201 | cfg.swift:201:8:203:3 | Block | 'Block' | | 202 | cfg.swift:202:12:202:12 | 0 | '0 -^ ReturnExpr' | | 204 | cfg.swift:204:10:204:10 | 1 | '1 -^ ReturnExpr' | -| 207 | cfg.swift:207:1:215:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 207 | cfg.swift:207:1:215:1 | func m3 | 'func m3' | | 207 | cfg.swift:207:9:207:9 | x | 'x -> Block' | | 208 | cfg.swift:208:3:213:3 | IfExpr | 'IfExpr -V x -> 0 -^ ... < ...' | | 208 | cfg.swift:208:12:213:3 | Block | 'Block' | @@ -159,7 +159,7 @@ | 210 | cfg.swift:210:15:212:5 | Block | 'Block' | | 211 | cfg.swift:211:7:211:7 | x | 'x -> x -> 1 -^ ... - ... -^ ... = ...' | | 214 | cfg.swift:214:10:214:10 | x | 'x -^ ReturnExpr' | -| 217 | cfg.swift:217:1:223:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 217 | cfg.swift:217:1:223:1 | func m4 | 'func m4' | | 217 | cfg.swift:217:10:217:11 | b1 | 'b1 -> b2 -> b3 -> Block' | | 218 | cfg.swift:218:3:222:20 | ReturnExpr | 'ReturnExpr' | | 218 | cfg.swift:218:10:222:20 | IfExpr | 'IfExpr -V IfExpr -V b1' | @@ -167,7 +167,7 @@ | 220 | cfg.swift:220:13:220:14 | b3 | 'b3' | | 221 | cfg.swift:221:9:221:18 | "b2 \|\| b3" | '"b2 \|\| b3"' | | 222 | cfg.swift:222:9:222:20 | "!b2 \|\| !b3" | '"!b2 \|\| !b3"' | -| 225 | cfg.swift:225:1:234:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 225 | cfg.swift:225:1:234:1 | func conversionsInSplitEntry | 'func conversionsInSplitEntry' | | 225 | cfg.swift:225:31:225:31 | b | 'b -> Block' | | 226 | cfg.swift:226:3:233:3 | IfExpr | 'IfExpr -V IfExpr -V b' | | 227 | cfg.swift:227:8:227:11 | true | 'true' | @@ -176,46 +176,46 @@ | 229 | cfg.swift:229:12:229:14 | "b" | '"b" -^ ReturnExpr' | | 231 | cfg.swift:231:8:233:3 | Block | 'Block' | | 232 | cfg.swift:232:12:232:15 | "!b" | '"!b" -^ ReturnExpr' | -| 236 | cfg.swift:236:1:240:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 236 | cfg.swift:236:1:240:1 | func constant_condition | 'func constant_condition' | | 236 | cfg.swift:236:27:240:1 | Block | 'Block' | | 237 | cfg.swift:237:3:239:3 | IfExpr | 'IfExpr -V ! ... -V true' | -| 242 | cfg.swift:242:1:248:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 242 | cfg.swift:242:1:248:1 | func empty_else | 'func empty_else' | | 242 | cfg.swift:242:17:242:17 | b | 'b -> Block' | | 243 | cfg.swift:243:3:246:9 | IfExpr | 'IfExpr -V b' | | 243 | cfg.swift:243:8:245:3 | Block | 'Block' | | 244 | cfg.swift:244:5:244:9 | print | 'print -> Argument -V "true" -^ print(...)' | | 246 | cfg.swift:246:8:246:9 | Block | 'Block' | | 247 | cfg.swift:247:3:247:7 | print | 'print -> Argument -V "done" -^ print(...)' | -| 250 | cfg.swift:250:1:254:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 250 | cfg.swift:250:1:254:1 | func disjunct | 'func disjunct' | | 250 | cfg.swift:250:16:250:17 | b1 | 'b1 -> b2 -> Block' | | 251 | cfg.swift:251:3:253:3 | IfExpr | 'IfExpr -V ... \|\| ... -V b1' | | 251 | cfg.swift:251:13:251:14 | b2 | 'b2' | | 251 | cfg.swift:251:17:253:3 | Block | 'Block' | | 252 | cfg.swift:252:5:252:9 | print | 'print -> Argument -V "b1 or b2" -^ print(...)' | -| 256 | cfg.swift:256:1:273:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 256 | cfg.swift:256:1:273:1 | func binaryExprs | 'func binaryExprs' | | 256 | cfg.swift:256:18:256:18 | a | 'a -> b -> Block' | -| 257 | cfg.swift:257:3:257:15 | VariableDeclaration | 'VariableDeclaration -V c -> a -> b -^ ... + ...' | -| 258 | cfg.swift:258:3:258:15 | VariableDeclaration | 'VariableDeclaration -V d -> a -> b -^ ... - ...' | -| 259 | cfg.swift:259:3:259:15 | VariableDeclaration | 'VariableDeclaration -V e -> a -> b -^ ... * ...' | -| 260 | cfg.swift:260:3:260:15 | VariableDeclaration | 'VariableDeclaration -V f -> a -> b -^ ... / ...' | -| 261 | cfg.swift:261:3:261:15 | VariableDeclaration | 'VariableDeclaration -V g -> a -> b -^ ... % ...' | -| 262 | cfg.swift:262:3:262:15 | VariableDeclaration | 'VariableDeclaration -V h -> a -> b -^ ... & ...' | -| 263 | cfg.swift:263:3:263:15 | VariableDeclaration | 'VariableDeclaration -V i -> a -> b -^ ... \| ...' | -| 264 | cfg.swift:264:3:264:15 | VariableDeclaration | 'VariableDeclaration -V j -> a -> b -^ ... ^ ...' | -| 265 | cfg.swift:265:3:265:16 | VariableDeclaration | 'VariableDeclaration -V k -> a -> b -^ ... << ...' | -| 266 | cfg.swift:266:3:266:16 | VariableDeclaration | 'VariableDeclaration -V l -> a -> b -^ ... >> ...' | -| 267 | cfg.swift:267:3:267:16 | VariableDeclaration | 'VariableDeclaration -V o -> a -> b -^ ... == ...' | -| 268 | cfg.swift:268:3:268:16 | VariableDeclaration | 'VariableDeclaration -V p -> a -> b -^ ... != ...' | -| 269 | cfg.swift:269:3:269:15 | VariableDeclaration | 'VariableDeclaration -V q -> a -> b -^ ... < ...' | -| 270 | cfg.swift:270:3:270:16 | VariableDeclaration | 'VariableDeclaration -V r -> a -> b -^ ... <= ...' | -| 271 | cfg.swift:271:3:271:15 | VariableDeclaration | 'VariableDeclaration -V s -> a -> b -^ ... > ...' | -| 272 | cfg.swift:272:3:272:16 | VariableDeclaration | 'VariableDeclaration -V t -> a -> b -^ ... >= ...' | -| 275 | cfg.swift:275:1:277:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 257 | cfg.swift:257:3:257:15 | let c | 'let c -V c -> a -> b -^ ... + ...' | +| 258 | cfg.swift:258:3:258:15 | let d | 'let d -V d -> a -> b -^ ... - ...' | +| 259 | cfg.swift:259:3:259:15 | let e | 'let e -V e -> a -> b -^ ... * ...' | +| 260 | cfg.swift:260:3:260:15 | let f | 'let f -V f -> a -> b -^ ... / ...' | +| 261 | cfg.swift:261:3:261:15 | let g | 'let g -V g -> a -> b -^ ... % ...' | +| 262 | cfg.swift:262:3:262:15 | let h | 'let h -V h -> a -> b -^ ... & ...' | +| 263 | cfg.swift:263:3:263:15 | let i | 'let i -V i -> a -> b -^ ... \| ...' | +| 264 | cfg.swift:264:3:264:15 | let j | 'let j -V j -> a -> b -^ ... ^ ...' | +| 265 | cfg.swift:265:3:265:16 | let k | 'let k -V k -> a -> b -^ ... << ...' | +| 266 | cfg.swift:266:3:266:16 | let l | 'let l -V l -> a -> b -^ ... >> ...' | +| 267 | cfg.swift:267:3:267:16 | let o | 'let o -V o -> a -> b -^ ... == ...' | +| 268 | cfg.swift:268:3:268:16 | let p | 'let p -V p -> a -> b -^ ... != ...' | +| 269 | cfg.swift:269:3:269:15 | let q | 'let q -V q -> a -> b -^ ... < ...' | +| 270 | cfg.swift:270:3:270:16 | let r | 'let r -V r -> a -> b -^ ... <= ...' | +| 271 | cfg.swift:271:3:271:15 | let s | 'let s -V s -> a -> b -^ ... > ...' | +| 272 | cfg.swift:272:3:272:16 | let t | 'let t -V t -> a -> b -^ ... >= ...' | +| 275 | cfg.swift:275:1:277:1 | func interpolatedString | 'func interpolatedString' | | 275 | cfg.swift:275:25:275:25 | x | 'x -> y -> Block' | | 276 | cfg.swift:276:11:276:10 | | ' -> interpolation -> Argument -V x -^ interpolation(...) -> + -> interpolation -> Argument -V y -^ interpolation(...) -> is equal to -> interpolation -> Argument -V x -> y -^ ... + ... -^ interpolation(...) -> and here is a zero: -> interpolation -> Argument -V returnZero -^ returnZero(...) -^ interpolation(...) -> -^ StringInterpolationExpr -^ ReturnExpr' | -| 279 | cfg.swift:279:1:310:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 279 | cfg.swift:279:1:310:1 | func testSubscriptExpr | 'func testSubscriptExpr' | | 279 | cfg.swift:279:55:310:1 | Block | 'Block' | -| 280 | cfg.swift:280:3:280:44 | VariableDeclaration | 'VariableDeclaration -V a -> 0 -> 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 -> 8 -> 9 -> 10 -^ ArrayLiteral' | +| 280 | cfg.swift:280:3:280:44 | var a | 'var a -V a -> 0 -> 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 -> 8 -> 9 -> 10 -^ ArrayLiteral' | | 281 | cfg.swift:281:3:281:3 | a | 'a -> Argument -V 0 -^ a(...) -> 0 -^ ... = ...' | | 282 | cfg.swift:282:3:282:3 | a | 'a -> Argument -V 1 -^ a(...) -> 1 -^ ... += ...' | | 283 | cfg.swift:283:3:283:3 | a | 'a -> Argument -V 2 -^ a(...) -> 1 -^ ... -= ...' | @@ -227,8 +227,8 @@ | 289 | cfg.swift:289:3:289:3 | a | 'a -> Argument -V 8 -^ a(...) -> 1 -^ ... ^= ...' | | 290 | cfg.swift:290:3:290:3 | a | 'a -> Argument -V 9 -^ a(...) -> 1 -^ ... <<= ...' | | 291 | cfg.swift:291:3:291:3 | a | 'a -> Argument -V 10 -^ a(...) -> 1 -^ ... >>= ...' | -| 293 | cfg.swift:293:3:293:49 | VariableDeclaration | 'VariableDeclaration -V tupleWithA -> Argument -V a -> Argument -V 0 -^ a(...) -> Argument -V a -> Argument -V 1 -^ a(...) -> Argument -V a -> Argument -V 2 -^ a(...) -> Argument -V a -> Argument -V 3 -^ a(...) -> Argument -V a -> Argument -V 4 -^ a(...) -^ TupleExpr' | -| 295 | cfg.swift:295:3:295:48 | VariableDeclaration | 'VariableDeclaration -V b -> 0 -> 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 -> 8 -> 9 -> 10 -> 11 -^ ArrayLiteral' | +| 293 | cfg.swift:293:3:293:49 | var tupleWithA | 'var tupleWithA -V tupleWithA -> Argument -V a -> Argument -V 0 -^ a(...) -> Argument -V a -> Argument -V 1 -^ a(...) -> Argument -V a -> Argument -V 2 -^ a(...) -> Argument -V a -> Argument -V 3 -^ a(...) -> Argument -V a -> Argument -V 4 -^ a(...) -^ TupleExpr' | +| 295 | cfg.swift:295:3:295:48 | var b | 'var b -V b -> 0 -> 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 -> 8 -> 9 -> 10 -> 11 -^ ArrayLiteral' | | 296 | cfg.swift:296:3:296:3 | b | 'b -> Argument -V 0 -^ b(...) -> a -> Argument -V 10 -^ a(...) -^ ... = ...' | | 297 | cfg.swift:297:3:297:3 | b | 'b -> Argument -V 1 -^ b(...) -> b -> Argument -V 0 -^ b(...) -> 1 -^ ... + ... -^ ... = ...' | | 298 | cfg.swift:298:3:298:3 | b | 'b -> Argument -V 2 -^ b(...) -> b -> Argument -V 1 -^ b(...) -> 1 -^ ... - ... -^ ... = ...' | @@ -240,16 +240,16 @@ | 304 | cfg.swift:304:3:304:3 | b | 'b -> Argument -V 8 -^ b(...) -> b -> Argument -V 7 -^ b(...) -> 1 -^ ... ^ ... -^ ... = ...' | | 305 | cfg.swift:305:3:305:3 | b | 'b -> Argument -V 9 -^ b(...) -> b -> Argument -V 8 -^ b(...) -> 1 -^ ... << ... -^ ... = ...' | | 306 | cfg.swift:306:3:306:3 | b | 'b -> Argument -V 10 -^ b(...) -> b -> Argument -V 9 -^ b(...) -> 1 -^ ... >> ... -^ ... = ...' | -| 308 | cfg.swift:308:3:308:39 | VariableDeclaration | 'VariableDeclaration -V Argument -V a1 -> Argument -V a2 -> Argument -V a3 -> Argument -V a4 -> Argument -V a5 -^ TupleExpr -> tupleWithA' | +| 308 | cfg.swift:308:3:308:39 | let | 'let -V Argument -V a1 -> Argument -V a2 -> Argument -V a3 -> Argument -V a4 -> Argument -V a5 -^ TupleExpr -> tupleWithA' | | 309 | cfg.swift:309:11:309:19 | Argument | 'Argument -V a1 -> b -> Argument -V 0 -^ b(...) -^ ... + ... -> Argument -V a2 -> b -> Argument -V 1 -^ b(...) -^ ... + ... -> Argument -V a3 -> b -> Argument -V 2 -^ b(...) -^ ... + ... -> Argument -V a4 -> b -> Argument -V 3 -^ b(...) -^ ... + ... -> Argument -V a5 -> b -> Argument -V 4 -^ b(...) -^ ... + ... -^ TupleExpr -^ ReturnExpr' | -| 312 | cfg.swift:312:1:317:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 312 | cfg.swift:312:1:317:1 | func loop1 | 'func loop1' | | 312 | cfg.swift:312:12:312:12 | x | 'x -> Block' | | 313 | cfg.swift:313:3:316:3 | WhileStmt | 'WhileStmt' | | 313 | cfg.swift:313:9:313:9 | x | 'x -> 0 -^ ... >= ...' | | 313 | cfg.swift:313:16:316:3 | Block | 'Block' | | 314 | cfg.swift:314:5:314:9 | print | 'print -> Argument -V x -^ print(...)' | | 315 | cfg.swift:315:5:315:5 | x | 'x -> 1 -^ ... -= ...' | -| 319 | cfg.swift:319:1:332:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 319 | cfg.swift:319:1:332:1 | func loop2 | 'func loop2' | | 319 | cfg.swift:319:12:319:12 | x | 'x -> Block' | | 320 | cfg.swift:320:3:330:3 | WhileStmt | 'WhileStmt' | | 320 | cfg.swift:320:9:320:9 | x | 'x -> 0 -^ ... >= ...' | @@ -264,7 +264,7 @@ | 327 | cfg.swift:327:7:327:14 | ContinueExpr | 'ContinueExpr' | | 329 | cfg.swift:329:5:329:9 | print | 'print -> Argument -V "Iter" -^ print(...)' | | 331 | cfg.swift:331:3:331:7 | print | 'print -> Argument -V "Done" -^ print(...)' | -| 334 | cfg.swift:334:1:349:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 334 | cfg.swift:334:1:349:1 | func labeledLoop | 'func labeledLoop' | | 334 | cfg.swift:334:18:334:18 | x | 'x -> Block' | | 335 | cfg.swift:335:3:348:3 | LabeledStmt | 'LabeledStmt -V WhileStmt' | | 335 | cfg.swift:335:16:335:16 | x | 'x -> 0 -^ ... >= ...' | @@ -282,43 +282,43 @@ | 343 | cfg.swift:343:9:343:22 | ContinueExpr | 'ContinueExpr' | | 345 | cfg.swift:345:7:345:11 | print | 'print -> Argument -V "Iter" -^ print(...)' | | 347 | cfg.swift:347:5:347:9 | print | 'print -> Argument -V "Done" -^ print(...)' | -| 351 | cfg.swift:351:1:356:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 351 | cfg.swift:351:1:356:1 | func testRepeat | 'func testRepeat' | | 351 | cfg.swift:351:17:351:17 | x | 'x -> Block' | | 352 | cfg.swift:352:3:355:16 | DoWhileStmt | 'DoWhileStmt' | | 352 | cfg.swift:352:10:355:3 | Block | 'Block' | | 353 | cfg.swift:353:5:353:9 | print | 'print -> Argument -V x -^ print(...)' | | 354 | cfg.swift:354:5:354:5 | x | 'x -> 1 -^ ... -= ...' | | 355 | cfg.swift:355:11:355:11 | x | 'x -> 0 -^ ... >= ...' | -| 358 | cfg.swift:358:1:363:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 358 | cfg.swift:358:1:363:1 | func loop_with_identity_expr | 'func loop_with_identity_expr' | | 358 | cfg.swift:358:32:363:1 | Block | 'Block' | -| 359 | cfg.swift:359:3:359:11 | VariableDeclaration | 'VariableDeclaration -V x -> 0' | +| 359 | cfg.swift:359:3:359:11 | var x | 'var x -V x -> 0' | | 360 | cfg.swift:360:3:362:3 | WhileStmt | 'WhileStmt' | | 360 | cfg.swift:360:9:360:9 | x | 'x -> 10 -^ ... < ...' | | 360 | cfg.swift:360:17:362:3 | Block | 'Block' | | 361 | cfg.swift:361:5:361:5 | x | 'x -> 1 -^ ... += ...' | | 365 | cfg.swift:365:1:374:1 | class OptionalC | 'class OptionalC -V OptionalC' | -| 366 | cfg.swift:366:3:366:11 | VariableDeclaration | 'VariableDeclaration -V c -> Optional -> C -^ GenericTypeExpr' | -| 367 | cfg.swift:367:3:369:3 | ConstructorDeclaration | 'ConstructorDeclaration' | +| 366 | cfg.swift:366:3:366:11 | let c | 'let c -V c -> Optional -> C -^ GenericTypeExpr' | +| 367 | cfg.swift:367:3:369:3 | init | 'init' | | 367 | cfg.swift:367:8:367:10 | arg | 'arg -> Block' | | 368 | cfg.swift:368:5:368:5 | c | 'c -> arg -^ ... = ...' | -| 371 | cfg.swift:371:3:373:3 | FunctionDeclaration | 'FunctionDeclaration' | +| 371 | cfg.swift:371:3:373:3 | func getOptional | 'func getOptional' | | 371 | cfg.swift:371:28:373:3 | Block | 'Block' | | 372 | cfg.swift:372:12:372:12 | c | 'c -^ ReturnExpr' | -| 376 | cfg.swift:376:1:378:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 376 | cfg.swift:376:1:378:1 | func testOptional | 'func testOptional' | | 376 | cfg.swift:376:19:376:19 | c | 'c -> Block' | | 377 | cfg.swift:377:10:377:10 | c | 'c -^ ... .getOptional -^ ... .getOptional(...) -^ ... .getMyInt -^ ... .getMyInt(...) -^ ReturnExpr' | -| 380 | cfg.swift:380:1:384:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 380 | cfg.swift:380:1:384:1 | func testCapture | 'func testCapture' | | 380 | cfg.swift:380:18:380:18 | x | 'x -> y -> Block' | -| 381 | cfg.swift:381:13:381:21 | VariableDeclaration | 'VariableDeclaration -V z -> x -> y -^ ... + ... -> VariableDeclaration -V t -> "literal" -^ FunctionExpr -^ ReturnExpr' | +| 381 | cfg.swift:381:13:381:21 | z | 'z -V z -> x -> y -^ ... + ... -> t -V t -> "literal" -^ FunctionExpr -^ ReturnExpr' | | 382 | cfg.swift:382:5:382:12 | Block | 'Block -V z -^ ReturnExpr' | -| 386 | cfg.swift:386:1:388:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 386 | cfg.swift:386:1:388:1 | func testTupleElement | 'func testTupleElement' | | 386 | cfg.swift:386:23:386:23 | t | 't -> Block' | | 387 | cfg.swift:387:10:387:10 | t | 't -^ ... .a -> t -^ ... .1 -^ ... + ... -> t -^ ... .c -^ ... + ... -> Argument -V 1 -> Argument -V 2 -> Argument -V 3 -^ TupleExpr -^ ... .0 -^ ... + ... -^ ReturnExpr' | | 390 | cfg.swift:390:1:394:1 | class Derived | 'class Derived -V Derived -> BaseType -V C' | -| 391 | cfg.swift:391:3:393:3 | ConstructorDeclaration | 'ConstructorDeclaration' | +| 391 | cfg.swift:391:3:393:3 | init | 'init' | | 391 | cfg.swift:391:10:393:3 | Block | 'Block' | | 392 | cfg.swift:392:5:392:9 | super | 'super -^ ... .init -> Argument -V 0 -^ ... .init(...)' | -| 396 | cfg.swift:396:1:404:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 396 | cfg.swift:396:1:404:1 | func doWithoutCatch | 'func doWithoutCatch' | | 396 | cfg.swift:396:21:396:21 | x | 'x -> Block' | | 397 | cfg.swift:397:3:402:3 | TryExpr | 'TryExpr -V Block' | | 398 | cfg.swift:398:5:398:24 | try ... | 'try ...' | @@ -328,50 +328,50 @@ | 401 | cfg.swift:401:5:401:9 | print | 'print -> Argument -V "Still did not throw." -^ print(...)' | | 403 | cfg.swift:403:10:403:10 | 0 | '0 -^ ReturnExpr' | | 406 | cfg.swift:406:1:415:1 | class Structors | 'class Structors -V Structors' | -| 407 | cfg.swift:407:3:407:16 | VariableDeclaration | 'VariableDeclaration -V field -> Int' | -| 408 | cfg.swift:408:3:410:3 | ConstructorDeclaration | 'ConstructorDeclaration' | +| 407 | cfg.swift:407:3:407:16 | var field | 'var field -V field -> Int' | +| 408 | cfg.swift:408:3:410:3 | init | 'init' | | 408 | cfg.swift:408:10:410:3 | Block | 'Block' | | 409 | cfg.swift:409:5:409:9 | field | 'field -> 10 -^ ... = ...' | | 412 | cfg.swift:412:3:414:3 | DestructorDeclaration | 'DestructorDeclaration' | | 412 | cfg.swift:412:10:414:3 | Block | 'Block' | | 413 | cfg.swift:413:5:413:9 | field | 'field -> 0 -^ ... = ...' | -| 417 | cfg.swift:417:1:419:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 417 | cfg.swift:417:1:419:1 | func dictionaryLiteral | 'func dictionaryLiteral' | | 417 | cfg.swift:417:24:417:24 | x | 'x -> y -> Block' | | 418 | cfg.swift:418:10:418:25 | MapLiteral | 'MapLiteral -^ ReturnExpr' | -| 421 | cfg.swift:421:1:444:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 421 | cfg.swift:421:1:444:1 | func localDeclarations | 'func localDeclarations' | | 421 | cfg.swift:421:33:444:1 | Block | 'Block' | | 422 | cfg.swift:422:3:427:3 | class MyLocalClass | 'class MyLocalClass -V MyLocalClass' | -| 423 | cfg.swift:423:5:423:14 | VariableDeclaration | 'VariableDeclaration -V x -> Int' | -| 424 | cfg.swift:424:5:426:5 | ConstructorDeclaration | 'ConstructorDeclaration' | +| 423 | cfg.swift:423:5:423:14 | var x | 'var x -V x -> Int' | +| 424 | cfg.swift:424:5:426:5 | init | 'init' | | 424 | cfg.swift:424:12:426:5 | Block | 'Block' | | 425 | cfg.swift:425:7:425:7 | x | 'x -> 10 -^ ... = ...' | | 429 | cfg.swift:429:3:434:3 | struct MyLocalStruct | 'struct MyLocalStruct -V MyLocalStruct' | -| 430 | cfg.swift:430:5:430:14 | VariableDeclaration | 'VariableDeclaration -V x -> Int' | -| 431 | cfg.swift:431:5:433:5 | ConstructorDeclaration | 'ConstructorDeclaration' | +| 430 | cfg.swift:430:5:430:14 | var x | 'var x -V x -> Int' | +| 431 | cfg.swift:431:5:433:5 | init | 'init' | | 431 | cfg.swift:431:12:433:5 | Block | 'Block' | | 432 | cfg.swift:432:7:432:7 | x | 'x -> 10 -^ ... = ...' | | 436 | cfg.swift:436:3:439:3 | enum MyLocalEnum | 'enum MyLocalEnum -V MyLocalEnum' | -| 437 | cfg.swift:437:10:437:10 | VariableDeclaration | 'VariableDeclaration -V A' | -| 438 | cfg.swift:438:10:438:10 | VariableDeclaration | 'VariableDeclaration -V B' | -| 441 | cfg.swift:441:3:441:22 | VariableDeclaration | 'VariableDeclaration -V myLocalVar -> Int' | +| 437 | cfg.swift:437:10:437:10 | A | 'A -V A' | +| 438 | cfg.swift:438:10:438:10 | B | 'B -V B' | +| 441 | cfg.swift:441:3:441:22 | var myLocalVar | 'var myLocalVar -V myLocalVar -> Int' | | 443 | cfg.swift:443:10:443:10 | 0 | '0 -^ ReturnExpr' | | 446 | cfg.swift:446:1:448:1 | struct B | 'struct B -V B' | -| 447 | cfg.swift:447:3:447:13 | VariableDeclaration | 'VariableDeclaration -V x -> Int' | +| 447 | cfg.swift:447:3:447:13 | var x | 'var x -V x -> Int' | | 450 | cfg.swift:450:1:454:1 | struct A | 'struct A -V A' | -| 451 | cfg.swift:451:3:451:11 | VariableDeclaration | 'VariableDeclaration -V b -> B' | -| 452 | cfg.swift:452:3:452:14 | VariableDeclaration | 'VariableDeclaration -V bs -> Array -> B -^ GenericTypeExpr' | -| 453 | cfg.swift:453:3:453:15 | VariableDeclaration | 'VariableDeclaration -V mayB -> Optional -> B -^ GenericTypeExpr' | -| 456 | cfg.swift:456:1:466:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 451 | cfg.swift:451:3:451:11 | var b | 'var b -V b -> B' | +| 452 | cfg.swift:452:3:452:14 | var bs | 'var bs -V bs -> Array -> B -^ GenericTypeExpr' | +| 453 | cfg.swift:453:3:453:15 | var mayB | 'var mayB -V mayB -> Optional -> B -^ GenericTypeExpr' | +| 456 | cfg.swift:456:1:466:1 | func test | 'func test' | | 456 | cfg.swift:456:11:456:11 | a | 'a -> Block' | -| 457 | cfg.swift:457:3:457:24 | VariableDeclaration | 'VariableDeclaration -V kpGet_b_x -> ' | -| 458 | cfg.swift:458:3:458:31 | VariableDeclaration | 'VariableDeclaration -V kpGet_bs_0_x -> ' | -| 459 | cfg.swift:459:3:459:37 | VariableDeclaration | 'VariableDeclaration -V kpGet_mayB_force_x -> ' | -| 460 | cfg.swift:460:3:460:31 | VariableDeclaration | 'VariableDeclaration -V kpGet_mayB_x -> ' | -| 462 | cfg.swift:462:3:462:45 | VariableDeclaration | 'VariableDeclaration -V apply_kpGet_b_x -> a -> Argument -V kpGet_b_x -^ a(...)' | -| 463 | cfg.swift:463:3:463:51 | VariableDeclaration | 'VariableDeclaration -V apply_kpGet_bs_0_x -> a -> Argument -V kpGet_bs_0_x -^ a(...)' | -| 464 | cfg.swift:464:3:464:63 | VariableDeclaration | 'VariableDeclaration -V apply_kpGet_mayB_force_x -> a -> Argument -V kpGet_mayB_force_x -^ a(...)' | -| 465 | cfg.swift:465:3:465:51 | VariableDeclaration | 'VariableDeclaration -V apply_kpGet_mayB_x -> a -> Argument -V kpGet_mayB_x -^ a(...)' | -| 468 | cfg.swift:468:1:495:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 457 | cfg.swift:457:3:457:24 | var kpGet_b_x | 'var kpGet_b_x -V kpGet_b_x -> ' | +| 458 | cfg.swift:458:3:458:31 | var kpGet_bs_0_x | 'var kpGet_bs_0_x -V kpGet_bs_0_x -> ' | +| 459 | cfg.swift:459:3:459:37 | var kpGet_mayB_force_x | 'var kpGet_mayB_force_x -V kpGet_mayB_force_x -> ' | +| 460 | cfg.swift:460:3:460:31 | var kpGet_mayB_x | 'var kpGet_mayB_x -V kpGet_mayB_x -> ' | +| 462 | cfg.swift:462:3:462:45 | var apply_kpGet_b_x | 'var apply_kpGet_b_x -V apply_kpGet_b_x -> a -> Argument -V kpGet_b_x -^ a(...)' | +| 463 | cfg.swift:463:3:463:51 | var apply_kpGet_bs_0_x | 'var apply_kpGet_bs_0_x -V apply_kpGet_bs_0_x -> a -> Argument -V kpGet_bs_0_x -^ a(...)' | +| 464 | cfg.swift:464:3:464:63 | var apply_kpGet_mayB_force_x | 'var apply_kpGet_mayB_force_x -V apply_kpGet_mayB_force_x -> a -> Argument -V kpGet_mayB_force_x -^ a(...)' | +| 465 | cfg.swift:465:3:465:51 | var apply_kpGet_mayB_x | 'var apply_kpGet_mayB_x -V apply_kpGet_mayB_x -> a -> Argument -V kpGet_mayB_x -^ a(...)' | +| 468 | cfg.swift:468:1:495:1 | func testIfConfig | 'func testIfConfig' | | 468 | cfg.swift:468:21:495:1 | Block | 'Block' | | 469 | cfg.swift:469:1:475:6 | | '' | | 477 | cfg.swift:477:3:477:3 | 5 | '5' | @@ -379,9 +379,9 @@ | 484 | cfg.swift:484:3:484:3 | 8 | '8' | | 486 | cfg.swift:486:1:492:6 | | '' | | 494 | cfg.swift:494:3:494:4 | 13 | '13' | -| 497 | cfg.swift:497:1:522:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 497 | cfg.swift:497:1:522:1 | func testAvailable | 'func testAvailable' | | 497 | cfg.swift:497:29:522:1 | Block | 'Block' | -| 498 | cfg.swift:498:3:498:11 | VariableDeclaration | 'VariableDeclaration -V x -> 0' | +| 498 | cfg.swift:498:3:498:11 | var x | 'var x -V x -> 0' | | 500 | cfg.swift:500:3:502:3 | IfExpr | 'IfExpr -V ' | | 500 | cfg.swift:500:30:502:3 | Block | 'Block' | | 501 | cfg.swift:501:5:501:5 | x | 'x -> 1 -^ ... += ...' | @@ -399,9 +399,9 @@ | 517 | cfg.swift:517:29:519:3 | Block | 'Block' | | 518 | cfg.swift:518:5:518:5 | x | 'x -> 1 -^ ... += ...' | | 521 | cfg.swift:521:10:521:10 | x | 'x -^ ReturnExpr' | -| 524 | cfg.swift:524:1:538:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 524 | cfg.swift:524:1:538:1 | func testAsyncFor | 'func testAsyncFor' | | 524 | cfg.swift:524:28:538:1 | Block | 'Block' | -| 525 | cfg.swift:525:5:533:6 | VariableDeclaration | 'VariableDeclaration -V stream -> AsyncStream -> Argument -V Int -^ ... .self -> Argument -V . -^ ... .bufferingNewest -> Argument -V 5 -^ ... .bufferingNewest(...) -> Argument -V FunctionExpr -^ AsyncStream(...)' | +| 525 | cfg.swift:525:5:533:6 | var stream | 'var stream -V stream -> AsyncStream -> Argument -V Int -^ ... .self -> Argument -V . -^ ... .bufferingNewest -> Argument -V 5 -^ ... .bufferingNewest(...) -> Argument -V FunctionExpr -^ AsyncStream(...)' | | 526 | cfg.swift:526:9:526:20 | continuation | 'continuation' | | 527 | cfg.swift:527:13:532:13 | Block | 'Block -V Task -^ ... .detached -> Argument -V FunctionExpr -^ ... .detached(...)' | | 528 | cfg.swift:528:17:531:37 | Block | 'Block -V ForEachStmt -V 1 -> 100 -^ ... ... ...' | @@ -411,12 +411,12 @@ | 535 | cfg.swift:535:5:537:5 | ForEachStmt | 'ForEachStmt -V stream' | | 535 | cfg.swift:535:19:535:19 | i | 'i -> Block' | | 536 | cfg.swift:536:9:536:13 | print | 'print -> Argument -V i -^ print(...)' | -| 540 | cfg.swift:540:1:544:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 540 | cfg.swift:540:1:544:1 | func testNilCoalescing | 'func testNilCoalescing' | | 540 | cfg.swift:540:24:540:24 | x | 'x -> Block' | | 541 | cfg.swift:541:3:543:9 | ReturnExpr | 'ReturnExpr' | | 542 | cfg.swift:542:5:543:9 | ... ?? ... | '... ?? ... -V x' | | 543 | cfg.swift:543:9:543:9 | 0 | '0' | -| 546 | cfg.swift:546:1:553:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 546 | cfg.swift:546:1:553:1 | func testNilCoalescing2 | 'func testNilCoalescing2' | | 546 | cfg.swift:546:25:546:25 | x | 'x -> Block' | | 547 | cfg.swift:547:3:552:3 | IfExpr | 'IfExpr -V ... ?? ... -V x' | | 548 | cfg.swift:548:7:548:11 | false | 'false' | @@ -424,44 +424,44 @@ | 549 | cfg.swift:549:12:549:12 | 1 | '1 -^ ReturnExpr' | | 550 | cfg.swift:550:10:552:3 | Block | 'Block' | | 551 | cfg.swift:551:12:551:12 | 0 | '0 -^ ReturnExpr' | -| 555 | cfg.swift:555:1:557:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 555 | cfg.swift:555:1:557:1 | func usesAutoclosure | 'func usesAutoclosure' | | 555 | cfg.swift:555:24:555:27 | expr | 'expr -> Block' | | 556 | cfg.swift:556:10:556:13 | expr | 'expr -^ expr(...) -^ ReturnExpr' | -| 559 | cfg.swift:559:1:561:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 559 | cfg.swift:559:1:561:1 | func autoclosureTest | 'func autoclosureTest' | | 559 | cfg.swift:559:24:561:1 | Block | 'Block' | | 560 | cfg.swift:560:3:560:17 | usesAutoclosure | 'usesAutoclosure -> Argument -V 1 -^ usesAutoclosure(...)' | | 565 | cfg.swift:565:1:567:1 | protocol MyProtocol | 'protocol MyProtocol -V MyProtocol' | | 566 | cfg.swift:566:2:566:1 | Block | 'Block' | -| 566 | cfg.swift:566:2:566:21 | FunctionDeclaration | 'FunctionDeclaration' | +| 566 | cfg.swift:566:2:566:21 | func source | 'func source' | | 569 | cfg.swift:569:1:571:1 | class MyProcotolImpl | 'class MyProcotolImpl -V MyProcotolImpl -> BaseType -V MyProtocol' | -| 570 | cfg.swift:570:2:570:34 | FunctionDeclaration | 'FunctionDeclaration' | +| 570 | cfg.swift:570:2:570:34 | func source | 'func source' | | 570 | cfg.swift:570:23:570:34 | Block | 'Block -V 0 -^ ReturnExpr' | -| 573 | cfg.swift:573:1:573:62 | FunctionDeclaration | 'FunctionDeclaration' | +| 573 | cfg.swift:573:1:573:62 | func getMyProtocol | 'func getMyProtocol' | | 573 | cfg.swift:573:36:573:62 | Block | 'Block -V MyProcotolImpl -^ MyProcotolImpl(...) -^ ReturnExpr' | -| 574 | cfg.swift:574:1:574:70 | FunctionDeclaration | 'FunctionDeclaration' | +| 574 | cfg.swift:574:1:574:70 | func getMyProtocolImpl | 'func getMyProtocolImpl' | | 574 | cfg.swift:574:44:574:70 | Block | 'Block -V MyProcotolImpl -^ MyProcotolImpl(...) -^ ReturnExpr' | -| 576 | cfg.swift:576:1:576:23 | FunctionDeclaration | 'FunctionDeclaration' | +| 576 | cfg.swift:576:1:576:23 | func sink | 'func sink' | | 576 | cfg.swift:576:11:576:13 | arg | 'arg -> Block' | -| 578 | cfg.swift:578:1:583:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 578 | cfg.swift:578:1:583:1 | func testOpenExistentialExpr | 'func testOpenExistentialExpr' | | 578 | cfg.swift:578:30:578:30 | x | 'x -> y -> Block' | | 579 | cfg.swift:579:2:579:5 | sink | 'sink -> Argument -V x -^ ... .source -^ ... .source(...) -^ sink(...)' | | 580 | cfg.swift:580:2:580:5 | sink | 'sink -> Argument -V y -^ ... .source -^ ... .source(...) -^ sink(...)' | | 581 | cfg.swift:581:2:581:5 | sink | 'sink -> Argument -V getMyProtocol -^ getMyProtocol(...) -^ ... .source -^ ... .source(...) -^ sink(...)' | | 582 | cfg.swift:582:2:582:5 | sink | 'sink -> Argument -V getMyProtocolImpl -^ getMyProtocolImpl(...) -^ ... .source -^ ... .source(...) -^ sink(...)' | -| 585 | cfg.swift:585:1:593:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 585 | cfg.swift:585:1:593:1 | func singleStmtExpr | 'func singleStmtExpr' | | 585 | cfg.swift:585:23:585:23 | x | 'x -> Block' | -| 586 | cfg.swift:586:3:589:3 | VariableDeclaration | 'VariableDeclaration -V a -> SwitchExpr -V x' | +| 586 | cfg.swift:586:3:589:3 | let a | 'let a -V a -> SwitchExpr -V x' | | 587 | cfg.swift:587:5:587:17 | SwitchCase | 'SwitchCase -V 0 -> 5 -^ ... ..< ...' | | 587 | cfg.swift:587:17:587:17 | Block | 'Block -V 1' | | 588 | cfg.swift:588:5:588:14 | SwitchCase | 'SwitchCase -V Block -V 2' | -| 590 | cfg.swift:590:3:592:18 | VariableDeclaration | 'VariableDeclaration -V b' | +| 590 | cfg.swift:590:3:592:18 | let b | 'let b -V b' | | 591 | cfg.swift:591:9:592:18 | IfExpr | 'IfExpr -V x -> 42 -^ ... < ...' | | 591 | cfg.swift:591:21:591:25 | Block | 'Block -V 1' | | 592 | cfg.swift:592:14:592:18 | Block | 'Block -V 2' | | 596 | cfg.swift:596:1:598:1 | struct ValueGenericsStruct | 'struct ValueGenericsStruct -V ValueGenericsStruct -> TypeParameter -V N -> Int' | -| 597 | cfg.swift:597:5:597:13 | VariableDeclaration | 'VariableDeclaration -V x -> N' | -| 600 | cfg.swift:600:1:604:1 | FunctionDeclaration | 'FunctionDeclaration' | +| 597 | cfg.swift:597:5:597:13 | var x | 'var x -V x -> N' | +| 600 | cfg.swift:600:1:604:1 | func valueGenericsFn | 'func valueGenericsFn' | | 600 | cfg.swift:600:36:600:40 | value | 'value -> Block' | -| 601 | cfg.swift:601:5:601:13 | VariableDeclaration | 'VariableDeclaration -V x -> N' | +| 601 | cfg.swift:601:5:601:13 | var x | 'var x -V x -> N' | | 602 | cfg.swift:602:5:602:9 | print | 'print -> Argument -V x -^ print(...)' | | 603 | cfg.swift:603:5:603:5 | _ | '_ -> value -^ ... = ...' | diff --git a/unified/ql/test/library-tests/controlflow/cfg.expected b/unified/ql/test/library-tests/controlflow/cfg.expected index 7360b5d654ff..9ce119975f36 100644 --- a/unified/ql/test/library-tests/controlflow/cfg.expected +++ b/unified/ql/test/library-tests/controlflow/cfg.expected @@ -123,8 +123,8 @@ bbStep | cfg.swift:548:7:548:11 | false | 'false : false -> Block(+2)' | | cfg.swift:587:10:587:14 | ... ..< ... | '... ..< ... : match -> Block(+0)' | | cfg.swift:587:10:587:14 | ... ..< ... | '... ..< ... : no-match -> SwitchCase(+1)' | -| cfg.swift:587:17:587:17 | 1 | '1 : successor -> VariableDeclaration(+3)' | -| cfg.swift:588:14:588:14 | 2 | '2 : successor -> VariableDeclaration(+2)' | +| cfg.swift:587:17:587:17 | 1 | '1 : successor -> let b(+3)' | +| cfg.swift:588:14:588:14 | 2 | '2 : successor -> let b(+2)' | | cfg.swift:591:13:591:18 | ... < ... | '... < ... : false -> Block(+1)' | | cfg.swift:591:13:591:18 | ... < ... | '... < ... : true -> Block(+0)' | noCfg diff --git a/unified/ql/test/library-tests/controlflow/cfg.swift b/unified/ql/test/library-tests/controlflow/cfg.swift index a6dc9f7478ec..276064a962f6 100644 --- a/unified/ql/test/library-tests/controlflow/cfg.swift +++ b/unified/ql/test/library-tests/controlflow/cfg.swift @@ -584,8 +584,8 @@ func testOpenExistentialExpr(x: MyProtocol, y: MyProcotolImpl) { func singleStmtExpr(_ x: Int) { let a = switch x { - case 0..<5: 1 // $ bbStep='1 : successor -> VariableDeclaration(+3)' bbStep='... ..< ... : match -> Block(+0)' bbStep='... ..< ... : no-match -> SwitchCase(+1)' - default: 2 // $ bbStep='2 : successor -> VariableDeclaration(+2)' + case 0..<5: 1 // $ bbStep='1 : successor -> let b(+3)' bbStep='... ..< ... : match -> Block(+0)' bbStep='... ..< ... : no-match -> SwitchCase(+1)' + default: 2 // $ bbStep='2 : successor -> let b(+2)' } let b = if (x < 42) { 1 } // $ bbStep='... < ... : false -> Block(+1)' bbStep='... < ... : true -> Block(+0)'