Skip to content

Commit 17eda99

Browse files
author
svorenova
committed
Nondet-initialize variables in clinit_wrapper constructor
If nondet-static option is used
1 parent 4fa23b8 commit 17eda99

File tree

1 file changed

+38
-4
lines changed

1 file changed

+38
-4
lines changed

jbmc/src/java_bytecode/java_static_initializers.cpp

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ gen_clinit_eqexpr(const exprt &expr, const clinit_statest state)
184184
/// \param class_name: name of the class to generate clinit wrapper calls for
185185
/// \param [out] init_body: appended with calls to clinit wrapper
186186
static void clinit_wrapper_do_recursive_calls(
187-
const symbol_tablet &symbol_table,
187+
symbol_table_baset &symbol_table,
188188
const irep_idt &class_name,
189189
code_blockt &init_body,
190190
const bool nondet_static,
@@ -208,9 +208,43 @@ static void clinit_wrapper_do_recursive_calls(
208208
auto find_sym_it = symbol_table.symbols.find(real_clinit_name);
209209
if(find_sym_it != symbol_table.symbols.end())
210210
{
211-
code_function_callt call_real_init;
212-
call_real_init.function() = find_sym_it->second.symbol_expr();
213-
init_body.move_to_operands(call_real_init);
211+
if(!nondet_static)
212+
{
213+
code_function_callt call_real_init;
214+
call_real_init.function() = find_sym_it->second.symbol_expr();
215+
init_body.move_to_operands(call_real_init);
216+
}
217+
else
218+
{
219+
object_factory_parameterst parameters = object_factory_parameters;
220+
parameters.function_id = real_clinit_name;
221+
222+
for(const auto &symbol : symbol_table.symbols)
223+
{
224+
if(
225+
symbol.second.is_static_lifetime &&
226+
symbol.second.type.get(ID_C_class) == class_name)
227+
{
228+
const symbol_exprt new_global_symbol = symbol.second.symbol_expr();
229+
230+
parameters.max_nonnull_tree_depth =
231+
is_non_null_library_global(symbol.first)
232+
? object_factory_parameters.max_nonnull_tree_depth + 1
233+
: object_factory_parameters.max_nonnull_tree_depth;
234+
235+
gen_nondet_init(
236+
new_global_symbol,
237+
init_body,
238+
symbol_table,
239+
source_locationt(),
240+
false,
241+
allocation_typet::DYNAMIC,
242+
parameters,
243+
pointer_type_selector,
244+
update_in_placet::NO_UPDATE_IN_PLACE);
245+
}
246+
}
247+
}
214248
}
215249
}
216250

0 commit comments

Comments
 (0)