mirror of
https://github.com/github/codeql.git
synced 2026-05-02 20:25:13 +02:00
C#: Add missing tuple declarations to PatternExpr
`x` and `y` in `pair is var (x, y) ? x : null` are now correctly part of `PatternExpr`.
This commit is contained in:
@@ -316,6 +316,12 @@ private predicate hasChildPattern(ControlFlowElement pm, Expr child) {
|
||||
child = mid.getChildExpr(0) or
|
||||
child = mid.getChildExpr(1)
|
||||
)
|
||||
or
|
||||
exists(Expr mid |
|
||||
hasChildPattern(pm, mid) and
|
||||
mid instanceof @tuple_expr and
|
||||
child = mid.getAChildExpr()
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -420,13 +426,10 @@ class TypeAccessPatternExpr extends TypePatternExpr, TypeAccess {
|
||||
override string getAPrimaryQlClass() { result = "TypeAccessPatternExpr" }
|
||||
}
|
||||
|
||||
/** A pattern that may bind a variable, for example `string s` in `x is string s`. */
|
||||
class BindingPatternExpr extends PatternExpr {
|
||||
BindingPatternExpr() {
|
||||
this instanceof LocalVariableDeclExpr or
|
||||
this instanceof @recursive_pattern_expr
|
||||
}
|
||||
private class TBindingPatternExpr = @local_var_decl_expr or @recursive_pattern_expr;
|
||||
|
||||
/** A pattern that may bind a variable, for example `string s` in `x is string s`. */
|
||||
class BindingPatternExpr extends PatternExpr, TBindingPatternExpr {
|
||||
/**
|
||||
* Gets the local variable declaration of this pattern, if any. For example,
|
||||
* `string s` in `string { Length: 5 } s`.
|
||||
|
||||
@@ -932,8 +932,8 @@ patterns.cs:
|
||||
# 58| 10: [BreakStmt] break;
|
||||
# 59| 11: [CaseStmt] case ...:
|
||||
# 59| 0: [TupleExpr] (..., ...)
|
||||
# 59| 0: [LocalVariableDeclExpr] Int32 x
|
||||
# 59| 1: [LocalVariableDeclExpr] Int32 y
|
||||
# 59| 0: [VariablePatternExpr] Int32 x
|
||||
# 59| 1: [VariablePatternExpr] Int32 y
|
||||
# 60| 12: [BreakStmt] break;
|
||||
# 61| 13: [DefaultCase] default:
|
||||
# 62| 14: [BreakStmt] break;
|
||||
@@ -1159,8 +1159,8 @@ patterns.cs:
|
||||
# 130| 2: [IntLiteral] 2
|
||||
# 131| 3: [SwitchCaseExpr] ... => ...
|
||||
# 131| 0: [TupleExpr] (..., ...)
|
||||
# 131| 0: [LocalVariableDeclExpr] Int32 x
|
||||
# 131| 1: [DiscardExpr] _
|
||||
# 131| 0: [VariablePatternExpr] Int32 x
|
||||
# 131| 1: [DiscardPatternExpr] _
|
||||
# 131| 2: [IntLiteral] 3
|
||||
# 134| 2: [TryStmt] try {...} ...
|
||||
# 135| 0: [BlockStmt] {...}
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
| Tuples.cs:50:17:50:56 | (..., ...) | Tuples.cs:50:13:50:56 | SSA def(x) |
|
||||
| Tuples.cs:51:17:51:17 | access to local variable x | Tuples.cs:53:18:53:57 | SSA def(t) |
|
||||
| Tuples.cs:51:17:51:17 | access to local variable x | Tuples.cs:58:18:58:35 | (..., ...) |
|
||||
| Tuples.cs:51:17:51:17 | access to local variable x | Tuples.cs:58:18:58:35 | (..., ...) |
|
||||
| Tuples.cs:51:17:51:17 | access to local variable x | Tuples.cs:77:13:77:13 | access to local variable x |
|
||||
| Tuples.cs:53:18:53:57 | SSA def(t) | Tuples.cs:53:64:53:64 | access to local variable t |
|
||||
| Tuples.cs:53:18:53:57 | SSA qualifier def(t.Item1) | Tuples.cs:54:22:54:28 | access to field Item1 |
|
||||
@@ -92,6 +93,7 @@
|
||||
| Tuples.cs:70:22:70:28 | [post] access to field Item2 | Tuples.cs:72:22:72:28 | access to field Item2 |
|
||||
| Tuples.cs:70:22:70:28 | access to field Item2 | Tuples.cs:72:22:72:28 | access to field Item2 |
|
||||
| Tuples.cs:77:13:77:13 | access to local variable x | Tuples.cs:77:18:77:35 | (..., ...) |
|
||||
| Tuples.cs:77:13:77:13 | access to local variable x | Tuples.cs:77:18:77:35 | (..., ...) |
|
||||
| Tuples.cs:77:23:77:23 | SSA def(p) | Tuples.cs:79:18:79:18 | access to local variable p |
|
||||
| Tuples.cs:77:27:77:27 | SSA def(q) | Tuples.cs:81:18:81:18 | access to local variable q |
|
||||
| Tuples.cs:77:30:77:30 | SSA def(r) | Tuples.cs:80:18:80:18 | access to local variable r |
|
||||
|
||||
@@ -206,11 +206,11 @@ Tuples.cs:
|
||||
# 57| 4: [BreakStmt] break;
|
||||
# 58| 5: [CaseStmt] case ...:
|
||||
# 58| 0: [TupleExpr] (..., ...)
|
||||
# 58| 0: [LocalVariableDeclExpr] String a
|
||||
# 58| 0: [VariablePatternExpr] String a
|
||||
# 58| 1: [TupleExpr] (..., ...)
|
||||
# 58| 0: [LocalVariableDeclExpr] Int32 b
|
||||
# 58| 1: [LocalVariableDeclExpr] String c
|
||||
# 58| 2: [DiscardExpr] _
|
||||
# 58| 0: [VariablePatternExpr] Int32 b
|
||||
# 58| 1: [VariablePatternExpr] String c
|
||||
# 58| 2: [DiscardPatternExpr] _
|
||||
# 59| 6: [ExprStmt] ...;
|
||||
# 59| 0: [MethodCall] call to method Sink<String>
|
||||
# 59| 0: [LocalVariableAccess] access to local variable a
|
||||
@@ -238,8 +238,8 @@ Tuples.cs:
|
||||
# 68| 2: [PositionalPatternExpr] ( ... )
|
||||
# 68| 0: [ConstantPatternExpr,StringLiteral] "taint source"
|
||||
# 68| 1: [TupleExpr] (..., ...)
|
||||
# 68| 0: [LocalVariableDeclExpr] Int32 b
|
||||
# 68| 1: [LocalVariableDeclExpr] String c
|
||||
# 68| 0: [VariablePatternExpr] Int32 b
|
||||
# 68| 1: [VariablePatternExpr] String c
|
||||
# 68| 2: [DiscardPatternExpr] _
|
||||
# 69| 1: [ExprStmt] ...;
|
||||
# 69| 0: [MethodCall] call to method Sink<String>
|
||||
@@ -266,11 +266,11 @@ Tuples.cs:
|
||||
# 77| 0: [IsExpr] ... is ...
|
||||
# 77| 0: [LocalVariableAccess] access to local variable x
|
||||
# 77| 1: [TupleExpr] (..., ...)
|
||||
# 77| 0: [LocalVariableDeclExpr] String p
|
||||
# 77| 0: [VariablePatternExpr] String p
|
||||
# 77| 1: [TupleExpr] (..., ...)
|
||||
# 77| 0: [LocalVariableDeclExpr] Int32 q
|
||||
# 77| 1: [LocalVariableDeclExpr] String r
|
||||
# 77| 2: [DiscardExpr] _
|
||||
# 77| 0: [VariablePatternExpr] Int32 q
|
||||
# 77| 1: [VariablePatternExpr] String r
|
||||
# 77| 2: [DiscardPatternExpr] _
|
||||
# 78| 1: [BlockStmt] {...}
|
||||
# 79| 0: [ExprStmt] ...;
|
||||
# 79| 0: [MethodCall] call to method Sink<String>
|
||||
@@ -339,8 +339,8 @@ Tuples.cs:
|
||||
# 96| 0: [LocalVariableAccess] access to local variable r
|
||||
# 98| 0: [CaseStmt] case ...:
|
||||
# 98| 0: [TupleExpr] (..., ...)
|
||||
# 98| 0: [LocalVariableDeclExpr] String x
|
||||
# 98| 1: [LocalVariableDeclExpr] Int32 y
|
||||
# 98| 0: [VariablePatternExpr] String x
|
||||
# 98| 1: [VariablePatternExpr] Int32 y
|
||||
# 99| 1: [ExprStmt] ...;
|
||||
# 99| 0: [MethodCall] call to method Sink<String>
|
||||
# 99| 0: [LocalVariableAccess] access to local variable x
|
||||
|
||||
Reference in New Issue
Block a user