7
7
8
8
\*******************************************************************/
9
9
10
+ // #define DEBUG
11
+
12
+ #ifdef DEBUG
13
+ #include < iostream>
14
+ #endif
15
+
10
16
#include < util/std_expr.h>
11
17
#include < util/string_utils.h>
12
18
#include < goto-programs/goto_functions.h>
@@ -312,7 +318,7 @@ void goto_unwindt::unwind(
312
318
313
319
goto_programt::const_targett t=i_it->get_target ();
314
320
315
- if (t->location_number >=loop_head->location_number ||
321
+ if (t->location_number >=loop_head->location_number &&
316
322
t->location_number <loop_exit->location_number )
317
323
{
318
324
i_it->set_target (t_skip);
@@ -385,10 +391,21 @@ void goto_unwindt::unwind(
385
391
{
386
392
assert (k>=-1 );
387
393
388
- forall_goto_program_instructions (i_it, goto_program)
394
+ for (goto_programt::const_targett i_it=goto_program.instructions .begin ();
395
+ i_it!=goto_program.instructions .end ();)
389
396
{
397
+ #ifdef DEBUG
398
+ symbol_tablet st;
399
+ namespacet ns (st);
400
+ std::cout << " Instruction:\n " ;
401
+ goto_program.output_instruction (ns, " " , std::cout, i_it);
402
+ #endif
403
+
390
404
if (!i_it->is_backwards_goto ())
405
+ {
406
+ i_it++;
391
407
continue ;
408
+ }
392
409
393
410
const irep_idt func=i_it->function ;
394
411
assert (!func.empty ());
@@ -398,7 +415,10 @@ void goto_unwindt::unwind(
398
415
int final_k=get_k (func, loop_number, k, unwind_set);
399
416
400
417
if (final_k==-1 )
418
+ {
419
+ i_it++;
401
420
continue ;
421
+ }
402
422
403
423
goto_programt::const_targett loop_head=i_it->get_target ();
404
424
goto_programt::const_targett loop_exit=i_it;
@@ -409,7 +429,6 @@ void goto_unwindt::unwind(
409
429
410
430
// necessary as we change the goto program in the previous line
411
431
i_it=loop_exit;
412
- i_it--; // as for loop first increments
413
432
}
414
433
}
415
434
@@ -440,6 +459,10 @@ void goto_unwindt::operator()(
440
459
if (!goto_function.body_available ())
441
460
continue ;
442
461
462
+ #ifdef DEBUG
463
+ std::cout << " Function: " << it->first << std::endl;
464
+ #endif
465
+
443
466
goto_programt &goto_program=goto_function.body ;
444
467
445
468
unwind (goto_program, unwind_set, k, unwind_strategy);
0 commit comments