@@ -93,7 +93,8 @@ class Guard extends ExprParent {
9393 /** Gets the statement containing this guard. */
9494 Stmt getEnclosingStmt ( ) {
9595 result = this .( Expr ) .getEnclosingStmt ( ) or
96- result = this .( SwitchCase ) .getSwitch ( )
96+ result = this .( SwitchCase ) .getSwitch ( ) or
97+ result = this .( SwitchCase ) .getSwitchExpr ( ) .getEnclosingStmt ( )
9798 }
9899
99100 /**
@@ -126,7 +127,7 @@ class Guard extends ExprParent {
126127 branch = true and
127128 bb2 .getFirstNode ( ) = sc .getControlFlowNode ( ) and
128129 pred = sc .getControlFlowNode ( ) .getAPredecessor ( ) and
129- pred .( Expr ) .getParent * ( ) = sc .getSwitch ( ) . getExpr ( ) and
130+ pred .( Expr ) .getParent * ( ) = sc .getSelectorExpr ( ) and
130131 bb1 = pred .getBasicBlock ( )
131132 )
132133 or
@@ -160,12 +161,12 @@ class Guard extends ExprParent {
160161}
161162
162163private predicate switchCaseControls ( SwitchCase sc , BasicBlock bb ) {
163- exists ( BasicBlock caseblock , SwitchStmt ss |
164- ss . getACase ( ) = sc and
164+ exists ( BasicBlock caseblock , Expr selector |
165+ selector = sc . getSelectorExpr ( ) and
165166 caseblock .getFirstNode ( ) = sc .getControlFlowNode ( ) and
166167 caseblock .bbDominates ( bb ) and
167168 forall ( ControlFlowNode pred | pred = sc .getControlFlowNode ( ) .getAPredecessor ( ) |
168- pred .( Expr ) .getParent * ( ) = ss . getExpr ( )
169+ pred .( Expr ) .getParent * ( ) = selector
169170 )
170171 )
171172}
@@ -254,7 +255,8 @@ private predicate equalityGuard(Guard g, Expr e1, Expr e2, boolean polarity) {
254255 exists ( ConstCase cc |
255256 cc = g and
256257 polarity = true and
257- cc .getSwitch ( ) .getExpr ( ) .getProperExpr ( ) = e1 and
258- cc .getValue ( ) = e2
258+ cc .getSelectorExpr ( ) .getProperExpr ( ) = e1 and
259+ cc .getValue ( ) = e2 and
260+ strictcount ( cc .getValue ( _) ) = 1
259261 )
260262}
0 commit comments