mirror of
https://github.com/github/codeql.git
synced 2025-12-20 10:46:30 +01:00
C#: Refactor recursive patterns implementation
- Extract names of properties in a propery match, using the `exprorstmt_name` relation. - Simplify extraction of properties by not distinguishing between top-level patterns and nested patterns. - Introduce `PatternExpr` to capture patterns in `is` expressions, `case` statements, and `switch` expression arms. - Generalize `IsTypeExpr`, `IsPatternExpr`, `IsRecursivePatternExpr`, and `IsConstantExpr` to just `IsExpr` with a member predicate `PatternExpr getPattern()`. - Generalize `TypeCase`, `RecursivePatternCase`, and `ConstCase` to just `CaseStmt` with a member predicate `PatternExpr getPattern()`. - Introduce classes `Switch` and `Case` as base classes of switch statements/expressions and case statements/switch expression arms, respectively. - Simplify CFG logic using the generalized classes. - Generalize guards library to cover `switch` expressions tests. - Generalize data flow library to cover `switch` expression assignments.
This commit is contained in:
@@ -542,7 +542,7 @@ compiler_generated(unique int id: @modifiable_direct ref);
|
||||
|
||||
@member = @method | @constructor | @destructor | @field | @property | @event | @operator | @indexer | @type;
|
||||
|
||||
@named_exprorstmt = @goto_stmt | @labeled_stmt | @literal_expr;
|
||||
@named_exprorstmt = @goto_stmt | @labeled_stmt | @expr;
|
||||
|
||||
@virtualizable = @method | @property | @indexer | @event;
|
||||
|
||||
@@ -806,7 +806,7 @@ case @stmt.kind of
|
||||
| 26 = @fixed_stmt
|
||||
| 27 = @label_stmt
|
||||
| 28 = @catch
|
||||
| 29 = @case
|
||||
| 29 = @case_stmt
|
||||
| 30 = @local_function_stmt
|
||||
;
|
||||
|
||||
@@ -985,6 +985,10 @@ case @expr.kind of
|
||||
| 118 = @switch_case_expr
|
||||
;
|
||||
|
||||
@switch = @switch_stmt | @switch_expr;
|
||||
@case = @case_stmt | @switch_case_expr;
|
||||
@pattern_match = @case | @is_expr;
|
||||
|
||||
@integer_literal_expr = @int_literal_expr | @long_literal_expr | @uint_literal_expr | @ulong_literal_expr;
|
||||
@real_literal_expr = @float_literal_expr | @double_literal_expr | @decimal_literal_expr;
|
||||
@literal_expr = @bool_literal_expr | @char_literal_expr | @integer_literal_expr | @real_literal_expr
|
||||
|
||||
Reference in New Issue
Block a user