Skip to content

Commit c34be32

Browse files
author
Owen Jones
committed
Fix java argument input declarations
Previously, we would output code like this: INPUT("arg0i", NONDET(int)); helloworld.fun:(I)I(NONDET(int)); We now output code like this instead: tmp_object_factory$1 = NONDET(int); INPUT("arg0i", tmp_object_factory$1); helloworld.fun:(I)I(tmp_object_factory$1); This means that the correct value of the argument to helloworld() is picked up. It also simplifies the code, as we now use the machinery built to deal with pointers for all types, with just a minor tweak for booleans.
1 parent 2f0ba52 commit c34be32

File tree

1 file changed

+25
-34
lines changed

1 file changed

+25
-34
lines changed

src/java_bytecode/java_object_factory.cpp

+25-34
Original file line numberDiff line numberDiff line change
@@ -356,11 +356,13 @@ void java_object_factoryt::gen_nondet_init(
356356
}
357357
else
358358
{
359-
side_effect_expr_nondett se=side_effect_expr_nondett(type);
359+
exprt rhs=type.id()==ID_c_bool?
360+
get_nondet_bool(type):
361+
side_effect_expr_nondett(type);
362+
code_assignt assign(expr, rhs);
363+
assign.add_source_location()=loc;
360364

361-
code_assignt code(expr, se);
362-
code.add_source_location()=loc;
363-
init_code.copy_to_operands(code);
365+
init_code.copy_to_operands(assign);
364366
}
365367
}
366368

@@ -517,36 +519,25 @@ exprt object_factory(
517519
size_t max_nondet_array_length,
518520
const source_locationt &loc)
519521
{
520-
if(type.id()==ID_pointer)
521-
{
522-
symbolt &aux_symbol=new_tmp_symbol(
523-
symbol_table,
524-
loc,
525-
type);
526-
aux_symbol.is_static_lifetime=true;
522+
symbolt &aux_symbol=new_tmp_symbol(
523+
symbol_table,
524+
loc,
525+
type);
526+
aux_symbol.is_static_lifetime=true;
527527

528-
exprt object=aux_symbol.symbol_expr();
528+
exprt object=aux_symbol.symbol_expr();
529529

530-
java_object_factoryt state(
531-
init_code,
532-
!allow_null,
533-
max_nondet_array_length,
534-
symbol_table);
535-
state.gen_nondet_init(
536-
object,
537-
false,
538-
"",
539-
loc,
540-
false);
541-
542-
return object;
543-
}
544-
else if(type.id()==ID_c_bool)
545-
{
546-
// We force this to 0 and 1 and won't consider
547-
// other values.
548-
return get_nondet_bool(type);
549-
}
550-
else
551-
return side_effect_expr_nondett(type);
530+
java_object_factoryt state(
531+
init_code,
532+
!allow_null,
533+
max_nondet_array_length,
534+
symbol_table);
535+
state.gen_nondet_init(
536+
object,
537+
false,
538+
"",
539+
loc,
540+
false);
541+
542+
return object;
552543
}

0 commit comments

Comments
 (0)