Skip to content

Commit d34c665

Browse files
Initialize shadow memory for function parameters
This triggers the allocation of local-scope\ shadow memory.
1 parent 3116be7 commit d34c665

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

src/goto-symex/goto_symex.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,16 @@ class goto_symext
463463
statet &state,
464464
const goto_programt::instructiont &instruction);
465465

466+
/// Preserves locality of parameters of a given function by applying L1
467+
/// renaming to them.
468+
/// \param function_identifier The parameter identifier
469+
/// \param state The current state
470+
/// \param goto_function The goto function
471+
virtual void locality(
472+
const irep_idt &function_identifier,
473+
goto_symext::statet &state,
474+
const goto_functionst::goto_functiont &goto_function);
475+
466476
/// Symbolically execute a END_FUNCTION instruction.
467477
/// \param state: Symbolic execution state for current instruction
468478
virtual void symex_end_of_function(statet &);

src/goto-symex/symex_function_call.cpp

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,6 @@ Author: Daniel Kroening, [email protected]
2424
#include "path_storage.h"
2525
#include "symex_assign.h"
2626

27-
static void locality(
28-
const irep_idt &function_identifier,
29-
goto_symext::statet &state,
30-
path_storaget &path_storage,
31-
const goto_functionst::goto_functiont &goto_function,
32-
const namespacet &ns);
33-
3427
bool goto_symext::get_unwind_recursion(const irep_idt &, unsigned, unsigned)
3528
{
3629
return false;
@@ -328,7 +321,7 @@ void goto_symext::symex_function_call_post_clean(
328321
}
329322

330323
// preserve locality of local variables
331-
locality(identifier, state, path_storage, goto_function, ns);
324+
locality(identifier, state, goto_function);
332325

333326
// assign actuals to formal parameters
334327
parameter_assignments(identifier, goto_function, state, cleaned_arguments);
@@ -457,26 +450,26 @@ void goto_symext::symex_end_of_function(statet &state)
457450
}
458451
}
459452

460-
/// Preserves locality of parameters of a given function by applying L1
461-
/// renaming to them.
462-
static void locality(
453+
void goto_symext::locality(
463454
const irep_idt &function_identifier,
464455
goto_symext::statet &state,
465-
path_storaget &path_storage,
466-
const goto_functionst::goto_functiont &goto_function,
467-
const namespacet &ns)
456+
const goto_functionst::goto_functiont &goto_function)
468457
{
469458
unsigned &frame_nr=
470459
state.threads[state.source.thread_nr].function_frame[function_identifier];
471460
frame_nr++;
472461

473462
for(const auto &param : goto_function.parameter_identifiers)
474463
{
475-
(void)state.add_object(
464+
const ssa_exprt &renamed_param = state.add_object(
476465
ns.lookup(param).symbol_expr(),
477-
[&path_storage, &frame_nr](const irep_idt &l0_name) {
466+
[this, &frame_nr](const irep_idt &l0_name) {
478467
return path_storage.get_unique_l1_index(l0_name, frame_nr);
479468
},
480469
ns);
470+
471+
// Allocate shadow memory for parameters.
472+
// They are like local variables.
473+
shadow_memory.symex_field_local_init(state, renamed_param);
481474
}
482475
}

0 commit comments

Comments
 (0)