Skip to content

Commit 2532b29

Browse files
authored
Merge pull request #5868 from diffblue/avoid_symex_code_assignt
symex: use lhs/rhs instead of code_assignt
2 parents 8122b9d + e7429be commit 2532b29

7 files changed

+33
-39
lines changed

src/goto-symex/auto_objects.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ void goto_symext::initialize_auto_object(const exprt &expr, statet &state)
6969
null_pointer_exprt(pointer_type),
7070
address_of_expr);
7171

72-
code_assignt assignment(expr, rhs);
73-
symex_assign(state, assignment);
72+
symex_assign(state, expr, rhs);
7473
}
7574
}
7675
}

src/goto-symex/goto_symex.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,13 @@ void goto_symext::do_simplify(exprt &expr)
3636
simplify(expr, ns);
3737
}
3838

39-
void goto_symext::symex_assign(statet &state, const code_assignt &code)
39+
void goto_symext::symex_assign(
40+
statet &state,
41+
const exprt &o_lhs,
42+
const exprt &o_rhs)
4043
{
41-
exprt lhs = clean_expr(code.lhs(), state, true);
42-
exprt rhs = clean_expr(code.rhs(), state, false);
44+
exprt lhs = clean_expr(o_lhs, state, true);
45+
exprt rhs = clean_expr(o_rhs, state, false);
4346

4447
DATA_INVARIANT(
4548
lhs.type() == rhs.type(), "assignments must be type consistent");

src/goto-symex/goto_symex.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,8 +508,9 @@ class goto_symext
508508
/// Symbolically execute an ASSIGN instruction or simulate such an execution
509509
/// for a synthetic assignment
510510
/// \param state: Symbolic execution state for current instruction
511-
/// \param code: The assignment to execute
512-
void symex_assign(statet &state, const code_assignt &code);
511+
/// \param lhs: The lhs of the assignment to execute
512+
/// \param rhs: The rhs of the assignment to execute
513+
void symex_assign(statet &state, const exprt &lhs, const exprt &rhs);
513514

514515
/// Attempt to constant propagate side effects of the assignment (if any)
515516
///

src/goto-symex/symex_builtin_functions.cpp

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,10 @@ void goto_symext::symex_allocate(
150150

151151
state.symbol_table.add(size_symbol);
152152

153-
code_assignt assignment(size_symbol.symbol_expr(), array_size);
154-
array_size = assignment.lhs();
153+
auto array_size_rhs = array_size;
154+
array_size = size_symbol.symbol_expr();
155155

156-
symex_assign(state, assignment);
156+
symex_assign(state, size_symbol.symbol_expr(), array_size_rhs);
157157
}
158158
}
159159

@@ -181,15 +181,14 @@ void goto_symext::symex_allocate(
181181
const auto zero_value =
182182
zero_initializer(*object_type, code.source_location(), ns);
183183
CHECK_RETURN(zero_value.has_value());
184-
code_assignt assignment(value_symbol.symbol_expr(), *zero_value);
185-
symex_assign(state, assignment);
184+
symex_assign(state, value_symbol.symbol_expr(), *zero_value);
186185
}
187186
else
188187
{
189-
const code_assignt assignment{
190-
value_symbol.symbol_expr(),
191-
path_storage.build_symex_nondet(*object_type, code.source_location())};
192-
symex_assign(state, assignment);
188+
auto lhs = value_symbol.symbol_expr();
189+
auto rhs =
190+
path_storage.build_symex_nondet(*object_type, code.source_location());
191+
symex_assign(state, lhs, rhs);
193192
}
194193

195194
exprt rhs;
@@ -207,9 +206,7 @@ void goto_symext::symex_allocate(
207206
value_symbol.symbol_expr(), pointer_type(value_symbol.type));
208207
}
209208

210-
symex_assign(
211-
state,
212-
code_assignt(lhs, typecast_exprt::conditional_cast(rhs, lhs.type())));
209+
symex_assign(state, lhs, typecast_exprt::conditional_cast(rhs, lhs.type()));
213210
}
214211

