@@ -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 ())
@@ -113,33 +114,24 @@ static void nondet_static(
113
114
// see cpp/cpp_typecheck.cpp, which creates initialization functions
114
115
if (fsym.get_identifier ().starts_with (" #cpp_dynamic_initialization#" ))
115
116
{
116
- nondet_static (ns, goto_functions , fsym.get_identifier ());
117
+ nondet_static (ns, goto_model , fsym.get_identifier ());
117
118
}
118
119
}
119
120
}
120
121
121
122
// 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 ();
132
124
}
133
125
134
126
// / First main entry point of the module. Nondeterministically initializes
135
127
// / global scope variables, except for constants (such as string literals, final
136
128
// / fields) and internal variables (such as CPROVER and symex variables,
137
129
// / 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.
139
131
void nondet_static (goto_modelt &goto_model)
140
132
{
141
133
const namespacet ns (goto_model.symbol_table );
142
- nondet_static (ns, goto_model. goto_functions );
134
+ nondet_static (ns, goto_model, INITIALIZE_FUNCTION );
143
135
}
144
136
145
137
// / Second main entry point of the module. Nondeterministically initializes
@@ -199,7 +191,7 @@ void nondet_static(
199
191
}
200
192
}
201
193
202
- nondet_static (ns, goto_model. goto_functions , INITIALIZE_FUNCTION);
194
+ nondet_static (ns, goto_model, INITIALIZE_FUNCTION);
203
195
}
204
196
205
197
// / Nondeterministically initializes global scope variables that
@@ -227,5 +219,5 @@ void nondet_static_matching(goto_modelt &goto_model, const std::string ®ex)
227
219
}
228
220
229
221
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);
231
223
}
0 commit comments