Skip to content

Commit f567784

Browse files
author
Owen Jones
committed
Address review comments
1 parent 70d3fea commit f567784

File tree

2 files changed

+12
-25
lines changed

2 files changed

+12
-25
lines changed

jbmc/src/java_bytecode/convert_java_nondet.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,13 @@ static goto_programt::targett insert_nondet_init_code(
5959
const typet &type = side_effect.type();
6060
// If the lhs type doesn't have a subtype then I guess it's primitive and
6161
// we want to bail out now
62-
if(!(type.id() == ID_pointer && type.has_subtype()))
62+
if(type.id() != ID_pointer)
6363
{
6464
continue;
6565
}
6666

67-
// Although, if the type is a ptr-to-void then we also want to bail
67+
// Although, if the type is a ptr-to-void or a function pointer then we also
68+
// want to bail
6869
if(type.subtype().id() == ID_empty || type.subtype().id() == ID_code)
6970
{
7071
continue;
@@ -131,8 +132,6 @@ static goto_programt::targett insert_nondet_init_code(
131132
// Finally insert the dead instruction for aux_symbol after target
132133
goto_program.insert_after(target)->swap(
133134
aux_instructions.instructions.back());
134-
135-
goto_program.update();
136135
}
137136

138137
return next_instr;
@@ -164,6 +163,9 @@ void convert_nondet(
164163
object_factory_parameters,
165164
mode);
166165
}
166+
167+
goto_program.update();
168+
167169
}
168170

169171
void convert_nondet(

jbmc/unit/java_bytecode/java_replace_nondet/replace_nondet.cpp

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ void validate_nondet_method_removed(
9595
void validate_nondets_converted(
9696
std::list<goto_programt::instructiont> instructions)
9797
{
98-
bool nondetExists = false, allocateExists = false;
98+
bool nondet_exists = false;
99+
bool allocate_exists = false;
99100
for(const auto &inst : instructions)
100101
{
101102
// Check that our NONDET(<type>) exists on a rhs somewhere.
@@ -110,18 +111,18 @@ void validate_nondets_converted(
110111
auto side_effect = to_side_effect_expr(target_expression);
111112
if(side_effect.get_statement() == ID_nondet)
112113
{
113-
nondetExists = true;
114+
nondet_exists = true;
114115
}
115116

116117
if(side_effect.get_statement() == ID_allocate)
117118
{
118-
allocateExists = true;
119+
allocate_exists = true;
119120
}
120121
}
121122
}
122123

123-
REQUIRE(!nondetExists);
124-
REQUIRE(allocateExists);
124+
REQUIRE(!nondet_exists);
125+
REQUIRE(allocate_exists);
125126
}
126127

127128
void load_and_test_method(
@@ -174,12 +175,6 @@ void load_and_test_method(
174175

175176
remove_returns(model_function, [](const irep_idt &) { return false; });
176177

177-
std::string output = "";
178-
for(auto instruction : model_function.get_goto_function().body.instructions)
179-
{
180-
output += instruction.code.pretty(0, 0) + "\n\n\n";
181-
}
182-
183178
std::stringstream out;
184179
goto_function.body.output(namespacet(symbol_table), "", out);
185180
std::string res = out.str();
@@ -197,16 +192,6 @@ void load_and_test_method(
197192

198193
remove_returns(model_function, [](const irep_idt &) { return false; });
199194

200-
std::string output = "";
201-
for(auto instruction : model_function.get_goto_function().body.instructions)
202-
{
203-
output += instruction.code.pretty(0, 0) + "\n\n\n";
204-
}
205-
206-
std::stringstream out;
207-
goto_function.body.output(namespacet(symbol_table), "", out);
208-
std::string res = out.str();
209-
210195
validate_nondets_converted(goto_function.body.instructions);
211196
}
212197
}

0 commit comments

Comments
 (0)