@@ -1325,7 +1325,7 @@ private void assumeLoopCondition(CtExpression<Boolean> condition) {
13251325 */
13261326 private RefinedVariable assumeCondition (CtExpression <Boolean > condition , boolean holds , String kind ) {
13271327 // conditions with side effects (e.g. (n = read()) > 0) are not encoded, so they assume nothing
1328- if (condition == null || ! condition . getElements ( new TypeFilter <>( CtVariableWrite . class )). isEmpty ( ))
1328+ if (condition == null || hasSideEffects ( condition ))
13291329 return null ;
13301330 Predicate refs = getRefinement (condition );
13311331 if (isUninformativeCondition (refs , condition ))
@@ -1377,8 +1377,7 @@ private Predicate conditionValue(CtExpression<Boolean> condition) {
13771377 Predicate refs = getRefinement (condition );
13781378 Predicate value ;
13791379 // as in assumeCondition, conditions with side effects are not encoded, and uninformative ones say nothing
1380- if (!condition .getElements (new TypeFilter <>(CtVariableWrite .class )).isEmpty ()
1381- || isUninformativeCondition (refs , condition ))
1380+ if (hasSideEffects (condition ) || isUninformativeCondition (refs , condition ))
13821381 value = new Predicate ();
13831382 else if (refs .getVariableNames ().contains (Keys .WILDCARD ) || condition instanceof CtInvocation <?>)
13841383 value = refs .substituteVariable (Keys .WILDCARD , name );
@@ -1389,6 +1388,10 @@ else if (refs.getVariableNames().contains(Keys.WILDCARD) || condition instanceof
13891388 return Predicate .createVar (name );
13901389 }
13911390
1391+ private static boolean hasSideEffects (CtExpression <?> expression ) {
1392+ return !expression .getElements (new TypeFilter <>(CtVariableWrite .class )).isEmpty ();
1393+ }
1394+
13921395 private void scanAssuming (CtExpression <?> branch , CtExpression <Boolean > condition , boolean holds ) {
13931396 RefinedVariable pathVar = assumeCondition (condition , holds , GeneratedNames .TERNARY_CONDITION );
13941397 scan (branch );
0 commit comments