@@ -145,7 +145,7 @@ private predicate isNonFallThroughPredecessor(SwitchCase sc, ControlFlowNode pre
145145 * Evaluating a switch case to true corresponds to taking that switch case, and
146146 * evaluating it to false corresponds to taking some other branch.
147147 */
148- class Guard extends ExprParent {
148+ final class Guard extends ExprParent {
149149 Guard ( ) {
150150 this .( Expr ) .getType ( ) instanceof BooleanType and not this instanceof BooleanLiteral
151151 or
@@ -360,6 +360,18 @@ private predicate guardControls_v3(Guard guard, BasicBlock controlled, boolean b
360360 )
361361}
362362
363+ pragma [ nomagic]
364+ private predicate guardControlsBranchEdge_v2 (
365+ Guard guard , BasicBlock bb1 , BasicBlock bb2 , boolean branch
366+ ) {
367+ guard .hasBranchEdge ( bb1 , bb2 , branch )
368+ or
369+ exists ( Guard g , boolean b |
370+ guardControlsBranchEdge_v2 ( g , bb1 , bb2 , b ) and
371+ implies_v2 ( g , b , guard , branch )
372+ )
373+ }
374+
363375pragma [ nomagic]
364376private predicate guardControlsBranchEdge_v3 (
365377 Guard guard , BasicBlock bb1 , BasicBlock bb2 , boolean branch
@@ -372,6 +384,27 @@ private predicate guardControlsBranchEdge_v3(
372384 )
373385}
374386
387+ /** INTERNAL: Use `Guard` instead. */
388+ final class Guard_v2 extends Guard {
389+ /**
390+ * Holds if this guard evaluating to `branch` controls the control-flow
391+ * branch edge from `bb1` to `bb2`. That is, following the edge from
392+ * `bb1` to `bb2` implies that this guard evaluated to `branch`.
393+ */
394+ predicate controlsBranchEdge ( BasicBlock bb1 , BasicBlock bb2 , boolean branch ) {
395+ guardControlsBranchEdge_v2 ( this , bb1 , bb2 , branch )
396+ }
397+
398+ /**
399+ * Holds if this guard evaluating to `branch` directly or indirectly controls
400+ * the block `controlled`. That is, the evaluation of `controlled` is
401+ * dominated by this guard evaluating to `branch`.
402+ */
403+ predicate controls ( BasicBlock controlled , boolean branch ) {
404+ guardControls_v2 ( this , controlled , branch )
405+ }
406+ }
407+
375408private predicate equalityGuard ( Guard g , Expr e1 , Expr e2 , boolean polarity ) {
376409 exists ( EqualityTest eqtest |
377410 eqtest = g and
0 commit comments