File tree Expand file tree Collapse file tree
lib/codeql/unified/internal
test/library-tests/controlflow Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -293,6 +293,28 @@ module Ast implements AstSig<Location> {
293293 boolean getValue ( ) { result .toString ( ) = super .getValue ( ) }
294294 }
295295
296+ class Pattern extends AstNode {
297+ Pattern ( ) { none ( ) }
298+ }
299+
300+ class AndPattern extends Pattern {
301+ AndPattern ( ) { none ( ) }
302+ }
303+
304+ class OrPattern extends Pattern {
305+ OrPattern ( ) { none ( ) }
306+ }
307+
308+ class NotPattern extends Pattern {
309+ NotPattern ( ) { none ( ) }
310+
311+ Pattern getNegatedPattern ( ) { none ( ) }
312+ }
313+
314+ class BindingPattern extends Pattern {
315+ BindingPattern ( ) { none ( ) }
316+ }
317+
296318 class PatternMatchExpr extends U:: PatternGuardExpr {
297319 Expr getExpr ( ) { result = super .getValue ( ) }
298320
Original file line number Diff line number Diff line change 189189| 163 | cfg.swift:163:15:165:3 | Block | 'Block' |
190190| 164 | cfg.swift:164:12:164:15 | true | 'true -^ ReturnExpr' |
191191| 167 | cfg.swift:167:3:167:25 | let xOptional | 'let xOptional -V xOptional -> Optional -> Int -^ GenericTypeExpr -> x' |
192- | 168 | cfg.swift:168:3:172:3 | IfExpr | 'IfExpr -V xOptional -^ PatternGuardExpr ' |
193- | 168 | cfg.swift:168:11:168:11 | . | '. -^ ... .some -> Argument -V x -^ ExprPattern -^ ... .some(...) -> Block' |
192+ | 168 | cfg.swift:168:3:172:3 | IfExpr | 'IfExpr -V PatternGuardExpr -V xOptional -? . -^ ... .some -> Argument -V x -^ ExprPattern -^ ... .some(...) ' |
193+ | 168 | cfg.swift:168:36:170:3 | Block | 'Block' |
194194| 169 | cfg.swift:169:12:169:12 | x | 'x -> 0 -^ ... == ... -^ ReturnExpr' |
195195| 170 | cfg.swift:170:10:172:3 | Block | 'Block' |
196196| 171 | cfg.swift:171:12:171:16 | false | 'false -^ ReturnExpr' |
Original file line number Diff line number Diff line change 4848| cfg.swift:159:11:159:16 | ... > ... | '... > ... : true -> Block(+0)' |
4949| cfg.swift:163:6:163:13 | TypeTestExpr | 'TypeTestExpr : false -> let xOptional(+4)' |
5050| cfg.swift:163:6:163:13 | TypeTestExpr | 'TypeTestExpr : true -> Block(+0)' |
51- | cfg.swift:168:6 :168:34 | PatternGuardExpr | 'PatternGuardExpr : false -> Block(+2 )' |
52- | cfg.swift:168:6 :168:34 | PatternGuardExpr | 'PatternGuardExpr : true -> .(+0 )' |
51+ | cfg.swift:168:11 :168:22 | ... .some(...) | '... .some(...) : match -> Block(+0 )' |
52+ | cfg.swift:168:11 :168:22 | ... .some(...) | '... .some(...) : no-match -> Block(+2 )' |
5353| cfg.swift:196:6:196:10 | ... > ... | '... > ... : false -> IfExpr(+3)' |
5454| cfg.swift:196:6:196:10 | ... > ... | '... > ... : true -> Block(+0)' |
5555| cfg.swift:199:11:199:16 | ... <= ... | '... <= ... : false,false,false -> Block(+5)' |
@@ -226,6 +226,7 @@ noCfg
226226nonSimple
227227| cfg.swift:12:17:12:25 | withParam | 'withParam -? Block' |
228228| cfg.swift:35:5:35:5 | CatchClause | 'CatchClause -V MyError -^ ... .error1 -> isZero -> Argument -V x -^ isZero(...) -? MyError -^ ... .error2 -^ ConditionalPattern -^ OrPattern' |
229+ | cfg.swift:168:3:168:3 | IfExpr | 'IfExpr -V PatternGuardExpr -V xOptional -? . -^ ... .some -> Argument -V x -^ ExprPattern -^ ... .some(...)' |
229230| cfg.swift:627:5:627:5 | SwitchCase | 'SwitchCase -V flag -? . -^ ... .error1 -^ ConditionalPattern' |
230231| fallthrough.swift:10:3:10:3 | SwitchCase | 'SwitchCase -V flag -? 1 -^ ConditionalPattern' |
231232| fallthrough.swift:51:3:51:3 | SwitchCase | 'SwitchCase -V flag -? 1 -^ ConditionalPattern' |
Original file line number Diff line number Diff line change @@ -165,7 +165,7 @@ func patterns(x : Int) -> Bool {
165165 }
166166
167167 let xOptional : Int ? = x
168- if case . some ( let x ) = xOptional { // $ bbStep='PatternGuardExpr : false -> Block(+2 )' bbStep='PatternGuardExpr : true -> .(+0 )'
168+ if case . some ( let x ) = xOptional { // $ bbStep='... .some(...) : match -> Block(+0 )' bbStep='... .some(...) : no-match -> Block(+2)' nonSimple='IfExpr -V PatternGuardExpr -V xOptional -? . -^ ... .some -> Argument -V x -^ ExprPattern -^ ... .some(... )'
169169 return x == 0
170170 } else {
171171 return false
You can’t perform that action at this time.
0 commit comments