Skip to content

Commit 5d1900c

Browse files
committed
change signature of goto_symext::symex_function_call and symex_function_call_symbol
This changes the signatures of symex_function_call and symex_function_call_symbol, which can now enforce the fact that the function to be executed is given as symbol expression using typing.
1 parent f083b9c commit 5d1900c

File tree

3 files changed

+22
-16
lines changed

3 files changed

+22
-16
lines changed

src/goto-symex/goto_symex.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -431,11 +431,11 @@ class goto_symext
431431
/// \param get_goto_function: The delegate to retrieve function bodies (see
432432
/// \ref get_goto_functiont)
433433
/// \param state: Symbolic execution state for current instruction
434-
/// \param code: The function call instruction
434+
/// \param instruction: The function call instruction
435435
virtual void symex_function_call(
436436
const get_goto_functiont &get_goto_function,
437437
statet &state,
438-
const code_function_callt &code);
438+
const goto_programt::instructiont &instruction);
439439

440440
/// Symbolically execute a END_FUNCTION instruction.
441441
/// \param state: Symbolic execution state for current instruction
@@ -445,11 +445,15 @@ class goto_symext
445445
/// \param get_goto_function: The delegate to retrieve function bodies (see
446446
/// \ref get_goto_functiont)
447447
/// \param state: Symbolic execution state for current instruction
448-
/// \param code: The function call instruction
448+
/// \param lhs: nil or the lhs of the function call instruction
449+
/// \param function: the symbol of the function to call
450+
/// \param arguments: the arguments of the function call
449451
virtual void symex_function_call_symbol(
450452
const get_goto_functiont &get_goto_function,
451453
statet &state,
452-
const code_function_callt &code);
454+
const exprt &lhs,
455+
const symbol_exprt &function,
456+
const exprt::operandst &arguments);
453457

454458
/// Symbolic execution of a function call by inlining.
455459
/// Records the call in \p target by appending a function call step and:

src/goto-symex/symex_function_call.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,23 +173,31 @@ void goto_symext::parameter_assignments(
173173
void goto_symext::symex_function_call(
174174
const get_goto_functiont &get_goto_function,
175175
statet &state,
176-
const code_function_callt &code)
176+
const goto_programt::instructiont &instruction)
177177
{
178-
const exprt &function=code.function();
178+
const exprt &function = instruction.call_function();
179179

180180
// If at some point symex_function_call can support more
181181
// expression ids(), like ID_Dereference, please expand the
182182
// precondition appropriately.
183183
PRECONDITION(function.id() == ID_symbol);
184-
symex_function_call_symbol(get_goto_function, state, code);
184+
185+
symex_function_call_symbol(
186+
get_goto_function,
187+
state,
188+
instruction.call_lhs(),
189+
to_symbol_expr(instruction.call_function()),
190+
instruction.call_arguments());
185191
}
186192

187193
void goto_symext::symex_function_call_symbol(
188194
const get_goto_functiont &get_goto_function,
189195
statet &state,
190-
const code_function_callt &original_code)
196+
const exprt &lhs,
197+
const symbol_exprt &function,
198+
const exprt::operandst &arguments)
191199
{
192-
code_function_callt code = original_code;
200+
code_function_callt code(lhs, function, arguments);
193201

194202
if(code.lhs().is_not_nil())
195203
code.lhs() = clean_expr(std::move(code.lhs()), state, true);

src/goto-symex/symex_main.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -674,13 +674,7 @@ void goto_symext::execute_next_instruction(
674674

675675
case FUNCTION_CALL:
676676
if(state.reachable)
677-
{
678-
code_function_callt call(
679-
instruction.call_lhs(),
680-
instruction.call_function(),
681-
instruction.call_arguments());
682-
symex_function_call(get_goto_function, state, call);
683-
}
677+
symex_function_call(get_goto_function, state, instruction);
684678
else
685679
symex_transition(state);
686680
break;

0 commit comments

Comments
 (0)