Skip to content

Commit ad06cf5

Browse files
author
Owen Jones
committed
Address (some) review comments
1 parent d05d8f9 commit ad06cf5

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

jbmc/src/java_bytecode/convert_java_nondet.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,14 @@ static std::pair<goto_programt::targett, bool> insert_nondet_init_code(
7575
continue;
7676
}
7777

78-
// Check whether the nondet object may be null
7978
if(!to_side_effect_expr_nondet(side_effect).get_nullable())
8079
object_factory_parameters.max_nonnull_tree_depth = 1;
80+
8181
// Get the symbol to nondet-init
8282
const auto source_loc = target->source_location;
8383

84-
// Create aux symbol for nondet object
84+
// Create symbol for storing nondet object. We will replace `op` with this
85+
// symbol.
8586
symbolt &aux_symbol = get_fresh_aux_symbol(
8687
type,
8788
id2string(goto_programt::get_function_id(goto_program)),
@@ -103,20 +104,19 @@ static std::pair<goto_programt::targett, bool> insert_nondet_init_code(
103104
aux_block, symbol_table, aux_instructions, message_handler, mode);
104105
CHECK_RETURN(aux_instructions.instructions.size() == 2);
105106

106-
// Generate nondet init code
107107
code_blockt init_code;
108108

109+
const bool skip_classid = true;
109110
gen_nondet_init(
110111
aux_symbol_expr,
111112
init_code,
112113
symbol_table,
113114
source_loc,
114-
true,
115+
skip_classid,
115116
allocation_typet::DYNAMIC,
116117
object_factory_parameters,
117118
update_in_placet::NO_UPDATE_IN_PLACE);
118119

119-
// Convert this code into goto instructions
120120
goto_programt nondet_init_instructions;
121121
goto_convert(
122122
init_code, symbol_table, nondet_init_instructions, message_handler, mode);

jbmc/unit/java_bytecode/java_replace_nondet/replace_nondet.cpp

+7-11
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ void validate_nondets_converted(
121121
}
122122
}
123123

124-
REQUIRE(!nondet_exists);
124+
REQUIRE_FALSE(nondet_exists);
125125
REQUIRE(allocate_exists);
126126
}
127127

@@ -145,7 +145,7 @@ void load_and_test_method(
145145
remove_virtual_functions(model_function);
146146

147147
// Then test both situations.
148-
THEN("Replace nondet should work when remove returns has been called.")
148+
THEN("Replace nondet should work after remove returns has been called.")
149149
{
150150
remove_returns(model_function, [](const irep_idt &) { return false; });
151151

@@ -154,7 +154,7 @@ void load_and_test_method(
154154
validate_nondet_method_removed(goto_function.body.instructions);
155155
}
156156

157-
THEN("Replace nondet should work when remove returns hasn't been called.")
157+
THEN("Replace nondet should work before remove returns has been called.")
158158
{
159159
replace_java_nondet(model_function);
160160

@@ -166,24 +166,20 @@ void load_and_test_method(
166166
object_factory_parameterst params{};
167167

168168
THEN(
169-
"Replace and convert nondet should work when remove returns has been "
169+
"Replace and convert nondet should work after remove returns has been "
170170
"called.")
171171
{
172+
remove_returns(model_function, [](const irep_idt &) { return false; });
173+
172174
replace_java_nondet(model_function);
173175

174176
convert_nondet(model_function, null_message_handler, params, ID_java);
175177

176-
remove_returns(model_function, [](const irep_idt &) { return false; });
177-
178-
std::stringstream out;
179-
goto_function.body.output(namespacet(symbol_table), "", out);
180-
std::string res = out.str();
181-
182178
validate_nondets_converted(goto_function.body.instructions);
183179
}
184180

185181
THEN(
186-
"Replace and convert nondet should work when remove returns hasn't been "
182+
"Replace and convert nondet should work before remove returns has been "
187183
"called.")
188184
{
189185
replace_java_nondet(model_function);

0 commit comments

Comments
 (0)