@@ -239,9 +239,10 @@ private class GuardConditionFromIR extends GuardCondition {
239239 * IRGuardConditions.
240240 */
241241class IRGuardCondition extends Instruction {
242-
242+ ConditionalBranchInstruction branch ;
243+
243244 IRGuardCondition ( ) {
244- is_condition ( this )
245+ branch = get_branch_for_condition ( this )
245246 }
246247
247248 /**
@@ -295,8 +296,7 @@ class IRGuardCondition extends Instruction {
295296 * return x;
296297 * ```
297298 */
298- predicate hasBranchEdge ( ConditionalBranchInstruction branch , IRBlock succ , boolean testIsTrue ) {
299- branch .getCondition ( ) = this and
299+ predicate hasBranchEdge ( IRBlock succ , boolean testIsTrue ) {
300300 (
301301 testIsTrue = true and
302302 succ .getFirstInstruction ( ) = branch .getTrueSuccessor ( )
@@ -340,26 +340,26 @@ class IRGuardCondition extends Instruction {
340340 */
341341 private predicate controlsBlock ( IRBlock controlled , boolean testIsTrue ) {
342342 not isUnreachedBlock ( controlled ) and
343- exists ( IRBlock thisblock
344- | thisblock .getAnInstruction ( ) = this
345- | exists ( IRBlock succ , ConditionalBranchInstruction branch
343+ exists ( IRBlock branchBlock
344+ | branchBlock .getAnInstruction ( ) = branch
345+ | exists ( IRBlock succ
346346 | testIsTrue = true and succ .getFirstInstruction ( ) = branch .getTrueSuccessor ( )
347347 or
348348 testIsTrue = false and succ .getFirstInstruction ( ) = branch .getFalseSuccessor ( )
349349 | branch .getCondition ( ) = this and
350350 succ .dominates ( controlled ) and
351351 forall ( IRBlock pred
352352 | pred .getASuccessor ( ) = succ
353- | pred = thisblock or succ .dominates ( pred ) or not pred .isReachableFromFunctionEntry ( ) ) ) )
353+ | pred = branchBlock or succ .dominates ( pred ) or not pred .isReachableFromFunctionEntry ( ) ) ) )
354354 }
355355}
356356
357- private predicate is_condition ( Instruction guard ) {
357+ private ConditionalBranchInstruction get_branch_for_condition ( Instruction guard ) {
358358 exists ( ConditionalBranchInstruction branch |
359359 branch .getCondition ( ) = guard
360360 )
361361 or
362- exists ( LogicalNotInstruction cond | is_condition ( cond ) and cond .getUnary ( ) = guard )
362+ exists ( LogicalNotInstruction cond | result = get_branch_for_condition ( cond ) and cond .getUnary ( ) = guard )
363363}
364364
365365/**
0 commit comments