Skip to content

Commit be6dd84

Browse files
committed
goto symex now handles function pointers
1 parent 43c04ab commit be6dd84

File tree

2 files changed

+48
-11
lines changed

2 files changed

+48
-11
lines changed

src/goto-symex/goto_symex.h

+15
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Author: Daniel Kroening, [email protected]
1919

2020
class address_of_exprt;
2121
class code_function_callt;
22+
class dereference_exprt;
2223
class function_application_exprt;
2324
class goto_symex_statet;
2425
class path_storaget;
@@ -459,6 +460,20 @@ class goto_symext
459460
const symbol_exprt &function,
460461
const exprt::operandst &arguments);
461462

463+
/// Symbolic execution of a call to a function given via a pointer.
464+
/// \param get_goto_function: The delegate to retrieve function bodies (see
465+
/// \ref get_goto_functiont)
466+
/// \param state: Symbolic execution state for current instruction
467+
/// \param lhs: nil or the lhs of the function call instruction
468+
/// \param function: the dereference expression for the function to call
469+
/// \param arguments: the arguments of the function call
470+
virtual void symex_function_call_dereference(
471+
const get_goto_functiont &get_goto_function,
472+
statet &state,
473+
const exprt &lhs,
474+
const dereference_exprt &function,
475+
const exprt::operandst &arguments);
476+
462477
/// Symbolic execution of a function call by inlining.
463478
/// Records the call in \p target by appending a function call step and:
464479
/// - if the body is available create a new frame, assigns the parameters,

src/goto-symex/symex_function_call.cpp

+33-11
Original file line numberDiff line numberDiff line change
@@ -178,17 +178,26 @@ void goto_symext::symex_function_call(
178178
{
179179
const exprt &function = instruction.call_function();
180180

181-
// If at some point symex_function_call can support more
182-
// expression ids(), like ID_Dereference, please expand the
183-
// precondition appropriately.
184-
PRECONDITION(function.id() == ID_symbol);
185-
186-
symex_function_call_symbol(
187-
get_goto_function,
188-
state,
189-
instruction.call_lhs(),
190-
to_symbol_expr(instruction.call_function()),
191-
instruction.call_arguments());
181+
PRECONDITION(function.id() == ID_symbol || function.id() == ID_dereference);
182+
183+
if(function.id() == ID_symbol)
184+
{
185+
symex_function_call_symbol(
186+
get_goto_function,
187+
state,
188+
instruction.call_lhs(),
189+
to_symbol_expr(function),
190+
instruction.call_arguments());
191+
}
192+
else if(function.id() == ID_dereference)
193+
{
194+
symex_function_call_dereference(
195+
get_goto_function,
196+
state,
197+
instruction.call_lhs(),
198+
to_dereference_expr(function),
199+
instruction.call_arguments());
200+
}
192201
}
193202

194203
void goto_symext::symex_function_call_symbol(
@@ -218,6 +227,19 @@ void goto_symext::symex_function_call_symbol(
218227
get_goto_function, state, cleaned_lhs, function, cleaned_arguments);
219228
}
220229

230+
void goto_symext::symex_function_call_dereference(
231+
const get_goto_functiont &get_goto_function,
232+
statet &state,
233+
const exprt &lhs,
234+
const dereference_exprt &function,
235+
const exprt::operandst &arguments)
236+
{
237+
// need to clean the function pointer expression
238+
auto cleaned_function = clean_expr(function, state, false);
239+
240+
// we get an if-then-else nest that contains symbols
241+
}
242+
221243
void goto_symext::symex_function_call_post_clean(
222244
const get_goto_functiont &get_goto_function,
223245
statet &state,

0 commit comments

Comments
 (0)