@@ -77,16 +77,17 @@ bool is_nondet_initializable_static(
7777// / assigned to nondet-initializable static variables with nondeterministic
7878// / values.
7979// / \param ns: Namespace for resolving type information.
80- // / \param [out] goto_functions: Existing goto-functions to be updated.
80+ // / \param [inout] goto_model: Existing goto-functions and symbol table to
81+ // / be updated.
8182// / \param fct_name: Name of the goto-function to be updated.
8283static void nondet_static (
8384 const namespacet &ns,
84- goto_functionst &goto_functions ,
85+ goto_modelt &goto_model ,
8586 const irep_idt &fct_name)
8687{
8788 goto_functionst::function_mapt::iterator fct_entry =
88- goto_functions.function_map .find (fct_name);
89- CHECK_RETURN (fct_entry != goto_functions.function_map .end ());
89+ goto_model. goto_functions .function_map .find (fct_name);
90+ CHECK_RETURN (fct_entry != goto_model. goto_functions .function_map .end ());
9091
9192 goto_programt &init = fct_entry->second .body ;
9293
@@ -99,11 +100,11 @@ static void nondet_static(
99100
100101 if (is_nondet_initializable_static (sym, ns))
101102 {
102- const auto source_location = instruction. source_location ();
103- instruction = goto_programt::make_assignment (
104- code_assignt (
105- sym, side_effect_expr_nondett (sym.type (), source_location)),
106- source_location) ;
103+ side_effect_expr_nondett nondet{
104+ sym. type (), instruction. source_location ()};
105+ instruction. assign_rhs_nonconst () = nondet;
106+ goto_model. symbol_table . get_writeable_ref (sym.get_identifier ()). value =
107+ nondet ;
107108 }
108109 }
109110 else if (instruction.is_function_call ())
@@ -113,33 +114,24 @@ static void nondet_static(
113114 // see cpp/cpp_typecheck.cpp, which creates initialization functions
114115 if (fsym.get_identifier ().starts_with (" #cpp_dynamic_initialization#" ))
115116 {
116- nondet_static (ns, goto_functions , fsym.get_identifier ());
117+ nondet_static (ns, goto_model , fsym.get_identifier ());
117118 }
118119 }
119120 }
120121
121122 // update counters etc.
122- goto_functions.update ();
123- }
124-
125- // / Nondeterministically initializes global scope variables in
126- // / CPROVER_initialize function.
127- // / \param ns: Namespace for resolving type information.
128- // / \param [out] goto_functions: Existing goto-functions to be updated.
129- void nondet_static (const namespacet &ns, goto_functionst &goto_functions)
130- {
131- nondet_static (ns, goto_functions, INITIALIZE_FUNCTION);
123+ goto_model.goto_functions .update ();
132124}
133125
134126// / First main entry point of the module. Nondeterministically initializes
135127// / global scope variables, except for constants (such as string literals, final
136128// / fields) and internal variables (such as CPROVER and symex variables,
137129// / language specific internal variables).
138- // / \param [out ] goto_model: Existing goto-model to be updated.
130+ // / \param [inout ] goto_model: Existing goto-model to be updated.
139131void nondet_static (goto_modelt &goto_model)
140132{
141133 const namespacet ns (goto_model.symbol_table );
142- nondet_static (ns, goto_model. goto_functions );
134+ nondet_static (ns, goto_model, INITIALIZE_FUNCTION );
143135}
144136
145137// / Second main entry point of the module. Nondeterministically initializes
@@ -199,7 +191,7 @@ void nondet_static(
199191 }
200192 }
201193
202- nondet_static (ns, goto_model. goto_functions , INITIALIZE_FUNCTION);
194+ nondet_static (ns, goto_model, INITIALIZE_FUNCTION);
203195}
204196
205197// / Nondeterministically initializes global scope variables that
@@ -227,5 +219,5 @@ void nondet_static_matching(goto_modelt &goto_model, const std::string ®ex)
227219 }
228220
229221 const namespacet ns (goto_model.symbol_table );
230- nondet_static (ns, goto_model. goto_functions , INITIALIZE_FUNCTION);
222+ nondet_static (ns, goto_model, INITIALIZE_FUNCTION);
231223}
0 commit comments