CBMC
symex_function_call.cpp
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Symbolic Execution of ANSI-C
4 
5 Author: Daniel Kroening, kroening@kroening.com
6 
7 \*******************************************************************/
8 
11 
12 #include "goto_symex.h"
13 
14 #include <util/arith_tools.h>
15 #include <util/byte_operators.h>
16 #include <util/c_types.h>
17 #include <util/exception_utils.h>
18 #include <util/fresh_symbol.h>
19 #include <util/invariant.h>
20 #include <util/prefix.h>
21 #include <util/range.h>
22 #include <util/std_code.h>
23 
24 #include "expr_skeleton.h"
25 #include "path_storage.h"
26 #include "symex_assign.h"
27 
28 static void locality(
29  const irep_idt &function_identifier,
30  goto_symext::statet &state,
31  path_storaget &path_storage,
32  const goto_functionst::goto_functiont &goto_function,
33  const namespacet &ns);
34 
35 bool goto_symext::get_unwind_recursion(const irep_idt &, unsigned, unsigned)
36 {
37  return false;
38 }
39 
41  const irep_idt &function_identifier,
42  const goto_functionst::goto_functiont &goto_function,
43  statet &state,
44  const exprt::operandst &arguments)
45 {
46  // iterates over the arguments
47  exprt::operandst::const_iterator it1=arguments.begin();
48 
49  // iterates over the types of the parameters
50  for(const auto &identifier : goto_function.parameter_identifiers)
51  {
52  INVARIANT(
53  !identifier.empty(), "function parameter must have an identifier");
54  state.call_stack().top().parameter_names.push_back(identifier);
55 
56  const symbolt &symbol=ns.lookup(identifier);
57  symbol_exprt lhs=symbol.symbol_expr();
58 
59  // this is the type that the n-th argument should have
60  const typet &parameter_type = symbol.type;
61 
62  exprt rhs;
63 
64  // if you run out of actual arguments there was a mismatch
65  if(it1==arguments.end())
66  {
67  log.warning() << state.source.pc->source_location().as_string()
68  << ": "
69  "call to '"
70  << id2string(function_identifier)
71  << "': "
72  "not enough arguments, inserting non-deterministic value"
73  << log.eom;
74 
76  parameter_type, state.source.pc->source_location());
77  }
78  else
79  rhs=*it1;
80 
81  if(rhs.is_nil())
82  {
83  // 'nil' argument doesn't get assigned
84  }
85  else
86  {
87  // It should be the same exact type.
88  if(parameter_type != rhs.type())
89  {
90  const typet &rhs_type = rhs.type();
91 
92  // But we are willing to do some limited conversion.
93  // This is highly dubious, obviously.
94  // clang-format off
95  if(
96  (parameter_type.id() == ID_signedbv ||
97  parameter_type.id() == ID_unsignedbv ||
98  parameter_type.id() == ID_c_enum_tag ||
99  parameter_type.id() == ID_bool ||
100  parameter_type.id() == ID_pointer ||
101  parameter_type.id() == ID_union ||
102  parameter_type.id() == ID_union_tag) &&
103  (rhs_type.id() == ID_signedbv ||
104  rhs_type.id() == ID_unsignedbv ||
105  rhs_type.id() == ID_c_bit_field ||
106  rhs_type.id() == ID_c_enum_tag ||
107  rhs_type.id() == ID_bool ||
108  rhs_type.id() == ID_pointer ||
109  rhs_type.id() == ID_union ||
110  rhs_type.id() == ID_union_tag))
111  // clang-format on
112  {
113  rhs = make_byte_extract(
114  rhs, from_integer(0, c_index_type()), parameter_type);
115  }
116  else
117  {
118  std::ostringstream error;
119  error << state.source.pc->source_location().as_string() << ": "
120  << "function call: parameter \"" << identifier
121  << "\" type mismatch:\ngot " << rhs.type().pretty()
122  << "\nexpected " << parameter_type.pretty();
123  throw unsupported_operation_exceptiont(error.str());
124  }
125  }
126 
127  assignment_typet assignment_type;
128 
129  // We hide if we are in a hidden function.
130  if(state.call_stack().top().hidden_function)
131  assignment_type =
133  else
134  assignment_type =
136 
137  lhs = to_symbol_expr(clean_expr(std::move(lhs), state, true));
138  rhs = clean_expr(std::move(rhs), state, false);
139 
140  exprt::operandst lhs_conditions;
141  symex_assignt{state, assignment_type, ns, symex_config, target}
142  .assign_rec(lhs, expr_skeletont{}, rhs, lhs_conditions);
143  }
144 
145  if(it1!=arguments.end())
146  it1++;
147  }
148 
149  if(to_code_type(ns.lookup(function_identifier).type).has_ellipsis())
150  {
151  // These are va_arg arguments; their types may differ from call to call
152  for(; it1 != arguments.end(); it1++)
153  {
154  symbolt &va_arg = get_fresh_aux_symbol(
155  it1->type(),
156  id2string(function_identifier),
157  "va_arg",
158  state.source.pc->source_location(),
159  ns.lookup(function_identifier).mode,
160  state.symbol_table);
161  va_arg.is_parameter = true;
162 
163  state.call_stack().top().parameter_names.push_back(va_arg.name);
164 
165  symex_assign(state, va_arg.symbol_expr(), *it1);
166  }
167  }
168  else if(it1!=arguments.end())
169  {
170  // we got too many arguments, but we will just ignore them
171  }
172 }
173 
175  const get_goto_functiont &get_goto_function,
176  statet &state,
177  const goto_programt::instructiont &instruction)
178 {
179  const exprt &function = instruction.call_function();
180 
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 
188  state,
189  instruction.call_lhs(),
190  to_symbol_expr(instruction.call_function()),
191  instruction.call_arguments());
192 }
193 
195  const get_goto_functiont &get_goto_function,
196  statet &state,
197  const exprt &lhs,
198  const symbol_exprt &function,
199  const exprt::operandst &arguments)
200 {
201  exprt cleaned_lhs;
202 
203  if(lhs.is_nil())
204  cleaned_lhs = lhs;
205  else
206  cleaned_lhs = clean_expr(lhs, state, true);
207 
208  // no need to clean the function, which is a symbol only
209 
210  exprt::operandst cleaned_arguments;
211 
212  for(auto &argument : arguments)
213  cleaned_arguments.push_back(clean_expr(argument, state, false));
214 
215  target.location(state.guard.as_expr(), state.source);
216 
218  get_goto_function, state, cleaned_lhs, function, cleaned_arguments);
219 }
220 
222  const get_goto_functiont &get_goto_function,
223  statet &state,
224  const exprt &cleaned_lhs,
225  const symbol_exprt &function,
226  const exprt::operandst &cleaned_arguments)
227 {
228  const irep_idt &identifier = function.get_identifier();
229 
230  const goto_functionst::goto_functiont &goto_function =
231  get_goto_function(identifier);
232 
233  path_storage.dirty.populate_dirty_for_function(identifier, goto_function);
234 
235  auto emplace_safe_pointers_result =
236  path_storage.safe_pointers.emplace(identifier, local_safe_pointerst{});
237  if(emplace_safe_pointers_result.second)
238  emplace_safe_pointers_result.first->second(goto_function.body);
239 
240  const bool stop_recursing = get_unwind_recursion(
241  identifier,
242  state.source.thread_nr,
243  state.call_stack().top().loop_iterations[identifier].count);
244 
245  // see if it's too much
246  if(stop_recursing)
247  {
249  vcc(false_exprt(), "recursion unwinding assertion", state);
251  {
252  // Rule out this path:
253  symex_assume_l2(state, false_exprt());
254  }
255 
256  symex_transition(state);
257  return;
258  }
259 
260  // read the arguments -- before the locality renaming
261  const std::vector<renamedt<exprt, L2>> renamed_arguments =
262  make_range(cleaned_arguments).map([&](const exprt &a) {
263  return state.rename(a, ns);
264  });
265 
266  // we hide the call if the caller and callee are both hidden
267  const bool hidden =
268  state.call_stack().top().hidden_function && goto_function.is_hidden();
269 
270  // record the call
272  state.guard.as_expr(), identifier, renamed_arguments, state.source, hidden);
273 
274  if(!goto_function.body_available())
275  {
276  no_body(identifier);
277 
278  // record the return
280  state.guard.as_expr(), identifier, state.source, hidden);
281 
282  if(cleaned_lhs.is_not_nil())
283  {
284  const auto rhs = side_effect_expr_nondett(
285  cleaned_lhs.type(), state.source.pc->source_location());
286  symex_assign(state, cleaned_lhs, rhs);
287  }
288 
290  {
291  // assign non det to function arguments if pointers
292  // are not const
293  for(const auto &arg : cleaned_arguments)
294  {
295  if(
296  arg.type().id() == ID_pointer &&
297  !to_pointer_type(arg.type()).base_type().get_bool(ID_C_constant) &&
298  to_pointer_type(arg.type()).base_type().id() != ID_code)
299  {
300  exprt object =
301  dereference_exprt(arg, to_pointer_type(arg.type()).base_type());
302  exprt cleaned_object = clean_expr(object, state, true);
303  const guardt guard(true_exprt(), state.guard_manager);
304  havoc_rec(state, guard, cleaned_object);
305  }
306  }
307  }
308 
309  symex_transition(state);
310  return;
311  }
312 
313  // produce a new frame
314  PRECONDITION(!state.call_stack().empty());
315  framet &frame = state.call_stack().new_frame(state.source, state.guard);
316 
317  // Only enable loop analysis when complexity is enabled.
319  {
320  // Analyzes loops if required.
321  path_storage.add_function_loops(identifier, goto_function.body);
322  frame.loops_info = path_storage.get_loop_analysis(identifier);
323  }
324 
325  // preserve locality of local variables
326  locality(identifier, state, path_storage, goto_function, ns);
327 
328  // assign actuals to formal parameters
329  parameter_assignments(identifier, goto_function, state, cleaned_arguments);
330 
331  frame.call_lhs = cleaned_lhs;
332  frame.end_of_function = --goto_function.body.instructions.end();
333  frame.function_identifier=identifier;
334  frame.hidden_function = goto_function.is_hidden();
335 
336  // set up the 'return value symbol' when needed
337  if(frame.call_lhs.is_not_nil())
338  {
339  irep_idt return_value_symbol_identifier =
340  "goto_symex::return_value::" + id2string(identifier);
341 
342  if(!state.symbol_table.has_symbol(return_value_symbol_identifier))
343  {
344  const symbolt &function_symbol = ns.lookup(identifier);
346  new_symbol; // these are thread-local and have dynamic lifetime
347  new_symbol.base_name = "return_value";
348  new_symbol.name = return_value_symbol_identifier;
349  new_symbol.type = to_code_type(function_symbol.type).return_type();
350  new_symbol.mode = function_symbol.mode;
351  state.symbol_table.add(new_symbol);
352  }
353 
354  frame.return_value_symbol =
355  ns.lookup(return_value_symbol_identifier).symbol_expr();
356  }
357 
358  const framet &p_frame = state.call_stack().previous_frame();
359  for(const auto &pair : p_frame.loop_iterations)
360  {
361  if(pair.second.is_recursion)
362  frame.loop_iterations.insert(pair);
363  }
364 
365  // increase unwinding counter
366  frame.loop_iterations[identifier].is_recursion=true;
367  frame.loop_iterations[identifier].count++;
368 
369  state.source.function_id = identifier;
370  symex_transition(state, goto_function.body.instructions.begin(), false);
371 }
372 
374 static void pop_frame(
375  goto_symext::statet &state,
376  const path_storaget &path_storage,
377  bool doing_path_exploration)
378 {
379  PRECONDITION(!state.call_stack().empty());
380 
381  const framet &frame = state.call_stack().top();
382 
383  // restore program counter
384  symex_transition(state, frame.calling_location.pc, false);
386 
387  // restore L1 renaming
388  state.level1.restore_from(frame.old_level1);
389 
390  // If the program is multi-threaded then the state guard is used to
391  // accumulate assumptions (in symex_assume_l2) and must be left alone.
392  // If however it is single-threaded then we should restore the guard, as the
393  // guard coming out of the function may be more complex (e.g. if the callee
394  // was { if(x) while(true) { } } then the guard may still be `!x`),
395  // but at this point all control-flow paths have either converged or been
396  // proven unviable, so we can stop specifying the callee's constraints when
397  // we generate an assumption or VCC.
398 
399  // If we're doing path exploration then we do tail-duplication, and we
400  // actually *are* in a more-restricted context than we were when the
401  // function began.
402  if(state.threads.size() == 1 && !doing_path_exploration)
403  {
404  state.guard = frame.guard_at_function_start;
405  }
406 
407  for(const irep_idt &l1_o_id : frame.local_objects)
408  {
409  const auto l2_entry_opt = state.get_level2().current_names.find(l1_o_id);
410 
411  if(
412  l2_entry_opt.has_value() &&
413  (state.threads.size() == 1 ||
414  !path_storage.dirty(l2_entry_opt->get().first.get_object_name())))
415  {
416  state.drop_existing_l1_name(l1_o_id);
417  }
418  }
419 
420  state.call_stack().pop();
421 }
422 
425 {
426  PRECONDITION(!state.call_stack().empty());
427 
428  const bool hidden = state.call_stack().top().hidden_function;
429 
430  // first record the return
432  state.guard.as_expr(), state.source.function_id, state.source, hidden);
433 
434  // before we drop the frame, remember the call LHS
435  // and the return value symbol, if any
436  auto call_lhs = state.call_stack().top().call_lhs;
438 
439  // now get rid of the frame
441 
442  // after dropping the frame, assign the return value, if any
443  if(state.reachable && call_lhs.is_not_nil())
444  {
446  return_value_symbol.has_value(),
447  "must have return value symbol when assigning call lhs");
448  // the type of the call lhs and the return type might not match
449  auto casted_return_value = typecast_exprt::conditional_cast(
450  return_value_symbol.value(), call_lhs.type());
451  symex_assign(state, call_lhs, casted_return_value);
452  }
453 }
454 
457 static void locality(
458  const irep_idt &function_identifier,
459  goto_symext::statet &state,
460  path_storaget &path_storage,
461  const goto_functionst::goto_functiont &goto_function,
462  const namespacet &ns)
463 {
464  unsigned &frame_nr=
465  state.threads[state.source.thread_nr].function_frame[function_identifier];
466  frame_nr++;
467 
468  for(const auto &param : goto_function.parameter_identifiers)
469  {
470  (void)state.add_object(
471  ns.lookup(param).symbol_expr(),
472  [&path_storage, &frame_nr](const irep_idt &l0_name) {
473  return path_storage.get_unique_l1_index(l0_name, frame_nr);
474  },
475  ns);
476  }
477 }
symex_configt::havoc_undefined_functions
bool havoc_undefined_functions
Definition: symex_config.h:37
guard_exprt
Definition: guard_expr.h:23
goto_symext::clean_expr
exprt clean_expr(exprt expr, statet &state, bool write)
Clean up an expression.
Definition: symex_clean_expr.cpp:227
symbol_table_baset::has_symbol
bool has_symbol(const irep_idt &name) const
Check whether a symbol exists in the symbol table.
Definition: symbol_table_base.h:87
exception_utils.h
dstringt
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:36
symex_targett::assignment_typet
assignment_typet
Definition: symex_target.h:68
code_typet::has_ellipsis
bool has_ellipsis() const
Definition: std_types.h:611
make_byte_extract
byte_extract_exprt make_byte_extract(const exprt &_op, const exprt &_offset, const typet &_type)
Construct a byte_extract_exprt with endianness and byte width matching the current configuration.
Definition: byte_operators.cpp:48
typecast_exprt::conditional_cast
static exprt conditional_cast(const exprt &expr, const typet &type)
Definition: std_expr.h:2025
goto_symext::symex_assume_l2
void symex_assume_l2(statet &, const exprt &cond)
Definition: symex_main.cpp:220
symex_configt::partial_loops
bool partial_loops
Definition: symex_config.h:35
symex_assign.h
symex_level1t::restore_from
void restore_from(const symex_level1t &other)
Insert the content of other into this renaming.
Definition: renaming_level.cpp:109
goto_symex_statet::level1
symex_level1t level1
Definition: goto_symex_state.h:72
arith_tools.h
symex_target_equationt::function_return
virtual void function_return(const exprt &guard, const irep_idt &function_id, const sourcet &source, bool hidden)
Record return from a function.
Definition: symex_target_equation.cpp:200
typet
The type of an expression, extends irept.
Definition: type.h:28
goto_statet::reachable
bool reachable
Is this code reachable? If not we can take shortcuts such as not entering function calls,...
Definition: goto_state.h:62
fresh_symbol.h
irept::pretty
std::string pretty(unsigned indent=0, unsigned max_indent=0) const
Definition: irep.cpp:495
symex_targett::sourcet::pc
goto_programt::const_targett pc
Definition: symex_target.h:42
expr_skeleton.h
goto_symext::target
symex_target_equationt & target
The equation that this execution is building up.
Definition: goto_symex.h:251
path_storaget
Storage for symbolic execution paths to be resumed later.
Definition: path_storage.h:37
symbolt::type
typet type
Type of symbol.
Definition: symbol.h:31
dereference_exprt
Operator to dereference a pointer.
Definition: pointer_expr.h:659
goto_symext::path_storage
path_storaget & path_storage
Symbolic execution paths to be resumed later.
Definition: goto_symex.h:788
goto_symex_statet
Central data structure: state.
Definition: goto_symex_state.h:41
framet::function_identifier
irep_idt function_identifier
Definition: frame.h:28
call_stackt::pop
void pop()
Definition: call_stack.h:36
unsupported_operation_exceptiont
Thrown when we encounter an instruction, parameters to an instruction etc.
Definition: exception_utils.h:144
framet::calling_location
symex_targett::sourcet calling_location
Definition: frame.h:30
local_safe_pointerst
A very simple, cheap analysis to determine when dereference operations are trivially guarded by a che...
Definition: local_safe_pointers.h:27
goto_symex_statet::guard_manager
guard_managert & guard_manager
Definition: goto_symex_state.h:69
goto_symext::symex_function_call_post_clean
virtual void symex_function_call_post_clean(const get_goto_functiont &get_goto_function, statet &state, const exprt &cleaned_lhs, const symbol_exprt &function, const exprt::operandst &cleaned_arguments)
Symbolic execution of a function call by inlining.
Definition: symex_function_call.cpp:221
symex_targett::sourcet::thread_nr
unsigned thread_nr
Definition: symex_target.h:38
prefix.h
invariant.h
exprt
Base class for all expressions.
Definition: expr.h:55
framet::guard_at_function_start
guardt guard_at_function_start
Definition: frame.h:32
goto_symex_statet::source
symex_targett::sourcet source
Definition: goto_symex_state.h:61
symbolt::base_name
irep_idt base_name
Base (non-scoped) name.
Definition: symbol.h:46
symex_assignt
Functor for symex assignment.
Definition: symex_assign.h:25
messaget::eom
static eomt eom
Definition: message.h:297
auxiliary_symbolt
Internally generated symbol table entry.
Definition: symbol.h:146
symbol_exprt
Expression to hold a symbol (variable)
Definition: std_expr.h:112
framet::hidden_function
bool hidden_function
Definition: frame.h:36
goto_programt::instructiont::call_arguments
const exprt::operandst & call_arguments() const
Get the arguments of a FUNCTION_CALL.
Definition: goto_program.h:307
path_storage.h
Storage of symbolic execution paths to resume.
goto_symext::get_unwind_recursion
virtual bool get_unwind_recursion(const irep_idt &identifier, unsigned thread_nr, unsigned unwind)
Definition: symex_function_call.cpp:35
symex_targett::assignment_typet::VISIBLE_ACTUAL_PARAMETER
@ VISIBLE_ACTUAL_PARAMETER
goto_symext::log
messaget log
The messaget to write log messages to.
Definition: goto_symex.h:263
symex_target_equationt::location
virtual void location(const exprt &guard, const sourcet &source)
Record a location.
Definition: symex_target_equation.cpp:169
namespacet
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition: namespace.h:90
exprt::type
typet & type()
Return the type of the expression.
Definition: expr.h:84
call_stackt::new_frame
framet & new_frame(symex_targett::sourcet calling_location, const guardt &guard)
Definition: call_stack.h:30
namespacet::lookup
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See documentation for namespace_baset::lookup().
Definition: namespace.cpp:138
irept::is_not_nil
bool is_not_nil() const
Definition: irep.h:380
goto_symex_statet::threads
std::vector< threadt > threads
Definition: goto_symex_state.h:196
framet::parameter_names
std::vector< irep_idt > parameter_names
Definition: frame.h:31
path_storaget::get_loop_analysis
std::shared_ptr< lexical_loopst > get_loop_analysis(const irep_idt &function_id)
Definition: path_storage.h:131
goto_symext::parameter_assignments
void parameter_assignments(const irep_idt &function_identifier, const goto_functionst::goto_functiont &goto_function, statet &state, const exprt::operandst &arguments)
Iterates over arguments and assigns them to the parameters, which are symbols whose name and type are...
Definition: symex_function_call.cpp:40
byte_operators.h
Expression classes for byte-level operators.
to_code_type
const code_typet & to_code_type(const typet &type)
Cast a typet to a code_typet.
Definition: std_types.h:744
framet::loops_info
std::shared_ptr< lexical_loopst > loops_info
Definition: frame.h:70
goto_symex_statet::call_stack
call_stackt & call_stack()
Definition: goto_symex_state.h:144
symbolt::mode
irep_idt mode
Language mode.
Definition: symbol.h:49
framet::return_value_symbol
optionalt< symbol_exprt > return_value_symbol
Definition: frame.h:35
DATA_INVARIANT
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
Definition: invariant.h:510
call_stackt::top
framet & top()
Definition: call_stack.h:17
id2string
const std::string & id2string(const irep_idt &d)
Definition: irep.h:47
goto_symex_statet::symbol_table
symbol_tablet symbol_table
contains symbols that are minted during symbolic execution, such as dynamically created objects etc.
Definition: goto_symex_state.h:66
symex_targett::assignment_typet::HIDDEN_ACTUAL_PARAMETER
@ HIDDEN_ACTUAL_PARAMETER
pop_frame
static void pop_frame(goto_symext::statet &state, const path_storaget &path_storage, bool doing_path_exploration)
pop one call frame
Definition: symex_function_call.cpp:374
goto_symext::symex_function_call_symbol
virtual void symex_function_call_symbol(const get_goto_functiont &get_goto_function, statet &state, const exprt &lhs, const symbol_exprt &function, const exprt::operandst &arguments)
Symbolic execution of a call to a function call.
Definition: symex_function_call.cpp:194
guard_exprt::as_expr
exprt as_expr() const
Definition: guard_expr.h:46
PRECONDITION
#define PRECONDITION(CONDITION)
Definition: invariant.h:463
symex_configt::doing_path_exploration
bool doing_path_exploration
Definition: symex_config.h:23
symex_configt::unwinding_assertions
bool unwinding_assertions
Definition: symex_config.h:33
incremental_dirtyt::populate_dirty_for_function
void populate_dirty_for_function(const irep_idt &id, const goto_functionst::goto_functiont &function)
Analyse the given function with dirtyt if it hasn't been seen before.
Definition: dirty.cpp:112
goto_symex_statet::rename
renamedt< exprt, level > rename(exprt expr, const namespacet &ns)
Rewrites symbol expressions in exprt, applying a suffix to each symbol reflecting its most recent ver...
Definition: goto_symex_state.cpp:169
goto_symex.h
goto_statet::guard
guardt guard
Definition: goto_state.h:58
framet::loop_iterations
std::unordered_map< irep_idt, loop_infot > loop_iterations
Definition: frame.h:73
symbolt::symbol_expr
class symbol_exprt symbol_expr() const
Produces a symbol_exprt for a symbol.
Definition: symbol.cpp:121
goto_symext::symex_end_of_function
virtual void symex_end_of_function(statet &)
Symbolically execute a END_FUNCTION instruction.
Definition: symex_function_call.cpp:424
to_pointer_type
const pointer_typet & to_pointer_type(const typet &type)
Cast a typet to a pointer_typet.
Definition: pointer_expr.h:79
path_storaget::dirty
incremental_dirtyt dirty
Local variables are considered 'dirty' if they've had an address taken and therefore may be referred ...
Definition: path_storage.h:116
to_symbol_expr
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
Definition: std_expr.h:222
symbolt::is_parameter
bool is_parameter
Definition: symbol.h:67
irept::is_nil
bool is_nil() const
Definition: irep.h:376
irept::id
const irep_idt & id() const
Definition: irep.h:396
framet::end_of_function
goto_programt::const_targett end_of_function
Definition: frame.h:33
range.h
exprt::operandst
std::vector< exprt > operandst
Definition: expr.h:58
path_storaget::add_function_loops
void add_function_loops(const irep_idt &identifier, const goto_programt &body)
Generates a loop analysis for the instructions in goto_programt and keys it against function ID.
Definition: path_storage.h:120
false_exprt
The Boolean constant false.
Definition: std_expr.h:3016
framet
Stack frames – these are used for function calls and for exceptions.
Definition: frame.h:21
framet::old_level1
symex_level1t old_level1
Definition: frame.h:38
goto_programt::instructiont::call_lhs
const exprt & call_lhs() const
Get the lhs of a FUNCTION_CALL (may be nil)
Definition: goto_program.h:293
std_code.h
goto_symext::symex_function_call
virtual void symex_function_call(const get_goto_functiont &get_goto_function, statet &state, const goto_programt::instructiont &instruction)
Symbolically execute a FUNCTION_CALL instruction.
Definition: symex_function_call.cpp:174
symex_transition
void symex_transition(goto_symext::statet &state)
Transition to the next instruction, which increments the internal program counter and initializes the...
Definition: symex_main.cpp:148
side_effect_expr_nondett
A side_effect_exprt that returns a non-deterministically chosen value.
Definition: std_code.h:1519
goto_functionst::goto_functiont
::goto_functiont goto_functiont
Definition: goto_functions.h:27
goto_symext::havoc_rec
void havoc_rec(statet &state, const guardt &guard, const exprt &dest)
Definition: symex_other.cpp:20
goto_symext::ns
namespacet ns
Initialized just before symbolic execution begins, to point to both outer_symbol_table and the symbol...
Definition: goto_symex.h:243
symbol_table_baset::add
bool add(const symbolt &symbol)
Add a new symbol to the symbol table.
Definition: symbol_table_base.cpp:18
symex_configt::complexity_limits_active
bool complexity_limits_active
Whether this run of symex is under complexity limits.
Definition: symex_config.h:54
call_stackt::previous_frame
const framet & previous_frame()
Definition: call_stack.h:42
symex_level2t::current_names
symex_renaming_levelt current_names
Definition: renaming_level.h:70
path_storaget::safe_pointers
std::unordered_map< irep_idt, local_safe_pointerst > safe_pointers
Map function identifiers to local_safe_pointerst instances.
Definition: path_storage.h:100
symex_target_equationt::function_call
virtual void function_call(const exprt &guard, const irep_idt &function_id, const std::vector< renamedt< exprt, L2 >> &ssa_function_arguments, const sourcet &source, bool hidden)
Record a function call.
Definition: symex_target_equation.cpp:181
symbolt
Symbol table entry.
Definition: symbol.h:27
from_integer
constant_exprt from_integer(const mp_integer &int_value, const typet &type)
Definition: arith_tools.cpp:100
goto_statet::get_level2
const symex_level2t & get_level2() const
Definition: goto_state.h:45
goto_symext::vcc
virtual void vcc(const exprt &, const std::string &msg, statet &)
Definition: symex_main.cpp:183
goto_symext::get_goto_function
static get_goto_functiont get_goto_function(abstract_goto_modelt &goto_model)
Return a function to get/load a goto function from the given goto model Create a default delegate to ...
Definition: symex_main.cpp:493
goto_symext::symex_config
const symex_configt symex_config
The configuration to use for this symbolic execution.
Definition: goto_symex.h:170
pointer_typet::base_type
const typet & base_type() const
The type of the data what we point to.
Definition: pointer_expr.h:35
framet::local_objects
std::set< irep_idt > local_objects
Definition: frame.h:40
path_storaget::get_unique_l1_index
std::size_t get_unique_l1_index(const irep_idt &id, std::size_t minimum_index)
Provide a unique L1 index for a given id, starting from minimum_index.
Definition: path_storage.h:104
goto_symext::get_goto_functiont
std::function< const goto_functionst::goto_functiont &(const irep_idt &)> get_goto_functiont
The type of delegate functions that retrieve a goto_functiont for a particular function identifier.
Definition: goto_symex.h:82
return_value_symbol
symbol_exprt return_value_symbol(const irep_idt &identifier, const namespacet &ns)
produces the symbol that is used to store the return value of the function with the given identifier
Definition: remove_returns.cpp:409
code_typet::return_type
const typet & return_type() const
Definition: std_types.h:645
goto_symext::no_body
virtual void no_body(const irep_idt &identifier)
Log a warning that a function has no body.
Definition: goto_symex.h:428
locality
static void locality(const irep_idt &function_identifier, goto_symext::statet &state, path_storaget &path_storage, const goto_functionst::goto_functiont &goto_function, const namespacet &ns)
Preserves locality of parameters of a given function by applying L1 renaming to them.
Definition: symex_function_call.cpp:457
symex_targett::sourcet::function_id
irep_idt function_id
Definition: symex_target.h:39
true_exprt
The Boolean constant true.
Definition: std_expr.h:3007
messaget::warning
mstreamt & warning() const
Definition: message.h:404
c_index_type
bitvector_typet c_index_type()
Definition: c_types.cpp:16
goto_programt::instructiont
This class represents an instruction in the GOTO intermediate representation.
Definition: goto_program.h:180
goto_symext::symex_assign
void symex_assign(statet &state, const exprt &lhs, const exprt &rhs)
Symbolically execute an ASSIGN instruction or simulate such an execution for a synthetic assignment.
Definition: goto_symex.cpp:40
goto_symex_statet::add_object
ssa_exprt add_object(const symbol_exprt &expr, std::function< std::size_t(const irep_idt &)> index_generator, const namespacet &ns)
Instantiate the object expr.
Definition: goto_symex_state.cpp:790
make_range
ranget< iteratort > make_range(iteratort begin, iteratort end)
Definition: range.h:524
c_types.h
get_fresh_aux_symbol
symbolt & get_fresh_aux_symbol(const typet &type, const std::string &name_prefix, const std::string &basename_prefix, const source_locationt &source_location, const irep_idt &symbol_mode, const namespacet &ns, symbol_table_baset &symbol_table)
Installs a fresh-named symbol with respect to the given namespace ns with the requested name pattern ...
Definition: fresh_symbol.cpp:32
goto_programt::instructiont::call_function
const exprt & call_function() const
Get the function that is called for FUNCTION_CALL.
Definition: goto_program.h:279
symbolt::name
irep_idt name
The unique identifier.
Definition: symbol.h:40
irept::get_bool
bool get_bool(const irep_idt &name) const
Definition: irep.cpp:58
framet::call_lhs
exprt call_lhs
Definition: frame.h:34
goto_symex_statet::drop_existing_l1_name
void drop_existing_l1_name(const irep_idt &l1_identifier)
Drops an L1 name from the local L2 map.
Definition: goto_symex_state.h:230
expr_skeletont
Expression in which some part is missing and can be substituted for another expression.
Definition: expr_skeleton.h:25
validation_modet::INVARIANT
@ INVARIANT
sharing_mapt::find
optionalt< std::reference_wrapper< const mapped_type > > find(const key_type &k) const
Find element.
Definition: sharing_map.h:1451