@@ -54,22 +54,29 @@ bool is_meta(const goto_programt::const_targett pos)
54
54
void add_explicit_nondet_for_extern_vars (goto_programt::targetst &locs,
55
55
const symbol_tablet &st, goto_functionst &gf)
56
56
{
57
- goto_programt &entry_body=get_body (gf, CPROVER_INIT);
58
- goto_programt::instructionst &instrs=entry_body.instructions ;
59
- goto_programt::targett pos=std::prev (instrs.end (), 1 );
57
+ goto_programt &entry_body=get_entry_body (gf);
58
+ goto_programt &init_body=get_body (gf, CPROVER_INIT);
59
+ goto_programt::targett entry_pos=entry_body.instructions .begin ();
60
+ goto_programt::targett init_pos=std::prev (init_body.instructions .end (), 1 );
61
+ size_t marker_index=locs.size ();
60
62
for (const symbol_tablet::symbolst::value_type &id_and_symbol : st.symbols )
61
63
{
62
64
const symbolt &symbol=id_and_symbol.second ;
63
- if (!symbol.is_extern ) continue ;
65
+ const std::string &name=id2string (id_and_symbol.first );
66
+ if (!symbol.is_extern || contains (name, CPROVER_PREFIX)) continue ;
67
+ const bool is_solution_var=CEGIS_CONTROL_VECTOR_SOLUTION_VAR_NAME == name
68
+ || CEGIS_CONTROL_SOLUTION_VAR_NAME == name;
69
+ goto_programt &body=is_solution_var ? init_body : entry_body;
70
+ goto_programt::targett &pos=is_solution_var ? init_pos : entry_pos;
64
71
const source_locationt &loc=pos->source_location ;
65
- pos=entry_body.insert_before (pos);
72
+ if (is_solution_var) pos=body.insert_before (pos);
73
+ else pos=body.insert_after (pos);
66
74
pos->source_location =loc;
67
75
pos->type =goto_program_instruction_typet::ASSIGN;
68
76
const side_effect_expr_nondett rhs (symbol.type );
69
77
pos->code =code_assignt (symbol.symbol_expr (), rhs);
70
78
}
71
79
entry_body.update ();
72
- collect_counterexample_locations (locs, entry_body, is_meta, locs.size ());
73
80
}
74
81
}
75
82
@@ -81,8 +88,8 @@ void control_preprocessingt::operator ()()
81
88
inline_user_program (st, gf);
82
89
goto_programt::targetst &locs=control_program.counterexample_locations ;
83
90
goto_programt &body=get_entry_body (gf);
84
- collect_counterexample_locations (locs, body, is_meta);
85
91
add_explicit_nondet_for_extern_vars (locs, st, gf);
92
+ collect_counterexample_locations (locs, body, is_meta);
86
93
// XXX: Debug
87
94
for (const goto_programt::const_targett target : locs)
88
95
{
0 commit comments