@@ -77,16 +77,17 @@ bool is_nondet_initializable_static(
77
77
// / assigned to nondet-initializable static variables with nondeterministic
78
78
// / values.
79
79
// / \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.
81
82
// / \param fct_name: Name of the goto-function to be updated.
82
83
static void nondet_static (
83
84
const namespacet &ns,
84
- goto_functionst &goto_functions ,
85
+ goto_modelt &goto_model ,
85
86
const irep_idt &fct_name)
86
87
{
87
88
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 ());
90
91
91
92
goto_programt &init = fct_entry->second .body ;
92
93
@@ -99,11 +100,11 @@ static void nondet_static(
99
100
100
101
if (is_nondet_initializable_static (sym, ns))
101
102
{
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 ;
107
108
}
108
109
}
109
110
else if (instruction.is_function_call ())
@@ -114,33 +115,24 @@ static void nondet_static(
114
115
if (has_prefix (
115
116
id2string (fsym.get_identifier ()), " #cpp_dynamic_initialization#" ))
116
117
{
117
- nondet_static (ns, goto_functions , fsym.get_identifier ());
118
+ nondet_static (ns, goto_model , fsym.get_identifier ());
118
119
}
119
120
}
120
121
}
121
122
122
123
// update counters etc.
123
- goto_functions.update ();
124
- }
125
-
126
- // / Nondeterministically initializes global scope variables in
127
- // / CPROVER_initialize function.
128
- // / \param ns: Namespace for resolving type information.
129
- // / \param [out] goto_functions: Existing goto-functions to be updated.
130
- void nondet_static (const namespacet &ns, goto_functionst &goto_functions)
131
- {
132
- nondet_static (ns, goto_functions, INITIALIZE_FUNCTION);
124
+ goto_model.goto_functions .update ();
133
125
}
134
126
135
127
// / First main entry point of the module. Nondeterministically initializes
136
128
// / global scope variables, except for constants (such as string literals, final
137
129
// / fields) and internal variables (such as CPROVER and symex variables,
138
130
// / language specific internal variables).
139
- // / \param [out ] goto_model: Existing goto-model to be updated.
131
+ // / \param [inout ] goto_model: Existing goto-model to be updated.
140
132
void nondet_static (goto_modelt &goto_model)
141
133
{
142
134
const namespacet ns (goto_model.symbol_table );
143
- nondet_static (ns, goto_model. goto_functions );
135
+ nondet_static (ns, goto_model, INITIALIZE_FUNCTION );
144
136
}
145
137
146
138
// / Second main entry point of the module. Nondeterministically initializes
@@ -200,7 +192,7 @@ void nondet_static(
200
192
}
201
193
}
202
194
203
- nondet_static (ns, goto_model. goto_functions , INITIALIZE_FUNCTION);
195
+ nondet_static (ns, goto_model, INITIALIZE_FUNCTION);
204
196
}
205
197
206
198
// / Nondeterministically initializes global scope variables that
@@ -228,5 +220,5 @@ void nondet_static_matching(goto_modelt &goto_model, const std::string ®ex)
228
220
}
229
221
230
222
const namespacet ns (goto_model.symbol_table );
231
- nondet_static (ns, goto_model. goto_functions , INITIALIZE_FUNCTION);
223
+ nondet_static (ns, goto_model, INITIALIZE_FUNCTION);
232
224
}
0 commit comments