mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Swift: add extraction of ThenStmt
These are currently added implicitly by the compiler in the context of `if`/`switch` expressions. In the future, there might be explicit `then <expr>` statement useful for cases where one would like to add more than one statement in the branch, to mark what value to actually use. See https://forums.swift.org/t/pitch-multi-statement-if-switch-do-expressions/68443
This commit is contained in:
@@ -994,6 +994,20 @@ class ThrowStmt(Stmt):
|
||||
class YieldStmt(Stmt):
|
||||
results: list[Expr] | child
|
||||
|
||||
@qltest.test_with('SingleValueStmtExpr')
|
||||
class ThenStmt(Stmt):
|
||||
""" A statement implicitly wrapping values to be used in branches of if/switch expressions. For example in:
|
||||
```
|
||||
let rank = switch value {
|
||||
case 0..<0x80: 1
|
||||
case 0x80..<0x0800: 2
|
||||
default: 3
|
||||
}
|
||||
```
|
||||
the literal expressions `1`, `2` and `3` are wrapped in `ThenStmt`.
|
||||
"""
|
||||
result: Expr
|
||||
|
||||
class DoCatchStmt(LabeledStmt):
|
||||
body: Stmt | child
|
||||
catches: list[CaseStmt] | child
|
||||
|
||||
Reference in New Issue
Block a user