Nullness library: recognise switches with null checks

This commit is contained in:
Chris Smowton
2023-10-27 16:14:00 +01:00
parent 79b77ae805
commit 6b9aed21df
6 changed files with 36 additions and 3 deletions

View File

@@ -1542,6 +1542,11 @@ class SwitchExpr extends Expr, StmtParent, @switchexpr {
exists(YieldStmt yield | yield.getTarget() = this and result = yield.getValue())
}
/** Holds if this switch has a case handling a null literal. */
predicate hasNullCase() {
this.getAConstCase().getValue(_) instanceof NullLiteral
}
/** Gets a printable representation of this expression. */
override string toString() { result = "switch (...)" }