Skip to content

Commit 09fdca3

Browse files
author
svorenova
authored
Merge pull request diffblue#2643 from svorenova/fixup-nondet-static
Fix-up to nondet-static option [TG-4365]
2 parents d42054a + daff1d1 commit 09fdca3

File tree

5 files changed

+17
-3
lines changed

5 files changed

+17
-3
lines changed

jbmc/src/java_bytecode/java_bytecode_internal_additions.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ void java_internal_additions(symbol_table_baset &dest)
5151
symbol.name = INFLIGHT_EXCEPTION_VARIABLE_NAME;
5252
symbol.mode = ID_java;
5353
symbol.type = pointer_type(empty_typet());
54+
symbol.type.set(ID_C_no_nondet_initialization, true);
5455
symbol.value = null_pointer_exprt(to_pointer_type(symbol.type));
5556
symbol.is_file_local = false;
5657
symbol.is_static_lifetime = true;

jbmc/src/java_bytecode/java_static_initializers.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ static symbolt add_new_variable_symbol(
9191
new_symbol.pretty_name = name;
9292
new_symbol.base_name = name;
9393
new_symbol.type = type;
94+
new_symbol.type.set(ID_C_no_nondet_initialization, true);
9495
new_symbol.value = value;
9596
new_symbol.is_lvalue = true;
9697
new_symbol.is_state_var = true;

jbmc/src/java_bytecode/java_string_literals.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ symbol_exprt get_or_create_string_literal_symbol(
8484
symbolt new_symbol;
8585
new_symbol.name = escaped_symbol_name_with_prefix;
8686
new_symbol.type = string_type;
87+
new_symbol.type.set(ID_C_constant, true);
8788
new_symbol.base_name = escaped_symbol_name;
8889
new_symbol.pretty_name = value;
8990
new_symbol.mode = ID_java;
@@ -131,6 +132,7 @@ symbol_exprt get_or_create_string_literal_symbol(
131132
array_symbol.is_state_var = true;
132133
array_symbol.value = data;
133134
array_symbol.type = array_symbol.value.type();
135+
array_symbol.type.set(ID_C_constant, true);
134136

135137
if(symbol_table.add(array_symbol))
136138
throw "failed to add constarray symbol to symbol table";
@@ -161,6 +163,7 @@ symbol_exprt get_or_create_string_literal_symbol(
161163
java_int_type(),
162164
symbol_table);
163165
return_symbol.type = return_symbol.value.type();
166+
return_symbol.type.set(ID_C_constant, true);
164167
if(symbol_table.add(return_symbol))
165168
throw "failed to add return symbol to symbol table";
166169

src/goto-instrument/nondet_static.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ void nondet_static(
4242
if(has_prefix(id2string(sym.get_identifier()), CPROVER_PREFIX))
4343
continue;
4444

45+
// any other internal variable such as Java specific?
46+
if(
47+
ns.lookup(sym.get_identifier())
48+
.type.get_bool(ID_C_no_nondet_initialization))
49+
{
50+
continue;
51+
}
52+
4553
// static lifetime?
4654
if(!ns.lookup(sym.get_identifier()).is_static_lifetime)
4755
continue;
@@ -50,11 +58,11 @@ void nondet_static(
5058
if(is_constant_or_has_constant_components(sym.type(), ns))
5159
continue;
5260

53-
i_it=init.insert_before(++i_it);
61+
const goto_programt::instructiont original_instruction = instruction;
5462
i_it->make_assignment();
5563
i_it->code=code_assignt(sym, side_effect_expr_nondett(sym.type()));
56-
i_it->source_location=instruction.source_location;
57-
i_it->function=instruction.function;
64+
i_it->source_location = original_instruction.source_location;
65+
i_it->function = original_instruction.function;
5866
}
5967
else if(instruction.is_function_call())
6068
{

src/util/irep_ids.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,7 @@ IREP_ID_TWO(java_lambda_method_handles, lambda_method_handles)
665665
IREP_ID_ONE(havoc_object)
666666
IREP_ID_TWO(overflow_shl, overflow-shl)
667667
IREP_ID_TWO(C_no_initialization_required, #no_initialization_required)
668+
IREP_ID_TWO(C_no_nondet_initialization, #no_nondet_initialization)
668669
IREP_ID_TWO(overlay_class, java::com.diffblue.OverlayClassImplementation)
669670
IREP_ID_TWO(overlay_method, java::com.diffblue.OverlayMethodImplementation)
670671
IREP_ID_TWO(ignored_method, java::com.diffblue.IgnoredMethodImplementation)

0 commit comments

Comments
 (0)