@@ -195,7 +195,7 @@ private int getSuccessorCounter(final ProductPredicate<?> productState, final LE
195195 for (int sCounter = productState .getSegmentCounter (); sCounter < segments .size (); sCounter ++) {
196196 final Segment currentSegment = segments .get (sCounter );
197197 // check if an Avoid Waypoint of the segment matches (Assumption Waypoints are ignored)
198- if (currentSegment .getAvoidWaypoints ().stream ().anyMatch (x -> matchesAvoidWaypoint (letter , x ))) {
198+ if (currentSegment .getAvoidWaypoints ().stream ().anyMatch (x -> matchesWaypoint (letter , x ))) {
199199 return -1 ;
200200 }
201201 final Waypoint currentFollowWaypoint = currentSegment .getFollowWaypoint ();
@@ -204,33 +204,36 @@ private int getSuccessorCounter(final ProductPredicate<?> productState, final LE
204204 && (!CHECK_ASSUMPTION_LOCATIONS || matchesStartLocation (letter , currentFollowWaypoint ))) {
205205 continue ;
206206 }
207- if (matchesStartLocation (letter , currentFollowWaypoint )) {
208- return matchesWaypointAtStart (letter , currentFollowWaypoint ) ? sCounter + 1 : -1 ;
209- }
210- if (matchesEndLocation (letter , currentFollowWaypoint )) {
211- return matchesWaypointAtEnd (letter , currentFollowWaypoint ) ? sCounter + 1 : -1 ;
212- }
213- return sCounter ;
207+ return matchesWaypoint (letter , currentFollowWaypoint ) ? sCounter + 1 : sCounter ;
214208 }
215209 return segments .size ();
216210 }
217211
218- private boolean matchesAvoidWaypoint (final LETTER statement , final Waypoint waypoint ) {
219- return matchesWaypointAtStart (statement , waypoint ) && matchesStartLocation (statement , waypoint )
220- || matchesWaypointAtEnd (statement , waypoint ) && matchesEndLocation (statement , waypoint );
221- }
222-
223- private boolean matchesWaypointAtStart (final LETTER statement , final Waypoint waypoint ) {
224- if (waypoint instanceof WaypointBranching ) {
212+ /** Checks if the waypoint matches with the statement. Assumption waypoints are not matched */
213+ private boolean matchesWaypoint (final LETTER statement , final Waypoint waypoint ) {
214+ if (waypoint instanceof WaypointBranching && matchesStartLocation (statement , waypoint )) {
225215 final ConditionAnnotation conditionAnnot = ConditionAnnotation .getAnnotation (statement );
226216 return conditionAnnot != null
227217 && Boolean .parseBoolean (waypoint .getConstraint ()) == !conditionAnnot .isNegated ();
228218 }
229- return waypoint instanceof WaypointTarget ;
230- }
231-
232- private boolean matchesWaypointAtEnd (final LETTER statement , final Waypoint waypoint ) {
233- return waypoint instanceof WaypointFunctionEnter || waypoint instanceof WaypointFunctionReturn ;
219+ if (waypoint instanceof WaypointTarget ) {
220+ return matchesStartLocation (statement , waypoint );
221+ }
222+ if (waypoint instanceof WaypointFunctionEnter ) {
223+ if (statement instanceof final IIcfgForkTransitionThreadOther fork ) {
224+ // The location is at the corresponding IIcfgForkTransitionThreadOther, so we check there
225+ return matchesEndLocation (fork .getCorrespondingIIcfgForkTransitionCurrentThread (), waypoint );
226+ }
227+ return matchesEndLocation (statement , waypoint );
228+ }
229+ if (waypoint instanceof WaypointFunctionReturn ) {
230+ if (statement instanceof IIcfgReturnTransition ) {
231+ // function_return waypoints match the location of the function call
232+ return matchesEndLocation (((IIcfgReturnTransition <?, ?>) statement ).getCorrespondingCall (), waypoint );
233+ }
234+ return matchesEndLocation (statement , waypoint );
235+ }
236+ return false ;
234237 }
235238
236239 /** Returns true if the start line and column of the statement match the location of the waypoint */
@@ -246,14 +249,6 @@ private static boolean matchesStartLocation(final IElement statement, final Wayp
246249
247250 /** Returns true if the end line and column of the statement match the location of the waypoint */
248251 private static boolean matchesEndLocation (final IElement statement , final Waypoint waypoint ) {
249- if (statement instanceof IIcfgReturnTransition ) {
250- // function_return waypoints match the location of the function call
251- return matchesEndLocation (((IIcfgReturnTransition <?, ?>) statement ).getCorrespondingCall (), waypoint );
252- }
253- if (statement instanceof final IIcfgForkTransitionThreadOther fork ) {
254- // The location is at the corresponding IIcfgForkTransitionThreadOther, so we check there
255- return matchesEndLocation (fork .getCorrespondingIIcfgForkTransitionCurrentThread (), waypoint );
256- }
257252 final ILocation programLoc = ILocation .getAnnotation (statement );
258253 if (programLoc == null ) {
259254 return false ;
0 commit comments