mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Swift: clean up VarDecl, NamedPattern and SwitchStmt interactions
* `variables` under `CaseStmt` are now AST children, which solves orphan `VarDecl`s in that case * reordered `CaseStmt` AST children to be `labels > variables > body` (was `body > labels`) * made `NamedPattern::getVarDecl` an extracted property instead of `getName` * The above led to duplicate DB entities because of a quirk in the Swift compiler code. This is solved by tweaking the extraction of `variables` under `CaseStmt` to not use `getCaseBodyVariables`.
This commit is contained in:
@@ -868,7 +868,7 @@ class IsPattern(Pattern):
|
||||
sub_pattern: optional[Pattern] | child
|
||||
|
||||
class NamedPattern(Pattern):
|
||||
name: string
|
||||
var_decl: VarDecl
|
||||
|
||||
class OptionalSomePattern(Pattern):
|
||||
sub_pattern: Pattern | child
|
||||
@@ -884,6 +884,7 @@ class TypedPattern(Pattern):
|
||||
type_repr: optional["TypeRepr"] | child
|
||||
|
||||
@group("stmt")
|
||||
@qltest.test_with("SwitchStmt")
|
||||
class CaseLabelItem(AstNode):
|
||||
pattern: Pattern | child
|
||||
guard: optional[Expr] | child
|
||||
@@ -948,10 +949,11 @@ class BreakStmt(Stmt):
|
||||
target_name: optional[string]
|
||||
target: optional[Stmt]
|
||||
|
||||
@qltest.test_with("SwitchStmt")
|
||||
class CaseStmt(Stmt):
|
||||
body: Stmt | child
|
||||
labels: list[CaseLabelItem] | child
|
||||
variables: list[VarDecl]
|
||||
variables: list[VarDecl] | child
|
||||
body: Stmt | child
|
||||
|
||||
class ContinueStmt(Stmt):
|
||||
target_name: optional[string]
|
||||
|
||||
Reference in New Issue
Block a user