Cleanup: use TypeSwitchStmt.getAssign, not a raw child accessor

This commit is contained in:
Chris Smowton
2020-06-22 14:33:38 +01:00
parent d8374adbde
commit 1dc427a2c5
2 changed files with 7 additions and 4 deletions

View File

@@ -882,6 +882,9 @@ class TypeSwitchStmt extends @typeswitchstmt, SwitchStmt {
/** Gets the assign statement of this type-switch statement. */
SimpleAssignStmt getAssign() { result = getChildStmt(1) }
/** Gets the test statement of this type-switch statement. This is a `SimpleAssignStmt` or `ExprStmt`. */
Stmt getTest() { result = getChildStmt(1) }
/** Gets the expression whose type is examined by this `switch` statement. */
Expr getExpr() { result = getAssign().getRhs() or result = getChildStmt(1).(ExprStmt).getExpr() }

View File

@@ -1761,7 +1761,7 @@ module CFG {
or
first = MkImplicitTrue(this)
or
firstNode(this.(TypeSwitchStmt).getChildStmt(1), first)
firstNode(this.(TypeSwitchStmt).getTest(), first)
)
}
@@ -1775,7 +1775,7 @@ module CFG {
last = MkImplicitTrue(this) and
cmpl = Bool(true)
or
lastNode(this.(TypeSwitchStmt).getChildStmt(1), last, cmpl)
lastNode(this.(TypeSwitchStmt).getTest(), last, cmpl)
) and
(
not cmpl.isNormal()
@@ -1811,13 +1811,13 @@ module CFG {
(
firstNode(this.(ExpressionSwitchStmt).getExpr(), succ) or
succ = MkImplicitTrue(this) or
firstNode(this.(TypeSwitchStmt).getChildStmt(1), succ)
firstNode(this.(TypeSwitchStmt).getTest(), succ)
)
or
(
lastNode(this.(ExpressionSwitchStmt).getExpr(), pred, normalCompletion()) or
pred = MkImplicitTrue(this) or
lastNode(this.(TypeSwitchStmt).getChildStmt(1), pred, normalCompletion())
lastNode(this.(TypeSwitchStmt).getTest(), pred, normalCompletion())
) and
(
firstNode(getNonDefaultCase(0), succ)