Skip to content

Commit 437be99

Browse files
author
svorenova
committed
Perform nondet-init in clinit_wrapper even if clinit doesn't exist
This just moves the whole if(nondet-static) block outside of the if(find_sym_it != symbol_table.symbols.end()) block and updates the comment
1 parent 46d47e0 commit 437be99

File tree

1 file changed

+43
-43
lines changed

1 file changed

+43
-43
lines changed

jbmc/src/java_bytecode/java_static_initializers.cpp

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -220,51 +220,51 @@ static void clinit_wrapper_do_recursive_calls(
220220
code_function_callt call_real_init;
221221
call_real_init.function() = find_sym_it->second.symbol_expr();
222222
init_body.move_to_operands(call_real_init);
223+
}
223224

224-
// Add a standard nondet initialization for each non-final static field
225-
// of this class. Note this is the same invocation used in
226-
// get_stub_initializer_body and java_static_lifetime_init.
227-
if(nondet_static)
225+
// If nondet-static option is given, add a standard nondet initialization for
226+
// each non-final static field of this class. Note this is the same invocation
227+
// used in get_stub_initializer_body and java_static_lifetime_init.
228+
if(nondet_static)
229+
{
230+
object_factory_parameterst parameters = object_factory_parameters;
231+
parameters.function_id = clinit_wrapper_name(class_name);
232+
233+
std::vector<irep_idt> nondet_ids;
234+
std::for_each(
235+
symbol_table.symbols.begin(),
236+
symbol_table.symbols.end(),
237+
[&](const std::pair<irep_idt, symbolt> &symbol) {
238+
if(
239+
symbol.second.type.get(ID_C_class) == class_name &&
240+
symbol.second.is_static_lifetime &&
241+
!symbol.second.type.get_bool(ID_C_constant))
242+
{
243+
nondet_ids.push_back(symbol.first);
244+
}
245+
});
246+
247+
for(const auto &id : nondet_ids)
228248
{
229-
object_factory_parameterst parameters = object_factory_parameters;
230-
parameters.function_id = clinit_wrapper_name(class_name);
231-
232-
std::vector<irep_idt> nondet_ids;
233-
std::for_each(
234-
symbol_table.symbols.begin(),
235-
symbol_table.symbols.end(),
236-
[&](const std::pair<irep_idt, symbolt> &symbol) {
237-
if(
238-
symbol.second.type.get(ID_C_class) == class_name &&
239-
symbol.second.is_static_lifetime &&
240-
!symbol.second.type.get_bool(ID_C_constant))
241-
{
242-
nondet_ids.push_back(symbol.first);
243-
}
244-
});
245-
246-
for(const auto &id : nondet_ids)
247-
{
248-
const symbol_exprt new_global_symbol =
249-
symbol_table.lookup_ref(id).symbol_expr();
250-
251-
parameters.max_nonnull_tree_depth =
252-
is_non_null_library_global(id)
253-
? std::max(
254-
size_t(1), object_factory_parameters.max_nonnull_tree_depth)
255-
: object_factory_parameters.max_nonnull_tree_depth;
256-
257-
gen_nondet_init(
258-
new_global_symbol,
259-
init_body,
260-
symbol_table,
261-
source_locationt(),
262-
false,
263-
allocation_typet::DYNAMIC,
264-
parameters,
265-
pointer_type_selector,
266-
update_in_placet::NO_UPDATE_IN_PLACE);
267-
}
249+
const symbol_exprt new_global_symbol =
250+
symbol_table.lookup_ref(id).symbol_expr();
251+
252+
parameters.max_nonnull_tree_depth =
253+
is_non_null_library_global(id)
254+
? std::max(
255+
size_t(1), object_factory_parameters.max_nonnull_tree_depth)
256+
: object_factory_parameters.max_nonnull_tree_depth;
257+
258+
gen_nondet_init(
259+
new_global_symbol,
260+
init_body,
261+
symbol_table,
262+
source_locationt(),
263+
false,
264+
allocation_typet::DYNAMIC,
265+
parameters,
266+
pointer_type_selector,
267+
update_in_placet::NO_UPDATE_IN_PLACE);
268268
}
269269
}
270270
}

0 commit comments

Comments
 (0)