Skip to content

Commit 5e2024c

Browse files
author
Owen Jones
committed
Change odd behaviour of remove_java_nondet()
1 parent f6219d4 commit 5e2024c

File tree

1 file changed

+2
-35
lines changed

1 file changed

+2
-35
lines changed

src/goto-programs/replace_java_nondet.cpp

+2-35
Original file line numberDiff line numberDiff line change
@@ -121,26 +121,6 @@ static bool is_typecast_with_id(const exprt& expr, const irep_idt& identifier)
121121
return op_symbol.get_identifier()==identifier;
122122
}
123123

124-
/// Return whether the instruction is an assignment, and the rhs is a symbol or
125-
/// typecast expression with the specified identifier.
126-
/// \param instr: A goto program instruction.
127-
/// \param identifier: Some identifier.
128-
/// \return True if the expression is a typecast with one operand, and the
129-
/// typecast's identifier matches the specified identifier.
130-
static bool is_assignment_from(
131-
const goto_programt::instructiont &instr,
132-
const irep_idt &identifier)
133-
{
134-
// If not an assignment, return false
135-
if(!instr.is_assign())
136-
{
137-
return false;
138-
}
139-
const auto &rhs=to_code_assign(instr.code).rhs();
140-
return is_symbol_with_id(rhs, identifier) ||
141-
is_typecast_with_id(rhs, identifier);
142-
}
143-
144124
/// Given an iterator into a list of instructions, modify the list to replace
145125
/// 'nondet' library functions with CBMC-native nondet expressions, and return
146126
/// an iterator to the next instruction to check.
@@ -170,30 +150,17 @@ static goto_programt::targett check_and_replace_target(
170150
{
171151
return next_instr;
172152
}
173-
const auto return_identifier=
174-
to_symbol_expr(next_instr_assign_lhs).get_identifier();
175153

176154
auto &instructions=goto_program.instructions;
177155
const auto end=instructions.end();
178156

179-
// Look for an instruction where this name is on the RHS of an assignment
180-
const auto matching_assignment=std::find_if(
181-
next_instr,
182-
end,
183-
[&return_identifier](const goto_programt::instructiont &instr)
184-
{
185-
return is_assignment_from(instr, return_identifier);
186-
});
187-
188-
assert(matching_assignment!=end);
189-
190157
// Assume that the LHS of *this* assignment is the actual nondet variable
191-
const auto &code_assign=to_code_assign(matching_assignment->code);
158+
const auto &code_assign=to_code_assign(next_instr->code);
192159
const auto nondet_var=code_assign.lhs();
193160
const auto source_loc=target->source_location;
194161

195162
// Erase from the nondet function call to the assignment
196-
const auto after_matching_assignment=std::next(matching_assignment);
163+
const auto after_matching_assignment=std::next(next_instr);
197164
assert(after_matching_assignment!=end);
198165

199166
std::for_each(

0 commit comments

Comments
 (0)