mirror of
https://github.com/github/codeql.git
synced 2025-12-17 17:23:36 +01:00
- 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.
15 lines
347 B
Plaintext
15 lines
347 B
Plaintext
/**
|
|
* @name Test for is expressions
|
|
*/
|
|
|
|
import csharp
|
|
|
|
from Method m, IsExpr e, TypePatternExpr tpe
|
|
where
|
|
m.hasName("MainIsAsCast") and
|
|
e.getEnclosingCallable() = m and
|
|
e.getExpr().(ParameterAccess).getTarget().getName() = "o" and
|
|
tpe = e.getPattern() and
|
|
tpe.getCheckedType().(Class).hasQualifiedName("Expressions.Class")
|
|
select m, e
|