From d6eb7bf2929e3ef131885387f791aef7e7ef47e9 Mon Sep 17 00:00:00 2001 From: Tom Hvitved Date: Wed, 2 Dec 2026 09:05:07 +0100 Subject: [PATCH 1/6] CFG: Include parameters as well as their patterns --- .../codeql/controlflow/ControlFlowGraph.qll | 48 ++++++++++++------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/shared/controlflow/codeql/controlflow/ControlFlowGraph.qll b/shared/controlflow/codeql/controlflow/ControlFlowGraph.qll index 285acb132fb1..0c6a274f2af8 100644 --- a/shared/controlflow/codeql/controlflow/ControlFlowGraph.qll +++ b/shared/controlflow/codeql/controlflow/ControlFlowGraph.qll @@ -55,9 +55,8 @@ signature module AstSig { /** * Gets the pattern associated with this parameter. * - * The pattern is included in the CFG while the parameter itself is not. - * Although, in simple cases that do not involve destructuring, it is - * allowed for the pattern to be equal to the parameter. + * The pattern, when present, is included in the CFG in addition to the + * parameter itself. */ AstNode getPattern(); @@ -777,8 +776,6 @@ module Make0 Ast> { n instanceof Case or n = any(Case case).getPattern(_) - or - exists(Parameter p | exists(p.getDefaultValue()) and n = p.getPattern()) ) } @@ -802,6 +799,8 @@ module Make0 Ast> { private string patternMatchTrueTag() { result = "[MatchTrue]" } + private string parameterDefaultValueTag() { result = "[ParameterDefaultValue]" } + /** * Holds if an additional node tagged with `tag` should be created for * `n`. Edges targeting such nodes are labeled with `t` and therefore `t` @@ -824,6 +823,10 @@ module Make0 Ast> { n instanceof PatternMatchExpr and tag = patternMatchTrueTag() and t.(BooleanSuccessor).getValue() = true + or + n = any(Parameter p | exists(p.getDefaultValue())) and + tag = parameterDefaultValueTag() and + t.(MatchingSuccessor).getValue() = false } /** @@ -983,10 +986,7 @@ module Make0 Ast> { ) } - private predicate hasCfg(AstNode n) { - exists(getEnclosingCallable(n)) and - (n instanceof Parameter implies n = n.(Parameter).getPattern()) - } + private predicate hasCfg(AstNode n) { exists(getEnclosingCallable(n)) } cached private newtype TNode = @@ -1529,7 +1529,7 @@ module Make0 Ast> { pragma[nomagic] private AstNode getParameterPatternOrBodyEntry(Callable c, CallableContextOption ctx, int i) { - result = getRankedParameter(c, ctx, i).getPattern() + result = getRankedParameter(c, ctx, i) or ( not exists(getRankedParameter(c, _, _)) and @@ -1562,14 +1562,28 @@ module Make0 Ast> { n2.isBefore(getParameterPatternOrBodyEntry(c, _, 1)) or exists(CallableContextOption ctx, Parameter p, int i | p = getRankedParameter(c, ctx, i) | - exists(MatchingSuccessor t | - n1.isAfterValue(p.getPattern(), t) and - if t.isMatch() - then n2.isBefore(getParameterPatternOrBodyEntry(c, ctx, i + 1)) - else n2.isBefore(p.getDefaultValue()) + n1.isBefore(p) and + n2.isAdditional(p, parameterDefaultValueTag()) + or + n1.isAdditional(p, parameterDefaultValueTag()) and + n2.isBefore(p.getDefaultValue()) + or + ( + n1.isBefore(p) + or + n1.isAfter(p.getDefaultValue()) + ) and + ( + n2.isBefore(p.getPattern()) + or + not exists(p.getPattern()) and + n2.isAfter(p) ) or - n1.isAfter(p.getDefaultValue()) and + n1.isAfter(p.getPattern()) and + n2.isAfter(p) + or + n1.isAfter(p) and n2.isBefore(getParameterPatternOrBodyEntry(c, ctx, i + 1)) ) or @@ -2606,7 +2620,7 @@ module Make0 Ast> { succ2 = node.getASuccessor(t2) and // allow for the pattern match true edge when a pattern match // expression is not in a conditional context - not succ1.isAdditional(_, patternMatchTrueTag()) + not succ1.isAdditional(_, [patternMatchTrueTag(), parameterDefaultValueTag()]) } /** From 74b6b8adcbe8ca339ae04031c2752f606b4c4763 Mon Sep 17 00:00:00 2001 From: Tom Hvitved Date: Wed, 2 Dec 2026 09:06:36 +0100 Subject: [PATCH 2/6] Unified: Update `Parameter.getPattern()` --- .../unified/internal/ControlFlowGraph.qll | 6 +- .../controlflow/basicblock-slices.expected | 100 +++++++++--------- .../library-tests/controlflow/cfg.expected | 8 +- .../test/library-tests/controlflow/cfg.swift | 4 +- 4 files changed, 57 insertions(+), 61 deletions(-) diff --git a/unified/ql/lib/codeql/unified/internal/ControlFlowGraph.qll b/unified/ql/lib/codeql/unified/internal/ControlFlowGraph.qll index 165cf5300c2c..a5da546d3060 100644 --- a/unified/ql/lib/codeql/unified/internal/ControlFlowGraph.qll +++ b/unified/ql/lib/codeql/unified/internal/ControlFlowGraph.qll @@ -63,11 +63,7 @@ module Ast implements AstSig { class Parameter extends U::Parameter { Expr getDefaultValue() { result = super.getDefault() } - AstNode getPattern() { - result = super.getPattern() - or - not exists(super.getPattern()) and result = this - } + AstNode getPattern() { result = super.getPattern() } } Parameter callableGetParameter(Callable c, int index) { diff --git a/unified/ql/test/library-tests/controlflow/basicblock-slices.expected b/unified/ql/test/library-tests/controlflow/basicblock-slices.expected index df7e456642ac..dbf8a6596515 100644 --- a/unified/ql/test/library-tests/controlflow/basicblock-slices.expected +++ b/unified/ql/test/library-tests/controlflow/basicblock-slices.expected @@ -1,6 +1,6 @@ | 1 | cfg.swift:1:1:635:1 | Block | 'Block -V var topLevelDecl -V topLevelDecl -> Int -> 0' | | 1 | fallthrough.swift:1:1:57:1 | Block | 'Block -V func fallthroughChain -V fallthroughChain' | -| 1 | fallthrough.swift:1:25:1:25 | x | 'x -> flag -> Block' | +| 1 | fallthrough.swift:1:23:1:30 | Parameter | 'Parameter -V x -> Parameter -V flag -> Block' | | 2 | cfg.swift:2:1:2:1 | 0 | '0' | | 2 | fallthrough.swift:2:3:18:3 | SwitchExpr | 'SwitchExpr -V x' | | 3 | cfg.swift:3:1:3:12 | topLevelDecl | 'topLevelDecl -> 1 -^ ... + ...' | @@ -19,24 +19,24 @@ | 11 | cfg.swift:11:10:11:15 | MyError.error1 | 'MyError.error1 -V error1 -> MyError.error2 -V error2' | | 11 | fallthrough.swift:11:5:12:15 | Block | 'Block -V print -> Argument -V "second case" -^ print(...)' | | 12 | cfg.swift:12:10:12:31 | MyError.error3 | 'MyError.error3 -V error3 -^ MyError.error3.(constructor)' | -| 12 | cfg.swift:12:17:12:25 | withParam | 'withParam -? Block' | +| 12 | cfg.swift:12:17:12:30 | Parameter | 'Parameter -V withParam -? Block' | | 12 | fallthrough.swift:12:5:12:15 | fallthrough | 'fallthrough' | | 13 | fallthrough.swift:13:3:15:15 | SwitchCase | 'SwitchCase -V 2' | | 14 | fallthrough.swift:14:5:15:15 | Block | 'Block -V print -> Argument -V "third case" -^ print(...)' | | 15 | cfg.swift:15:1:17:1 | func isZero | 'func isZero -V isZero' | -| 15 | cfg.swift:15:13:15:13 | x | 'x -> Block' | +| 15 | cfg.swift:15:13:15:19 | Parameter | 'Parameter -V x -> Block' | | 15 | fallthrough.swift:15:5:15:15 | fallthrough | 'fallthrough' | | 16 | cfg.swift:16:10:16:10 | x | 'x -> 0 -^ ... == ... -^ ReturnExpr' | | 16 | fallthrough.swift:16:3:17:25 | SwitchCase | 'SwitchCase' | | 17 | fallthrough.swift:17:5:17:25 | Block | 'Block -V print -> Argument -V "default case" -^ print(...)' | | 19 | cfg.swift:19:1:26:1 | func mightThrow | 'func mightThrow -V mightThrow' | -| 19 | cfg.swift:19:17:19:17 | x | 'x -> Block' | +| 19 | cfg.swift:19:17:19:23 | Parameter | 'Parameter -V x -> Block' | | 19 | fallthrough.swift:19:3:19:7 | print | 'print -> Argument -V "after switch" -^ print(...)' | | 20 | cfg.swift:20:3:22:3 | GuardIfStmt | 'GuardIfStmt -V x -> 0 -^ ... >= ...' | | 20 | cfg.swift:20:21:22:3 | Block | 'Block' | | 21 | cfg.swift:21:11:21:17 | MyError | 'MyError -^ ... .error1 -^ ThrowExpr' | | 22 | fallthrough.swift:22:1:37:1 | func nestedFallthrough | 'func nestedFallthrough -V nestedFallthrough' | -| 22 | fallthrough.swift:22:26:22:26 | x | 'x -> y -> Block' | +| 22 | fallthrough.swift:22:24:22:31 | Parameter | 'Parameter -V x -> Parameter -V y -> Block' | | 23 | cfg.swift:23:3:25:3 | GuardIfStmt | 'GuardIfStmt -V x -> 0 -^ ... <= ...' | | 23 | cfg.swift:23:21:25:3 | Block | 'Block' | | 23 | fallthrough.swift:23:3:35:3 | SwitchExpr | 'SwitchExpr -V x' | @@ -46,7 +46,7 @@ | 26 | fallthrough.swift:26:5:27:17 | SwitchCase | 'SwitchCase -V 0' | | 27 | fallthrough.swift:27:7:27:17 | Block | 'Block -V fallthrough' | | 28 | cfg.swift:28:1:45:1 | func tryCatch | 'func tryCatch -V tryCatch' | -| 28 | cfg.swift:28:15:28:15 | x | 'x -> Block' | +| 28 | cfg.swift:28:15:28:21 | Parameter | 'Parameter -V x -> Block' | | 28 | fallthrough.swift:28:5:29:28 | SwitchCase | 'SwitchCase' | | 29 | cfg.swift:29:3:43:3 | TryExpr | 'TryExpr -V Block' | | 29 | fallthrough.swift:29:7:29:28 | Block | 'Block -V print -> Argument -V "inner default" -^ print(...)' | @@ -69,7 +69,7 @@ | 39 | cfg.swift:39:5:41:3 | CatchClause | 'CatchClause -V ' | | 39 | cfg.swift:39:22:41:3 | Block | 'Block' | | 39 | fallthrough.swift:39:1:57:1 | func fallthroughWithDefer | 'func fallthroughWithDefer -V fallthroughWithDefer' | -| 39 | fallthrough.swift:39:29:39:29 | x | 'x -> flag -> Block' | +| 39 | fallthrough.swift:39:27:39:34 | Parameter | 'Parameter -V x -> Parameter -V flag -> Block' | | 40 | cfg.swift:40:5:40:9 | print | 'print -> Argument -V "MyError" -^ print(...)' | | 40 | fallthrough.swift:40:3:55:3 | SwitchExpr | 'SwitchExpr -V x' | | 41 | cfg.swift:41:5:43:3 | CatchClause | 'CatchClause -V Block' | @@ -83,7 +83,7 @@ | 46 | fallthrough.swift:46:7:48:7 | DeferStmt | 'DeferStmt' | | 46 | fallthrough.swift:46:13:48:7 | Block | 'Block' | | 47 | cfg.swift:47:1:51:1 | func createClosure1 | 'func createClosure1 -V createClosure1' | -| 47 | cfg.swift:47:21:47:21 | s | 's -> Block' | +| 47 | cfg.swift:47:21:47:30 | Parameter | 'Parameter -V s -> Block' | | 47 | fallthrough.swift:47:9:47:13 | print | 'print -> Argument -V "inner defer" -^ print(...)' | | 48 | cfg.swift:48:10:50:3 | FunctionExpr | 'FunctionExpr -^ ReturnExpr' | | 49 | cfg.swift:49:5:49:17 | Block | 'Block -V s -> "" -^ ... + ... -^ ReturnExpr' | @@ -91,25 +91,25 @@ | 51 | fallthrough.swift:51:3:52:22 | SwitchCase | 'SwitchCase -V flag -? 1 -^ ConditionalPattern' | | 52 | fallthrough.swift:52:5:52:22 | Block | 'Block -V print -> Argument -V "next case" -^ print(...)' | | 53 | cfg.swift:53:1:58:1 | func createClosure2 | 'func createClosure2 -V createClosure2' | -| 53 | cfg.swift:53:21:53:21 | x | 'x -> Block' | +| 53 | cfg.swift:53:21:53:27 | Parameter | 'Parameter -V x -> Block' | | 53 | fallthrough.swift:53:3:54:9 | SwitchCase | 'SwitchCase' | | 54 | cfg.swift:54:3:56:3 | func f | 'func f -V f' | -| 54 | cfg.swift:54:10:54:10 | y | 'y -> Block' | +| 54 | cfg.swift:54:10:54:16 | Parameter | 'Parameter -V y -> Block' | | 54 | fallthrough.swift:54:5:54:9 | Block | 'Block -V BreakExpr' | | 55 | cfg.swift:55:12:55:12 | x | 'x -> y -^ ... + ... -^ ReturnExpr' | | 56 | fallthrough.swift:56:3:56:7 | print | 'print -> Argument -V "after deferred fallthrough" -^ print(...)' | | 57 | cfg.swift:57:10:57:10 | f | 'f -^ ReturnExpr' | | 60 | cfg.swift:60:1:64:1 | func createClosure3 | 'func createClosure3 -V createClosure3' | -| 60 | cfg.swift:60:21:60:21 | x | 'x -> Block' | +| 60 | cfg.swift:60:21:60:27 | Parameter | 'Parameter -V 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 -^ ... + ...' | +| 62 | cfg.swift:62:6:62:6 | Parameter | 'Parameter -V y -> Block -V x -> y -^ ... + ...' | | 66 | cfg.swift:66:1:70:1 | func callClosures | 'func callClosures -V callClosures' | | 66 | cfg.swift:66:21:70:1 | Block | 'Block' | | 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 -V maybeParseInt' | -| 72 | cfg.swift:72:20:72:20 | s | 's -> Block' | +| 72 | cfg.swift:72:20:72:29 | Parameter | 'Parameter -V s -> Block' | | 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 | func forceAndBackToOptional | 'func forceAndBackToOptional -V forceAndBackToOptional' | @@ -121,10 +121,10 @@ | 83 | cfg.swift:83:25:98:1 | Block | 'Block' | | 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 -V add' | -| 86 | cfg.swift:86:12:86:12 | a | 'a -> Block' | +| 86 | cfg.swift:86:12:86:23 | Parameter | 'Parameter -V a -> Block' | | 87 | cfg.swift:87:5:87:5 | a | 'a -> a -> 1 -^ ... + ... -^ ... = ...' | | 90 | cfg.swift:90:3:92:3 | func addOptional | 'func addOptional -V addOptional' | -| 90 | cfg.swift:90:20:90:20 | a | 'a -> Block' | +| 90 | cfg.swift:90:20:90:32 | Parameter | 'Parameter -V a -> Block' | | 91 | cfg.swift:91:5:91:5 | a | 'a -> nil -^ ... = ...' | | 94 | cfg.swift:94:3:94:5 | add | 'add -> Argument -V temp -^ & ... -^ add(...)' | | 95 | cfg.swift:95:3:95:30 | var tempOptional | 'var tempOptional -V tempOptional -> Optional -> Int -^ GenericTypeExpr -> 10' | @@ -133,13 +133,13 @@ | 100 | cfg.swift:100:1:109:1 | class C | 'class C -V C' | | 101 | cfg.swift:101:3:101:16 | let C.myInt | 'let C.myInt -V myInt -> Int' | | 102 | cfg.swift:102:3:104:3 | C.init | 'C.init' | -| 102 | cfg.swift:102:8:102:8 | n | 'n -> Block' | +| 102 | cfg.swift:102:8:102:13 | Parameter | 'Parameter -V n -> Block' | | 103 | cfg.swift:103:5:103:9 | myInt | 'myInt -> n -^ ... = ...' | | 106 | cfg.swift:106:3:108:3 | func C.getMyInt | 'func C.getMyInt -V 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 | func testMemberRef | 'func testMemberRef -V testMemberRef' | -| 111 | cfg.swift:111:20:111:24 | param | 'param -> inoutParam -> opt -> Block' | +| 111 | cfg.swift:111:20:111:28 | Parameter | 'Parameter -V param -> Parameter -V inoutParam -> Parameter -V opt -> Block' | | 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' | @@ -162,7 +162,7 @@ | 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:173:1 | func patterns | 'func patterns -V patterns' | -| 139 | cfg.swift:139:15:139:15 | x | 'x -> Block' | +| 139 | cfg.swift:139:15:139:21 | Parameter | 'Parameter -V x -> Block' | | 140 | cfg.swift:140:3:141:12 | ForEachStmt | 'ForEachStmt -V 0 -> 10 -^ ... ... ...' | | 140 | cfg.swift:140:7:140:7 | _ | '_' | | 141 | cfg.swift:141:9:141:12 | Block | 'Block' | @@ -195,7 +195,7 @@ | 170 | cfg.swift:170:10:172:3 | Block | 'Block' | | 171 | cfg.swift:171:12:171:16 | false | 'false -^ ReturnExpr' | | 175 | cfg.swift:175:1:193:1 | func testDefer | 'func testDefer -V testDefer' | -| 175 | cfg.swift:175:16:175:16 | x | 'x -> Block' | +| 175 | cfg.swift:175:16:175:28 | Parameter | 'Parameter -V x -> Block' | | 177 | cfg.swift:177:3:179:3 | DeferStmt | 'DeferStmt' | | 177 | cfg.swift:177:9:179:3 | Block | 'Block' | | 178 | cfg.swift:178:5:178:9 | print | 'print -> Argument -V "6" -^ print(...)' | @@ -209,7 +209,7 @@ | 189 | cfg.swift:189:5:191:5 | DeferStmt | 'DeferStmt -V Block' | | 190 | cfg.swift:190:7:190:11 | print | 'print -> Argument -V "4" -^ print(...)' | | 195 | cfg.swift:195:1:207:1 | func m1 | 'func m1 -V m1' | -| 195 | cfg.swift:195:9:195:9 | x | 'x -> Block' | +| 195 | cfg.swift:195:9:195:15 | Parameter | 'Parameter -V x -> Block' | | 196 | cfg.swift:196:3:206:3 | IfExpr | 'IfExpr -V x -> 2 -^ ... > ...' | | 196 | cfg.swift:196:12:198:3 | Block | 'Block' | | 197 | cfg.swift:197:5:197:9 | print | 'print -> Argument -V "x is greater than 2" -^ print(...)' | @@ -221,15 +221,15 @@ | 204 | cfg.swift:204:8:206:3 | Block | 'Block' | | 205 | cfg.swift:205:5:205:9 | print | 'print -> Argument -V "I can't guess the number" -^ print(...)' | | 209 | cfg.swift:209:1:214:1 | func m2 | 'func m2 -V m2' | -| 209 | cfg.swift:209:9:209:9 | b | 'b' | +| 209 | cfg.swift:209:9:209:9 | b | 'b -> Block' | +| 209 | cfg.swift:209:9:209:24 | Parameter | 'Parameter' | | 209 | cfg.swift:209:20:209:24 | false | 'false' | -| 209 | cfg.swift:209:34:214:1 | Block | 'Block' | | 210 | cfg.swift:210:3:212:3 | IfExpr | 'IfExpr -V b' | | 210 | cfg.swift:210:8:212:3 | Block | 'Block' | | 211 | cfg.swift:211:12:211:12 | 0 | '0 -^ ReturnExpr' | | 213 | cfg.swift:213:10:213:10 | 1 | '1 -^ ReturnExpr' | | 216 | cfg.swift:216:1:224:1 | func m3 | 'func m3 -V m3' | -| 216 | cfg.swift:216:9:216:9 | x | 'x -> Block' | +| 216 | cfg.swift:216:9:216:21 | Parameter | 'Parameter -V x -> Block' | | 217 | cfg.swift:217:3:222:3 | IfExpr | 'IfExpr -V x -> 0 -^ ... < ...' | | 217 | cfg.swift:217:12:222:3 | Block | 'Block' | | 218 | cfg.swift:218:5:218:5 | x | 'x -> x -^ - ... -^ ... = ...' | @@ -238,7 +238,7 @@ | 220 | cfg.swift:220:7:220:7 | x | 'x -> x -> 1 -^ ... - ... -^ ... = ...' | | 223 | cfg.swift:223:10:223:10 | x | 'x -^ ReturnExpr' | | 226 | cfg.swift:226:1:232:1 | func m4 | 'func m4 -V m4' | -| 226 | cfg.swift:226:10:226:11 | b1 | 'b1 -> b2 -> b3 -> Block' | +| 226 | cfg.swift:226:10:226:18 | Parameter | 'Parameter -V b1 -> Parameter -V b2 -> Parameter -V b3 -> Block' | | 227 | cfg.swift:227:3:231:20 | ReturnExpr | 'ReturnExpr' | | 227 | cfg.swift:227:10:231:20 | IfExpr | 'IfExpr -V IfExpr -V b1' | | 228 | cfg.swift:228:13:228:14 | b2 | 'b2' | @@ -246,7 +246,7 @@ | 230 | cfg.swift:230:9:230:18 | "b2 \|\| b3" | '"b2 \|\| b3"' | | 231 | cfg.swift:231:9:231:20 | "!b2 \|\| !b3" | '"!b2 \|\| !b3"' | | 234 | cfg.swift:234:1:243:1 | func conversionsInSplitEntry | 'func conversionsInSplitEntry -V conversionsInSplitEntry' | -| 234 | cfg.swift:234:31:234:31 | b | 'b -> Block' | +| 234 | cfg.swift:234:31:234:38 | Parameter | 'Parameter -V b -> Block' | | 235 | cfg.swift:235:3:242:3 | IfExpr | 'IfExpr -V IfExpr -V b' | | 236 | cfg.swift:236:8:236:11 | true | 'true' | | 237 | cfg.swift:237:7:237:10 | Bool | 'Bool -> Argument -V false -^ Bool(...)' | @@ -258,20 +258,20 @@ | 245 | cfg.swift:245:27:249:1 | Block | 'Block' | | 246 | cfg.swift:246:3:248:3 | IfExpr | 'IfExpr -V ! ... -V true' | | 251 | cfg.swift:251:1:257:1 | func empty_else | 'func empty_else -V empty_else' | -| 251 | cfg.swift:251:17:251:17 | b | 'b -> Block' | +| 251 | cfg.swift:251:17:251:24 | Parameter | 'Parameter -V b -> Block' | | 252 | cfg.swift:252:3:255:9 | IfExpr | 'IfExpr -V b' | | 252 | cfg.swift:252:8:254:3 | Block | 'Block' | | 253 | cfg.swift:253:5:253:9 | print | 'print -> Argument -V "true" -^ print(...)' | | 255 | cfg.swift:255:8:255:9 | Block | 'Block' | | 256 | cfg.swift:256:3:256:7 | print | 'print -> Argument -V "done" -^ print(...)' | | 259 | cfg.swift:259:1:263:1 | func disjunct | 'func disjunct -V disjunct' | -| 259 | cfg.swift:259:16:259:17 | b1 | 'b1 -> b2 -> Block' | +| 259 | cfg.swift:259:16:259:24 | Parameter | 'Parameter -V b1 -> Parameter -V b2 -> Block' | | 260 | cfg.swift:260:3:262:3 | IfExpr | 'IfExpr -V ... \|\| ... -V b1' | | 260 | cfg.swift:260:13:260:14 | b2 | 'b2' | | 260 | cfg.swift:260:17:262:3 | Block | 'Block' | | 261 | cfg.swift:261:5:261:9 | print | 'print -> Argument -V "b1 or b2" -^ print(...)' | | 265 | cfg.swift:265:1:282:1 | func binaryExprs | 'func binaryExprs -V binaryExprs' | -| 265 | cfg.swift:265:18:265:18 | a | 'a -> b -> Block' | +| 265 | cfg.swift:265:18:265:24 | Parameter | 'Parameter -V a -> Parameter -V b -> Block' | | 266 | cfg.swift:266:3:266:15 | let c | 'let c -V c -> a -> b -^ ... + ...' | | 267 | cfg.swift:267:3:267:15 | let d | 'let d -V d -> a -> b -^ ... - ...' | | 268 | cfg.swift:268:3:268:15 | let e | 'let e -V e -> a -> b -^ ... * ...' | @@ -289,7 +289,7 @@ | 280 | cfg.swift:280:3:280:15 | let s | 'let s -V s -> a -> b -^ ... > ...' | | 281 | cfg.swift:281:3:281:16 | let t | 'let t -V t -> a -> b -^ ... >= ...' | | 284 | cfg.swift:284:1:286:1 | func interpolatedString | 'func interpolatedString -V interpolatedString' | -| 284 | cfg.swift:284:25:284:25 | x | 'x -> y -> Block' | +| 284 | cfg.swift:284:25:284:31 | Parameter | 'Parameter -V x -> Parameter -V y -> Block' | | 285 | cfg.swift:285:11:285: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' | | 288 | cfg.swift:288:1:319:1 | func testSubscriptExpr | 'func testSubscriptExpr -V testSubscriptExpr' | | 288 | cfg.swift:288:55:319:1 | Block | 'Block' | @@ -321,14 +321,14 @@ | 317 | cfg.swift:317:3:317:39 | let (pattern assignment) | 'let (pattern assignment) -V Argument -V a1 -> Argument -V a2 -> Argument -V a3 -> Argument -V a4 -> Argument -V a5 -^ TupleExpr -> tupleWithA' | | 318 | cfg.swift:318:11:318:19 | Argument | 'Argument -V a1 -> b -^ ... .subscript -> Argument -V 0 -^ ... .subscript(...) -^ ... + ... -> Argument -V a2 -> b -^ ... .subscript -> Argument -V 1 -^ ... .subscript(...) -^ ... + ... -> Argument -V a3 -> b -^ ... .subscript -> Argument -V 2 -^ ... .subscript(...) -^ ... + ... -> Argument -V a4 -> b -^ ... .subscript -> Argument -V 3 -^ ... .subscript(...) -^ ... + ... -> Argument -V a5 -> b -^ ... .subscript -> Argument -V 4 -^ ... .subscript(...) -^ ... + ... -^ TupleExpr -^ ReturnExpr' | | 321 | cfg.swift:321:1:326:1 | func loop1 | 'func loop1 -V loop1' | -| 321 | cfg.swift:321:12:321:12 | x | 'x -> Block' | +| 321 | cfg.swift:321:12:321:24 | Parameter | 'Parameter -V x -> Block' | | 322 | cfg.swift:322:3:325:3 | WhileStmt | 'WhileStmt' | | 322 | cfg.swift:322:9:322:9 | x | 'x -> 0 -^ ... >= ...' | | 322 | cfg.swift:322:16:325:3 | Block | 'Block' | | 323 | cfg.swift:323:5:323:9 | print | 'print -> Argument -V x -^ print(...)' | | 324 | cfg.swift:324:5:324:5 | x | 'x -> 1 -^ ... -= ...' | | 328 | cfg.swift:328:1:341:1 | func loop2 | 'func loop2 -V loop2' | -| 328 | cfg.swift:328:12:328:12 | x | 'x -> Block' | +| 328 | cfg.swift:328:12:328:24 | Parameter | 'Parameter -V x -> Block' | | 329 | cfg.swift:329:3:339:3 | WhileStmt | 'WhileStmt' | | 329 | cfg.swift:329:9:329:9 | x | 'x -> 0 -^ ... >= ...' | | 329 | cfg.swift:329:16:339:3 | Block | 'Block' | @@ -343,7 +343,7 @@ | 338 | cfg.swift:338:5:338:9 | print | 'print -> Argument -V "Iter" -^ print(...)' | | 340 | cfg.swift:340:3:340:7 | print | 'print -> Argument -V "Done" -^ print(...)' | | 343 | cfg.swift:343:1:358:1 | func labeledLoop | 'func labeledLoop -V labeledLoop' | -| 343 | cfg.swift:343:18:343:18 | x | 'x -> Block' | +| 343 | cfg.swift:343:18:343:30 | Parameter | 'Parameter -V x -> Block' | | 344 | cfg.swift:344:3:357:3 | LabeledStmt | 'LabeledStmt -V WhileStmt' | | 344 | cfg.swift:344:16:344:16 | x | 'x -> 0 -^ ... >= ...' | | 344 | cfg.swift:344:23:357:3 | Block | 'Block' | @@ -361,7 +361,7 @@ | 354 | cfg.swift:354:7:354:11 | print | 'print -> Argument -V "Iter" -^ print(...)' | | 356 | cfg.swift:356:5:356:9 | print | 'print -> Argument -V "Done" -^ print(...)' | | 360 | cfg.swift:360:1:365:1 | func testRepeat | 'func testRepeat -V testRepeat' | -| 360 | cfg.swift:360:17:360:17 | x | 'x -> Block' | +| 360 | cfg.swift:360:17:360:29 | Parameter | 'Parameter -V x -> Block' | | 361 | cfg.swift:361:3:364:16 | DoWhileStmt | 'DoWhileStmt' | | 361 | cfg.swift:361:10:364:3 | Block | 'Block' | | 362 | cfg.swift:362:5:362:9 | print | 'print -> Argument -V x -^ print(...)' | @@ -377,27 +377,27 @@ | 374 | cfg.swift:374:1:383:1 | class OptionalC | 'class OptionalC -V OptionalC' | | 375 | cfg.swift:375:3:375:11 | let OptionalC.c | 'let OptionalC.c -V c -> Optional -> C -^ GenericTypeExpr' | | 376 | cfg.swift:376:3:378:3 | OptionalC.init | 'OptionalC.init' | -| 376 | cfg.swift:376:8:376:10 | arg | 'arg -> Block' | +| 376 | cfg.swift:376:8:376:14 | Parameter | 'Parameter -V arg -> Block' | | 377 | cfg.swift:377:5:377:5 | c | 'c -> arg -^ ... = ...' | | 380 | cfg.swift:380:3:382:3 | func OptionalC.getOptional | 'func OptionalC.getOptional -V getOptional' | | 380 | cfg.swift:380:28:382:3 | Block | 'Block' | | 381 | cfg.swift:381:12:381:12 | c | 'c -^ ReturnExpr' | | 385 | cfg.swift:385:1:387:1 | func testOptional | 'func testOptional -V testOptional' | -| 385 | cfg.swift:385:19:385:19 | c | 'c -> Block' | +| 385 | cfg.swift:385:19:385:32 | Parameter | 'Parameter -V c -> Block' | | 386 | cfg.swift:386:10:386:10 | c | 'c -^ ... .getOptional -^ ... .getOptional(...) -^ ... .getMyInt -^ ... .getMyInt(...) -^ ReturnExpr' | | 389 | cfg.swift:389:1:393:1 | func testCapture | 'func testCapture -V testCapture' | -| 389 | cfg.swift:389:18:389:18 | x | 'x -> y -> Block' | +| 389 | cfg.swift:389:18:389:24 | Parameter | 'Parameter -V x -> Parameter -V y -> Block' | | 390 | cfg.swift:390:13:390:21 | z | 'z -V z -> x -> y -^ ... + ... -> t -V t -> "literal" -^ FunctionExpr -^ ReturnExpr' | | 391 | cfg.swift:391:5:391:12 | Block | 'Block -V z -^ ReturnExpr' | | 395 | cfg.swift:395:1:397:1 | func testTupleElement | 'func testTupleElement -V testTupleElement' | -| 395 | cfg.swift:395:23:395:23 | t | 't -> Block' | +| 395 | cfg.swift:395:23:395:47 | Parameter | 'Parameter -V t -> Block' | | 396 | cfg.swift:396:10:396:10 | t | 't -^ ... .a -> t -^ ... .1 -^ ... + ... -> t -^ ... .c -^ ... + ... -> Argument -V 1 -> Argument -V 2 -> Argument -V 3 -^ TupleExpr -^ ... .0 -^ ... + ... -^ ReturnExpr' | | 399 | cfg.swift:399:1:403:1 | class Derived | 'class Derived -V Derived -> BaseType -V C' | | 400 | cfg.swift:400:3:402:3 | Derived.init | 'Derived.init' | | 400 | cfg.swift:400:10:402:3 | Block | 'Block' | | 401 | cfg.swift:401:5:401:9 | super | 'super -^ ... .init -> Argument -V 0 -^ ... .init(...)' | | 405 | cfg.swift:405:1:413:1 | func doWithoutCatch | 'func doWithoutCatch -V doWithoutCatch' | -| 405 | cfg.swift:405:21:405:21 | x | 'x -> Block' | +| 405 | cfg.swift:405:21:405:27 | Parameter | 'Parameter -V x -> Block' | | 406 | cfg.swift:406:3:411:3 | TryExpr | 'TryExpr -V Block' | | 407 | cfg.swift:407:5:407:24 | try ... | 'try ...' | | 407 | cfg.swift:407:9:407:18 | mightThrow | 'mightThrow -> Argument -V 0 -^ mightThrow(...)' | @@ -414,7 +414,7 @@ | 421 | cfg.swift:421:10:423:3 | Block | 'Block' | | 422 | cfg.swift:422:5:422:9 | field | 'field -> 0 -^ ... = ...' | | 426 | cfg.swift:426:1:428:1 | func dictionaryLiteral | 'func dictionaryLiteral -V dictionaryLiteral' | -| 426 | cfg.swift:426:24:426:24 | x | 'x -> y -> Block' | +| 426 | cfg.swift:426:24:426:29 | Parameter | 'Parameter -V x -> Parameter -V y -> Block' | | 427 | cfg.swift:427:11:427:13 | "x" | '"x" -> x -^ KeyValuePair -> "y" -> y -^ KeyValuePair -^ MapLiteral -^ ReturnExpr' | | 430 | cfg.swift:430:1:453:1 | func localDeclarations | 'func localDeclarations -V localDeclarations' | | 430 | cfg.swift:430:33:453:1 | Block | 'Block' | @@ -440,7 +440,7 @@ | 461 | cfg.swift:461:3:461:14 | var A.bs | 'var A.bs -V bs -> Array -> B -^ GenericTypeExpr' | | 462 | cfg.swift:462:3:462:15 | var A.mayB | 'var A.mayB -V mayB -> Optional -> B -^ GenericTypeExpr' | | 465 | cfg.swift:465:1:475:1 | func test | 'func test -V test' | -| 465 | cfg.swift:465:11:465:11 | a | 'a -> Block' | +| 465 | cfg.swift:465:11:465:15 | Parameter | 'Parameter -V a -> Block' | | 466 | cfg.swift:466:3:466:24 | var kpGet_b_x | 'var kpGet_b_x -V kpGet_b_x -> ' | | 467 | cfg.swift:467:3:467:31 | var kpGet_bs_0_x | 'var kpGet_bs_0_x -V kpGet_bs_0_x -> ' | | 468 | cfg.swift:468:3:468:37 | var kpGet_mayB_force_x | 'var kpGet_mayB_force_x -V kpGet_mayB_force_x -> ' | @@ -492,7 +492,7 @@ | 533 | cfg.swift:533:1:547:1 | func testAsyncFor | 'func testAsyncFor -V testAsyncFor' | | 533 | cfg.swift:533:28:547:1 | Block | 'Block' | | 534 | cfg.swift:534:5:542:6 | var stream | 'var stream -V stream -> AsyncStream -> Argument -V Int -^ ... .self -> Argument -V . -^ ... .bufferingNewest -> Argument -V 5 -^ ... .bufferingNewest(...) -> Argument -V FunctionExpr -^ AsyncStream(...)' | -| 535 | cfg.swift:535:9:535:20 | continuation | 'continuation' | +| 535 | cfg.swift:535:9:535:20 | Parameter | 'Parameter -V continuation' | | 536 | cfg.swift:536:13:541:13 | Block | 'Block -V Task -^ ... .detached -> Argument -V FunctionExpr -^ ... .detached(...)' | | 537 | cfg.swift:537:17:540:37 | Block | 'Block -V ForEachStmt -V 1 -> 100 -^ ... ... ...' | | 537 | cfg.swift:537:21:537:21 | i | 'i -> Block' | @@ -502,12 +502,12 @@ | 544 | cfg.swift:544:19:544:19 | i | 'i -> Block' | | 545 | cfg.swift:545:9:545:13 | print | 'print -> Argument -V i -^ print(...)' | | 549 | cfg.swift:549:1:553:1 | func testNilCoalescing | 'func testNilCoalescing -V testNilCoalescing' | -| 549 | cfg.swift:549:24:549:24 | x | 'x -> Block' | +| 549 | cfg.swift:549:24:549:30 | Parameter | 'Parameter -V x -> Block' | | 550 | cfg.swift:550:3:552:9 | ReturnExpr | 'ReturnExpr' | | 551 | cfg.swift:551:5:552:9 | ... ?? ... | '... ?? ... -V x' | | 552 | cfg.swift:552:9:552:9 | 0 | '0' | | 555 | cfg.swift:555:1:562:1 | func testNilCoalescing2 | 'func testNilCoalescing2 -V testNilCoalescing2' | -| 555 | cfg.swift:555:25:555:25 | x | 'x -> Block' | +| 555 | cfg.swift:555:25:555:32 | Parameter | 'Parameter -V x -> Block' | | 556 | cfg.swift:556:3:561:3 | IfExpr | 'IfExpr -V ... ?? ... -V x' | | 557 | cfg.swift:557:7:557:11 | false | 'false' | | 557 | cfg.swift:557:13:559:3 | Block | 'Block' | @@ -515,7 +515,7 @@ | 559 | cfg.swift:559:10:561:3 | Block | 'Block' | | 560 | cfg.swift:560:12:560:12 | 0 | '0 -^ ReturnExpr' | | 564 | cfg.swift:564:1:566:1 | func usesAutoclosure | 'func usesAutoclosure -V usesAutoclosure' | -| 564 | cfg.swift:564:24:564:27 | expr | 'expr -> Block' | +| 564 | cfg.swift:564:22:564:51 | Parameter | 'Parameter -V expr -> Block' | | 565 | cfg.swift:565:10:565:13 | expr | 'expr -^ expr(...) -^ ReturnExpr' | | 568 | cfg.swift:568:1:570:1 | func autoclosureTest | 'func autoclosureTest -V autoclosureTest' | | 568 | cfg.swift:568:24:570:1 | Block | 'Block' | @@ -531,15 +531,15 @@ | 583 | cfg.swift:583:1:583:70 | func getMyProtocolImpl | 'func getMyProtocolImpl -V getMyProtocolImpl' | | 583 | cfg.swift:583:44:583:70 | Block | 'Block -V MyProcotolImpl -^ MyProcotolImpl(...) -^ ReturnExpr' | | 585 | cfg.swift:585:1:585:23 | func sink | 'func sink -V sink' | -| 585 | cfg.swift:585:11:585:13 | arg | 'arg -> Block' | +| 585 | cfg.swift:585:11:585:18 | Parameter | 'Parameter -V arg -> Block' | | 587 | cfg.swift:587:1:592:1 | func testOpenExistentialExpr | 'func testOpenExistentialExpr -V testOpenExistentialExpr' | -| 587 | cfg.swift:587:30:587:30 | x | 'x -> y -> Block' | +| 587 | cfg.swift:587:30:587:42 | Parameter | 'Parameter -V x -> Parameter -V y -> Block' | | 588 | cfg.swift:588:2:588:5 | sink | 'sink -> Argument -V x -^ ... .source -^ ... .source(...) -^ sink(...)' | | 589 | cfg.swift:589:2:589:5 | sink | 'sink -> Argument -V y -^ ... .source -^ ... .source(...) -^ sink(...)' | | 590 | cfg.swift:590:2:590:5 | sink | 'sink -> Argument -V getMyProtocol -^ getMyProtocol(...) -^ ... .source -^ ... .source(...) -^ sink(...)' | | 591 | cfg.swift:591:2:591:5 | sink | 'sink -> Argument -V getMyProtocolImpl -^ getMyProtocolImpl(...) -^ ... .source -^ ... .source(...) -^ sink(...)' | | 594 | cfg.swift:594:1:602:1 | func singleStmtExpr | 'func singleStmtExpr -V singleStmtExpr' | -| 594 | cfg.swift:594:23:594:23 | x | 'x -> Block' | +| 594 | cfg.swift:594:21:594:28 | Parameter | 'Parameter -V x -> Block' | | 595 | cfg.swift:595:3:598:3 | let a | 'let a -V a -> SwitchExpr -V x' | | 596 | cfg.swift:596:5:596:17 | SwitchCase | 'SwitchCase -V 0 -> 5 -^ ... ..< ...' | | 596 | cfg.swift:596:17:596:17 | Block | 'Block -V 1' | @@ -551,19 +551,19 @@ | 605 | cfg.swift:605:1:607:1 | struct ValueGenericsStruct | 'struct ValueGenericsStruct -V ValueGenericsStruct -> TypeParameter -V N -> Int' | | 606 | cfg.swift:606:5:606:13 | var ValueGenericsStruct.x | 'var ValueGenericsStruct.x -V x -> N' | | 609 | cfg.swift:609:1:613:1 | func valueGenericsFn | 'func valueGenericsFn -V valueGenericsFn' | -| 609 | cfg.swift:609:36:609:40 | value | 'value -> Block' | +| 609 | cfg.swift:609:34:609:64 | Parameter | 'Parameter -V value -> Block' | | 610 | cfg.swift:610:5:610:13 | var x | 'var x -V x -> N' | | 611 | cfg.swift:611:5:611:9 | print | 'print -> Argument -V x -^ print(...)' | | 612 | cfg.swift:612:5:612:5 | _ | '_ -> value -^ ... = ...' | | 615 | cfg.swift:615:1:623:1 | func exhaustiveBoolSwitch | 'func exhaustiveBoolSwitch -V exhaustiveBoolSwitch' | -| 615 | cfg.swift:615:29:615:33 | value | 'value -> Block' | +| 615 | cfg.swift:615:27:615:39 | Parameter | 'Parameter -V value -> Block' | | 616 | cfg.swift:616:3:621:3 | SwitchExpr | 'SwitchExpr -V value' | | 617 | cfg.swift:617:5:618:14 | SwitchCase | 'SwitchCase -V true' | | 618 | cfg.swift:618:7:618:14 | Block | 'Block -V 1 -^ ReturnExpr' | | 619 | cfg.swift:619:5:620:14 | SwitchCase | 'SwitchCase -V false' | | 620 | cfg.swift:620:7:620:14 | Block | 'Block -V 0 -^ ReturnExpr' | | 625 | cfg.swift:625:1:635:1 | func exhaustiveEnumSwitch | 'func exhaustiveEnumSwitch -V exhaustiveEnumSwitch' | -| 625 | cfg.swift:625:29:625:33 | value | 'value -> flag -> Block' | +| 625 | cfg.swift:625:27:625:42 | Parameter | 'Parameter -V value -> Parameter -V flag -> Block' | | 626 | cfg.swift:626:3:633:3 | SwitchExpr | 'SwitchExpr -V value' | | 627 | cfg.swift:627:5:628:14 | SwitchCase | 'SwitchCase -V flag -? . -^ ... .error1 -^ ConditionalPattern' | | 628 | cfg.swift:628:7:628:14 | Block | 'Block -V 1 -^ ReturnExpr' | diff --git a/unified/ql/test/library-tests/controlflow/cfg.expected b/unified/ql/test/library-tests/controlflow/cfg.expected index b1cf19c84a27..519997bd40a6 100644 --- a/unified/ql/test/library-tests/controlflow/cfg.expected +++ b/unified/ql/test/library-tests/controlflow/cfg.expected @@ -58,9 +58,9 @@ bbStep | cfg.swift:200:13:200:17 | ... > ... | '... > ... : true -> ! ...(+1)' | | cfg.swift:201:15:201:20 | ... == ... | '... == ... : false -> Block(+0)' | | cfg.swift:201:15:201:20 | ... == ... | '... == ... : true,false -> Block(+3)' | -| cfg.swift:209:9:209:9 | b | 'b : match -> Block(+0)' | -| cfg.swift:209:9:209:9 | b | 'b : no-match -> false(+0)' | -| cfg.swift:209:20:209:24 | false | 'false : successor -> Block(+0)' | +| cfg.swift:209:9:209:24 | Parameter | 'Parameter : no-match -> false(+0)' | +| cfg.swift:209:9:209:24 | Parameter | 'Parameter : successor -> b(+0)' | +| cfg.swift:209:20:209:24 | false | 'false : successor -> b(+0)' | | cfg.swift:210:6:210:6 | b | 'b : false -> 1(+3)' | | cfg.swift:210:6:210:6 | b | 'b : true -> Block(+0)' | | cfg.swift:217:6:217:10 | ... < ... | '... < ... : false -> x(+6)' | @@ -224,7 +224,7 @@ noCfg | cfg.swift:634:3:634:11 | ReturnExpr | | fallthrough.swift:6:7:6:11 | print | nonSimple -| cfg.swift:12:17:12:25 | withParam | 'withParam -? Block' | +| cfg.swift:12:17:12:30 | Parameter | 'Parameter -V withParam -? Block' | | cfg.swift:35:5:35:5 | CatchClause | 'CatchClause -V MyError -^ ... .error1 -> isZero -> Argument -V x -^ isZero(...) -? MyError -^ ... .error2 -^ ConditionalPattern -^ OrPattern' | | cfg.swift:627:5:627:5 | SwitchCase | 'SwitchCase -V flag -? . -^ ... .error1 -^ ConditionalPattern' | | fallthrough.swift:10:3:10:3 | SwitchCase | 'SwitchCase -V flag -? 1 -^ ConditionalPattern' | diff --git a/unified/ql/test/library-tests/controlflow/cfg.swift b/unified/ql/test/library-tests/controlflow/cfg.swift index c239336a508f..69f0ccb9d6fb 100644 --- a/unified/ql/test/library-tests/controlflow/cfg.swift +++ b/unified/ql/test/library-tests/controlflow/cfg.swift @@ -9,7 +9,7 @@ Double(topLevelDecl) enum MyError: Error { case error1, error2 - case error3(withParam: Int) // $ nonSimple='withParam -? Block' + case error3(withParam: Int) // $ nonSimple='Parameter -V withParam -? Block' } func isZero(x : Int) -> Bool { @@ -206,7 +206,7 @@ func m1(x : Int) { } } -func m2(b : Bool = false) -> Int { // $ bbStep='b : match -> Block(+0)' bbStep='b : no-match -> false(+0)' bbStep='false : successor -> Block(+0)' +func m2(b : Bool = false) -> Int { // $ bbStep='Parameter : no-match -> false(+0)' bbStep='Parameter : successor -> b(+0)' bbStep='false : successor -> b(+0)' if b { // $ bbStep='b : false -> 1(+3)' bbStep='b : true -> Block(+0)' return 0 } From 6d788afb0cced3d33ac5c8f6260496d12d1e533c Mon Sep 17 00:00:00 2001 From: Tom Hvitved Date: Wed, 2 Dec 2026 09:07:30 +0100 Subject: [PATCH 3/6] C#: Update `Parameter.getPattern()` --- .../code/csharp/controlflow/internal/ControlFlowGraph.qll | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/csharp/ql/lib/semmle/code/csharp/controlflow/internal/ControlFlowGraph.qll b/csharp/ql/lib/semmle/code/csharp/controlflow/internal/ControlFlowGraph.qll index 254fad1579aa..c8cc2a3a6728 100644 --- a/csharp/ql/lib/semmle/code/csharp/controlflow/internal/ControlFlowGraph.qll +++ b/csharp/ql/lib/semmle/code/csharp/controlflow/internal/ControlFlowGraph.qll @@ -147,7 +147,7 @@ module Ast implements AstSig { final private class ParameterFinal = CS::Parameter; class Parameter extends ParameterFinal { - AstNode getPattern() { result = this } + AstNode getPattern() { none() } Expr getDefaultValue() { // Avoid combinatorial explosions for callables with multiple bodies From 52459bebe22fa1da69fa532389ce8342aafe989c Mon Sep 17 00:00:00 2001 From: Tom Hvitved Date: Wed, 2 Dec 2026 09:07:46 +0100 Subject: [PATCH 4/6] Go: Update `Parameter.getPattern()` --- go/ql/lib/semmle/go/controlflow/ControlFlowGraphImpl.qll | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go/ql/lib/semmle/go/controlflow/ControlFlowGraphImpl.qll b/go/ql/lib/semmle/go/controlflow/ControlFlowGraphImpl.qll index ccd031ecb48a..6f6c2a27a2a2 100644 --- a/go/ql/lib/semmle/go/controlflow/ControlFlowGraphImpl.qll +++ b/go/ql/lib/semmle/go/controlflow/ControlFlowGraphImpl.qll @@ -167,7 +167,7 @@ module CfgImpl { class Parameter extends AstNode { Parameter() { this = any(Go::Parameter p).getDeclaration() } - AstNode getPattern() { result = this } + AstNode getPattern() { none() } Expr getDefaultValue() { none() } } From b1d7731d0e0919954a85f3b1b9af2c976dfc68ba Mon Sep 17 00:00:00 2001 From: Tom Hvitved Date: Wed, 2 Dec 2026 09:08:00 +0100 Subject: [PATCH 5/6] Python: Update `Parameter.getPattern()` --- .../ql/lib/semmle/python/controlflow/internal/AstNodeImpl.qll | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/ql/lib/semmle/python/controlflow/internal/AstNodeImpl.qll b/python/ql/lib/semmle/python/controlflow/internal/AstNodeImpl.qll index 8bec9f2a229b..a4db0d27d8e8 100644 --- a/python/ql/lib/semmle/python/controlflow/internal/AstNodeImpl.qll +++ b/python/ql/lib/semmle/python/controlflow/internal/AstNodeImpl.qll @@ -191,7 +191,7 @@ module Ast implements AstSig { * Gets the pattern for this parameter. In Python, there is no destructuring * pattern syntax for parameters, so the pattern is the parameter itself. */ - AstNode getPattern() { result = this } + AstNode getPattern() { none() } } /** From 8c1ea41fdfd9013c579168776e1f0ec50c02b240 Mon Sep 17 00:00:00 2001 From: Tom Hvitved Date: Wed, 2 Dec 2026 09:08:18 +0100 Subject: [PATCH 6/6] Ruby: Update `Parameter.getPattern()` --- ruby/ql/lib/codeql/ruby/controlflow/ControlFlowGraph.qll | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/ruby/ql/lib/codeql/ruby/controlflow/ControlFlowGraph.qll b/ruby/ql/lib/codeql/ruby/controlflow/ControlFlowGraph.qll index 74923a307b43..4eb921330372 100644 --- a/ruby/ql/lib/codeql/ruby/controlflow/ControlFlowGraph.qll +++ b/ruby/ql/lib/codeql/ruby/controlflow/ControlFlowGraph.qll @@ -209,12 +209,7 @@ private module Ast implements AstSig { } class Parameter extends AstNode instanceof R::Ast::Parameter { - AstNode getPattern() { - this.(R::Ast::NamedParameter).getDefiningAccess() = result - or - not exists(this.(R::Ast::NamedParameter).getDefiningAccess()) and - this = result - } + AstNode getPattern() { result = this.(R::Ast::NamedParameter).getDefiningAccess() } Expr getDefaultValue() { result = desugar(this.(R::Ast::KeywordParameter).getDefaultValue()) or