@@ -358,25 +358,18 @@ module MakeStateBarrierGuard<
358358 }
359359
360360 /**
361- * Gets a logical `and` expression, or parenthesized expression, that contains `guard` .
361+ * Gets any of the ancestors of `guard` that preserves the value of `possibleOutcome`. Includes the guard itself .
362362 */
363- private Expr getALogicalAndParent ( BarrierGuard guard ) {
364- barrierGuardIsRelevant ( guard ) and result = guard .asExpr ( )
363+ private Expr getALogicalOperatorParent ( BarrierGuard guard , boolean possibleOutcome ) {
364+ barrierGuardIsRelevant ( guard ) and result = guard .asExpr ( ) and possibleOutcome = [ true , false ]
365365 or
366- result .( LogAndExpr ) .getAnOperand ( ) = getALogicalAndParent ( guard )
366+ result .( LogOrExpr ) .getAnOperand ( ) = getALogicalOperatorParent ( guard , possibleOutcome ) and
367+ possibleOutcome = false
367368 or
368- result .getUnderlyingValue ( ) = getALogicalAndParent ( guard )
369- }
370-
371- /**
372- * Gets a logical `or` expression, or parenthesized expression, that contains `guard`.
373- */
374- private Expr getALogicalOrParent ( BarrierGuard guard ) {
375- barrierGuardIsRelevant ( guard ) and result = guard .asExpr ( )
369+ result .( LogAndExpr ) .getAnOperand ( ) = getALogicalOperatorParent ( guard , possibleOutcome ) and
370+ possibleOutcome = true
376371 or
377- result .( LogOrExpr ) .getAnOperand ( ) = getALogicalOrParent ( guard )
378- or
379- result .getUnderlyingValue ( ) = getALogicalOrParent ( guard )
372+ result .getUnderlyingValue ( ) = getALogicalOperatorParent ( guard , possibleOutcome )
380373 }
381374
382375 final private class FinalFunction = Function ;
@@ -394,15 +387,7 @@ module MakeStateBarrierGuard<
394387 exists ( BarrierGuard guard |
395388 barrierGuardIsRelevant ( guard ) and
396389 exists ( Expr e |
397- exists ( Expr returnExpr |
398- returnExpr = guard .asExpr ( )
399- or
400- // ad hoc support for conjunctions:
401- getALogicalAndParent ( guard ) = returnExpr and guardOutcome = true
402- or
403- // ad hoc support for disjunctions:
404- getALogicalOrParent ( guard ) = returnExpr and guardOutcome = false
405- |
390+ exists ( Expr returnExpr | returnExpr = getALogicalOperatorParent ( guard , guardOutcome ) |
406391 exists ( SsaExplicitDefinition ssa |
407392 ssa .getDef ( ) .getSource ( ) = returnExpr and
408393 ssa .getVariable ( ) .getAUse ( ) = this .getAReturnedExpr ( )
0 commit comments