215212
/// Construct an entry for the var args array. Visual Studio complicates this as
@@ -297,14 +294,12 @@ void goto_symext::symex_va_start(
297294
array = clean_expr(std::move(array), state, false);
298295
array = state.rename(std::move(array), ns).get();
299296
do_simplify(array);
300-
symex_assign(state, code_assignt{va_array.symbol_expr(), std::move(array)});
297+
symex_assign(state, va_array.symbol_expr(), std::move(array));
301298

302299
exprt rhs = address_of_exprt{
303300
index_exprt{va_array.symbol_expr(), from_integer(0, index_type())}};
304301
rhs = state.rename(std::move(rhs), ns).get();
305-
symex_assign(
306-
state,
307-
code_assignt{lhs, typecast_exprt::conditional_cast(rhs, lhs.type())});
302+
symex_assign(state, lhs, typecast_exprt::conditional_cast(rhs, lhs.type()));
308303
}
309304

310305
static irep_idt get_string_argument_rec(const exprt &src)
@@ -533,7 +528,7 @@ void goto_symext::symex_cpp_new(
533528
else
534529
rhs.copy_to_operands(symbol.symbol_expr());
535530

536-
symex_assign(state, code_assignt(lhs, rhs));
531+
symex_assign(state, lhs, rhs);
537532
}
538533

539534
void goto_symext::symex_cpp_delete(

src/goto-symex/symex_function_call.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ void goto_symext::parameter_assignments(
165165

166166
state.call_stack().top().parameter_names.push_back(va_arg.name);
167167

168-
symex_assign(state, code_assignt{va_arg.symbol_expr(), *it1});
168+
symex_assign(state, va_arg.symbol_expr(), *it1);
169169
}
170170
}
171171
else if(it1!=arguments.end())
@@ -287,8 +287,7 @@ void goto_symext::symex_function_call_code(
287287
{
288288
const auto rhs =
289289
side_effect_expr_nondett(call.lhs().type(), call.source_location());
290-
code_assignt code(call.lhs(), rhs);
291-
symex_assign(state, code);
290+
symex_assign(state, call.lhs(), rhs);
292291
}
293292

294293
if(symex_config.havoc_undefined_functions)

src/goto-symex/symex_main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,8 @@ void goto_symext::execute_next_instruction(
667667

668668
case ASSIGN:
669669
if(state.reachable)
670-
symex_assign(state, instruction.get_assign());
670+
symex_assign(
671+
state, instruction.get_assign().lhs(), instruction.get_assign().rhs());
671672

672673
symex_transition(state);
673674
break;

src/goto-symex/symex_other.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,10 @@ void goto_symext::havoc_rec(
3131
lhs=if_exprt(
3232
guard.as_expr(), dest, exprt(ID_null_object, dest.type()));
3333

34-
code_assignt assignment;
35-
assignment.lhs()=lhs;
36-
assignment.rhs() =
34+
auto rhs =
3735
side_effect_expr_nondett(dest.type(), state.source.pc->source_location);
3836

39-
symex_assign(state, assignment);
37+
symex_assign(state, lhs, rhs);
4038
}
4139
else if(dest.id()==ID_byte_extract_little_endian ||
4240
dest.id()==ID_byte_extract_big_endian)
@@ -167,8 +165,7 @@ void goto_symext::symex_other(
167165
}
168166
}
169167

170-
code_assignt assignment(dest_array, src_array);
171-
symex_assign(state, assignment);
168+
symex_assign(state, dest_array, src_array);
172169
}
173170
else if(statement==ID_array_set)
174171
{
@@ -211,8 +208,7 @@ void goto_symext::symex_other(
211208
if(array_type.subtype() != value.type())
212209
value = typecast_exprt(value, array_type.subtype());
213210

214-
code_assignt assignment(array_expr, array_of_exprt(value, array_type));
215-
symex_assign(state, assignment);
211+
symex_assign(state, array_expr, array_of_exprt(value, array_type));
216212
}
217213
else if(statement==ID_array_equal)
218214
{
@@ -236,13 +232,13 @@ void goto_symext::symex_other(
236232
process_array_expr(state, array1);
237233
process_array_expr(state, array2);
238234

239-
code_assignt assignment(code.op2(), equal_exprt(array1, array2));
235+
exprt rhs = equal_exprt(array1, array2);
240236

241237
// check for size (or type) mismatch
242238
if(array1.type() != array2.type())
243-
assignment.rhs() = false_exprt();
239+
rhs = false_exprt();
244240

245-
symex_assign(state, assignment);
241+
symex_assign(state, code.op2(), rhs);
246242
}
247243
else if(statement==ID_user_specified_predicate ||
248244
statement==ID_user_specified_parameter_predicates ||

0 commit comments

Comments
 (0)