CBMC
instrument_spec_assigns.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Instrument assigns clauses in code contracts.
4 
5 Author: Remi Delmas
6 
7 Date: January 2022
8 
9 \*******************************************************************/
10 
13 
14 #ifndef CPROVER_GOTO_INSTRUMENT_CONTRACTS_INSTRUMENT_SPEC_ASSIGNS_H
15 #define CPROVER_GOTO_INSTRUMENT_CONTRACTS_INSTRUMENT_SPEC_ASSIGNS_H
16 
17 #include <util/message.h>
18 
20 
21 #include <ansi-c/c_expr.h>
22 
23 #include "utils.h"
24 
25 #include <optional>
26 #include <unordered_map>
27 #include <unordered_set>
28 
29 // forward declarations
31 class namespacet;
32 class symbol_tablet;
33 class symbolt;
34 class cfg_infot;
35 
38 {
39 public:
40  conditional_target_exprt(const exprt &_condition, const exprt &_target)
41  : exprt(irep_idt{}, typet{}, {_condition, _target})
42  {
43  INVARIANT(
44  !has_subexpr(_condition, ID_side_effect),
45  "condition must have no side_effect sub-expression");
46  add_source_location() = _target.source_location();
47  }
48 
50  const exprt &condition() const
51  {
52  return operands()[0];
53  }
54 
56  const exprt &target() const
57  {
58  return operands()[1];
59  }
60 };
61 
64 {
68 };
69 
76 class car_exprt : public exprt
77 {
78 public:
80  const exprt &_condition,
81  const exprt &_target,
82  const exprt &_target_start_address,
83  const exprt &_target_size,
84  const symbol_exprt &_validity_var,
85  const symbol_exprt &_lower_bound_var,
86  const symbol_exprt &_upper_bound_var,
87  const car_havoc_methodt _havoc_method)
88  : exprt(
89  irep_idt{},
90  typet{},
91  {_condition,
92  _target,
93  _target_start_address,
94  _target_size,
95  _validity_var,
96  _lower_bound_var,
97  _upper_bound_var}),
98  havoc_method(_havoc_method)
99  {
100  add_source_location() = _target.source_location();
101  }
102 
105 
107  const exprt &condition() const
108  {
109  return operands()[0];
110  }
111 
113  const exprt &target() const
114  {
115  return operands()[1];
116  }
117 
120  {
121  return operands()[2];
122  }
123 
125  const exprt &target_size() const
126  {
127  return operands()[3];
128  }
129 
131  const symbol_exprt &valid_var() const
132  {
133  return to_symbol_expr(operands()[4]);
134  }
135 
138  {
139  return to_symbol_expr(operands()[5]);
140  }
141 
144  {
145  return to_symbol_expr(operands()[6]);
146  }
147 };
148 
152 
156 
161 // "unsigned-overflow-check", "conversion-check".
163 
166 
173 
180 
190 {
191 public:
200  const irep_idt &_function_id,
201  const goto_functionst &_functions,
202  cfg_infot &_cfg_info,
203  symbol_tablet &_st,
204  message_handlert &_message_handler)
205  : function_id(_function_id),
206  functions(_functions),
207  cfg_info(_cfg_info),
208  st(_st),
209  ns(_st),
210  log(_message_handler),
211  mode(st.lookup_ref(function_id).mode)
212  {
213  }
214 
217  void track_spec_target(const exprt &expr, goto_programt &dest);
218 
220  void
221  track_stack_allocated(const symbol_exprt &symbol_expr, goto_programt &dest);
222 
224  bool stack_allocated_is_tracked(const symbol_exprt &symbol_expr) const;
225 
229  const symbol_exprt &symbol_expr,
230  goto_programt &dest);
231 
234  void track_heap_allocated(const exprt &expr, goto_programt &dest);
235 
243 
255  goto_programt &dest);
256 
257 protected:
265  {
266  public:
269  {
270  min_line = std::numeric_limits<std::size_t>::max();
271  min_col = std::numeric_limits<std::size_t>::max();
272  max_line = std::numeric_limits<std::size_t>::min();
273  max_col = std::numeric_limits<std::size_t>::min();
274  }
275 
278  void anywhere()
279  {
280  min_line = std::numeric_limits<std::size_t>::min();
281  min_col = std::numeric_limits<std::size_t>::min();
282  max_line = std::numeric_limits<std::size_t>::max();
283  max_col = std::numeric_limits<std::size_t>::max();
284  }
285 
287  void update(const source_locationt &source_location)
288  {
289  PRECONDITION(source_location.is_not_nil());
290  // use pessimistic lowest value to update min for undefined
291  update_min(
293  source_location, std::numeric_limits<std::size_t>::min()),
295  source_location, std::numeric_limits<std::size_t>::min()));
296 
297  // use pessimistic highest value to update max for undefined
298  update_max(
300  source_location, std::numeric_limits<std::size_t>::max()),
302  source_location, std::numeric_limits<std::size_t>::max()));
303  }
304 
306  bool contains(const source_locationt &source_location)
307  {
308  if(source_location.is_not_nil())
309  {
310  return
311  // use pessimistic highest value to compare to min for undefined
312  is_lte(
313  min_line,
314  min_col,
316  source_location, std::numeric_limits<std::size_t>::max()),
318  source_location, std::numeric_limits<std::size_t>::max())) &&
319  // use pessimistic lowest value to compare to max for undefined
320  is_lte(
322  source_location, std::numeric_limits<std::size_t>::min()),
324  source_location, std::numeric_limits<std::size_t>::min()),
325  max_line,
326  max_col);
327  }
328  else
329  {
330  return true;
331  }
332  }
333 
334  private:
336  std::size_t col_to_size_t(
337  const source_locationt &source_location,
338  std::size_t default_value)
339  {
340  if(
341  source_location.get_line().empty() ||
342  source_location.get_column().empty())
343  {
344  return default_value;
345  }
346  else
347  {
348  std::stringstream stream(id2string(source_location.get_column()));
349  size_t res;
350  stream >> res;
351  return res;
352  }
353  }
354 
356  std::size_t line_to_size_t(
357  const source_locationt &source_location,
358  std::size_t default_value)
359  {
360  if(source_location.get_line().empty())
361  {
362  return default_value;
363  }
364  else
365  {
366  std::stringstream stream(id2string(source_location.get_line()));
367  size_t res;
368  stream >> res;
369  return res;
370  }
371  }
372 
374  static bool is_lte(size_t line0, size_t col0, size_t line1, size_t col1)
375  {
376  return (line0 < line1) || ((line0 == line1) && (col0 <= col1));
377  }
378 
381  void update_min(size_t line, size_t col)
382  {
383  if(is_lte(line, col, min_line, min_col))
384  {
385  min_line = line;
386  min_col = col;
387  }
388  }
389 
392  void update_max(size_t line, size_t col)
393  {
394  if(is_lte(max_line, max_col, line, col))
395  {
396  max_line = line;
397  max_col = col;
398  }
399  }
400 
401  std::size_t min_line;
402  std::size_t min_col;
403  std::size_t max_line;
404  std::size_t max_col;
405  };
406 
408  typedef std::unordered_map<irep_idt, location_intervalt> covered_locationst;
409  typedef std::unordered_set<symbol_exprt, irep_hash> propagated_static_localst;
410 
419  const irep_idt ambient_function_id,
422  covered_locationst &covered_locations,
423  propagated_static_localst &propagated) const;
424 
428  covered_locationst &covered_locations,
429  std::unordered_set<symbol_exprt, irep_hash> &dest);
430 
431 public:
436  void check_inclusion_assignment(const exprt &lhs, goto_programt &dest) const;
437 
442  const exprt &expr,
443  goto_programt &dest);
444 
456  goto_programt &body,
457  goto_programt::targett instruction_it,
458  const goto_programt::targett &instruction_end,
459  const std::function<bool(const goto_programt::targett &)> &pred = {});
460 
464  template <typename C>
465  void get_static_locals(std::insert_iterator<C> inserter) const
466  {
468  from_static_local.cbegin(),
469  from_static_local.cend(),
470  inserter,
471  // can use `const auto &` below once we switch to C++14
472  [](const symbol_exprt_to_car_mapt::value_type &s) { return s.first; });
473  }
474 
475 protected:
478 
481 
484 
487 
489  const namespacet ns;
490 
493 
495  const irep_idt &mode;
496 
500  const conditional_target_group_exprt &group,
501  goto_programt &dest);
502 
505  void track_plain_spec_target(const exprt &expr, goto_programt &dest);
506 
510  const std::string &suffix,
511  const typet &type,
512  const source_locationt &location) const;
513 
515  void create_snapshot(const car_exprt &car, goto_programt &dest) const;
516 
518  exprt
519  target_validity_expr(const car_exprt &car, bool allow_null_target) const;
520 
526  const car_exprt &car,
527  bool allow_null_target,
528  goto_programt &dest) const;
529 
532  const car_exprt &lhs,
533  const car_exprt &candidate_car) const;
534 
541  const car_exprt &lhs,
542  bool allow_null_lhs,
543  bool include_stack_allocated) const;
544 
552  const car_exprt &lhs,
553  bool allow_null_lhs,
554  bool include_stack_allocated,
555  goto_programt &dest) const;
556 
559  void invalidate_car(
560  const car_exprt &tracked_car,
561  const car_exprt &freed_car,
562  goto_programt &result) const;
563 
568  const car_exprt &freed_car,
569  goto_programt &dest) const;
570 
573  bool must_track_decl(const goto_programt::const_targett &target) const;
574 
577  bool must_track_dead(const goto_programt::const_targett &target) const;
578 
588  bool must_track_decl_or_dead(const irep_idt &ident) const;
589 
592 
597  goto_programt::targett &instruction_it,
598  goto_programt &body) const;
599 
604  goto_programt::targett &instruction_it,
605  goto_programt &body);
606 
607  using cond_target_exprt_to_car_mapt = std::
608  unordered_map<const conditional_target_exprt, const car_exprt, irep_hash>;
609 
613 
614  const car_exprt &
615  create_car_from_spec_assigns(const exprt &condition, const exprt &target);
616 
618  std::unordered_map<const symbol_exprt, const car_exprt, irep_hash>;
619 
622 
623  const car_exprt &create_car_from_stack_alloc(const symbol_exprt &target);
624 
625  using exprt_to_car_mapt =
626  std::unordered_map<const exprt, const car_exprt, irep_hash>;
627 
629  using car_expr_listt = std::list<car_exprt>;
631 
632  const car_exprt &create_car_from_heap_alloc(const exprt &target);
633 
637 
639 
642  car_exprt create_car_expr(const exprt &condition, const exprt &target) const;
643 };
644 
645 #endif // CPROVER_GOTO_INSTRUMENT_CONTRACTS_INSTRUMENT_SPEC_ASSIGNS_H
messaget
Class that provides messages with a built-in verbosity 'level'.
Definition: message.h:154
dstringt
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:36
symbol_tablet
The symbol table.
Definition: symbol_table.h:13
instrument_spec_assignst::from_spec_assigns
cond_target_exprt_to_car_mapt from_spec_assigns
Map from conditional target expressions of assigns clauses to corresponding conditional address range...
Definition: instrument_spec_assigns.h:612
has_subexpr
bool has_subexpr(const exprt &expr, const std::function< bool(const exprt &)> &pred)
returns true if the expression has a subexpression that satisfies pred
Definition: expr_util.cpp:139
instrument_spec_assignst::create_car_from_spec_assigns
const car_exprt & create_car_from_spec_assigns(const exprt &condition, const exprt &target)
Definition: instrument_spec_assigns.cpp:804
conditional_target_exprt
Class that represents a single conditional target.
Definition: instrument_spec_assigns.h:37
instrument_spec_assignst::traverse_instructions
void traverse_instructions(const irep_idt ambient_function_id, goto_programt::const_targett it, const goto_programt::const_targett end, covered_locationst &covered_locations, propagated_static_localst &propagated) const
Traverses the given list of instructions, updating the given coverage map, recursing into function ca...
Definition: instrument_spec_assigns.cpp:202
cfg_infot
Stores information about a goto function computed from its CFG.
Definition: cfg_info.h:38
typet
The type of an expression, extends irept.
Definition: type.h:28
transform
static abstract_object_pointert transform(const exprt &expr, const std::vector< abstract_object_pointert > &operands, const abstract_environmentt &environment, const namespacet &ns)
Definition: abstract_value_object.cpp:159
instrument_spec_assignst::check_inclusion_heap_allocated_and_invalidate_aliases
void check_inclusion_heap_allocated_and_invalidate_aliases(const exprt &expr, goto_programt &dest)
Generates inclusion check instructions for an argument passed to free.
Definition: instrument_spec_assigns.cpp:304
instrument_spec_assignst::create_snapshot
void create_snapshot(const car_exprt &car, goto_programt &dest) const
Returns snapshot instructions for a car_exprt.
Definition: instrument_spec_assigns.cpp:594
car_exprt::condition
const exprt & condition() const
Condition expression. When this condition holds the target is allowed.
Definition: instrument_spec_assigns.h:107
car_exprt::havoc_method
const car_havoc_methodt havoc_method
Method to use to havod the target.
Definition: instrument_spec_assigns.h:104
instrument_spec_assignst::from_stack_alloc
symbol_exprt_to_car_mapt from_stack_alloc
Map from DECL symbols to corresponding conditional address ranges.
Definition: instrument_spec_assigns.h:621
instrument_spec_assignst::location_intervalt
Represents an interval of source locations covered by the static local variable search.
Definition: instrument_spec_assigns.h:264
instrument_spec_assignst::check_inclusion_assignment
void check_inclusion_assignment(const exprt &lhs, goto_programt &dest) const
Generates inclusion check instructions for an assignment, havoc or havoc_object instruction.
Definition: instrument_spec_assigns.cpp:145
has_propagate_static_local_pragma
bool has_propagate_static_local_pragma(source_locationt &source_location)
True iff the pragma to mark assignments to static local variables that need to be propagated upwards ...
instrument_spec_assignst::invalidate_car
void invalidate_car(const car_exprt &tracked_car, const car_exprt &freed_car, goto_programt &result) const
Adds an assignment in dest to invalidate the tracked car if was valid before and was pointing to the ...
Definition: instrument_spec_assigns.cpp:876
source_locationt::get_column
const irep_idt & get_column() const
Definition: source_location.h:50
instrument_spec_assignst::invalidate_heap_and_spec_aliases
void invalidate_heap_and_spec_aliases(const car_exprt &freed_car, goto_programt &dest) const
Generates instructions to invalidate all targets aliased with a car that was passed to free,...
Definition: instrument_spec_assigns.cpp:893
instrument_spec_assignst::location_intervalt::update_max
void update_max(size_t line, size_t col)
Updates the max_line and max_col in place using the given values iff they are larger.
Definition: instrument_spec_assigns.h:392
conditional_target_exprt::conditional_target_exprt
conditional_target_exprt(const exprt &_condition, const exprt &_target)
Definition: instrument_spec_assigns.h:40
exprt
Base class for all expressions.
Definition: expr.h:55
instrument_spec_assignst::from_static_local
symbol_exprt_to_car_mapt from_static_local
Map to from detected or propagated static local symbols to corresponding conditional address ranges.
Definition: instrument_spec_assigns.h:636
instrument_spec_assignst::inclusion_check_assertion
void inclusion_check_assertion(const car_exprt &lhs, bool allow_null_lhs, bool include_stack_allocated, goto_programt &dest) const
Returns an inclusion check assertion of lhs over all tracked cars.
Definition: instrument_spec_assigns.cpp:676
instrument_spec_assignst::location_intervalt::update_min
void update_min(size_t line, size_t col)
Updates the min_line and min_col in place using the given values iff they are smaller.
Definition: instrument_spec_assigns.h:381
instrument_spec_assignst::location_intervalt::location_intervalt
location_intervalt()
Initializes to the empty interval.
Definition: instrument_spec_assigns.h:268
instrument_spec_assignst::get_static_locals
void get_static_locals(std::insert_iterator< C > inserter) const
Inserts the detected static local symbols into a target container.
Definition: instrument_spec_assigns.h:465
instrument_spec_assignst::target_validity_expr
exprt target_validity_expr(const car_exprt &car, bool allow_null_target) const
Returns the target validity expression for a car_exprt.
Definition: instrument_spec_assigns.cpp:626
car_exprt::target_size
const exprt & target_size() const
Size of the target in bytes.
Definition: instrument_spec_assigns.h:125
car_exprt::lower_bound_var
const symbol_exprt & lower_bound_var() const
Identifier of the lower address bound snapshot variable.
Definition: instrument_spec_assigns.h:137
symbol_exprt
Expression to hold a symbol (variable)
Definition: std_expr.h:112
car_havoc_methodt::HAVOC_OBJECT
@ HAVOC_OBJECT
instrument_spec_assignst
A class that generates instrumentation for assigns clause checking.
Definition: instrument_spec_assigns.h:189
source_locationt::get_line
const irep_idt & get_line() const
Definition: source_location.h:45
instrument_spec_assignst::target_validity_assertion
void target_validity_assertion(const car_exprt &car, bool allow_null_target, goto_programt &dest) const
Generates the target validity assertion for the given car and adds it to dest.
Definition: instrument_spec_assigns.cpp:645
instrument_spec_assignst::log
messaget log
Logger.
Definition: instrument_spec_assigns.h:492
instrument_spec_assignst::function_id
const irep_idt & function_id
Name of the instrumented function.
Definition: instrument_spec_assigns.h:477
namespacet
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition: namespace.h:90
car_exprt::upper_bound_var
const symbol_exprt & upper_bound_var() const
Identifier of the upper address bound snapshot variable.
Definition: instrument_spec_assigns.h:143
car_exprt::valid_var
const symbol_exprt & valid_var() const
Identifier of the validity snapshot variable.
Definition: instrument_spec_assigns.h:131
irept::is_not_nil
bool is_not_nil() const
Definition: irep.h:380
instrument_spec_assignst::cond_target_exprt_to_car_mapt
std::unordered_map< const conditional_target_exprt, const car_exprt, irep_hash > cond_target_exprt_to_car_mapt
Definition: instrument_spec_assigns.h:608
instrument_spec_assignst::ns
const namespacet ns
Program namespace.
Definition: instrument_spec_assigns.h:489
utils.h
car_exprt::car_exprt
car_exprt(const exprt &_condition, const exprt &_target, const exprt &_target_start_address, const exprt &_target_size, const symbol_exprt &_validity_var, const symbol_exprt &_lower_bound_var, const symbol_exprt &_upper_bound_var, const car_havoc_methodt _havoc_method)
Definition: instrument_spec_assigns.h:79
instrument_spec_assignst::create_car_expr
car_exprt create_car_expr(const exprt &condition, const exprt &target) const
Creates a conditional address range expression from a cleaned-up condition and target expression.
Definition: instrument_spec_assigns.cpp:452
id2string
const std::string & id2string(const irep_idt &d)
Definition: irep.h:47
car_havoc_methodt::NONDET_ASSIGN
@ NONDET_ASSIGN
instrument_spec_assignst::must_track_dead
bool must_track_dead(const goto_programt::const_targett &target) const
Returns true iff a DEAD x must be processed to update the write set.
Definition: instrument_spec_assigns.cpp:995
instrument_spec_assignst::inclusion_check_single
exprt inclusion_check_single(const car_exprt &lhs, const car_exprt &candidate_car) const
Returns inclusion check expression for a single candidate location.
Definition: instrument_spec_assigns.cpp:713
instrument_spec_assignst::st
symbol_tablet & st
Program symbol table.
Definition: instrument_spec_assigns.h:486
instrument_spec_assignst::create_car_from_static_local
const car_exprt & create_car_from_static_local(const symbol_exprt &target)
Definition: instrument_spec_assigns.cpp:856
c_expr.h
PRECONDITION
#define PRECONDITION(CONDITION)
Definition: invariant.h:463
add_propagate_static_local_pragma
void add_propagate_static_local_pragma(source_locationt &source_location)
Sets a pragma to mark assignments to static local variables that need to be propagated upwards in the...
Definition: instrument_spec_assigns.cpp:42
add_pragma_disable_assigns_check
void add_pragma_disable_assigns_check(source_locationt &source_location)
Adds a pragma on a source_locationt to disable inclusion checking.
Definition: instrument_spec_assigns.cpp:70
instrument_spec_assignst::inclusion_check_full
exprt inclusion_check_full(const car_exprt &lhs, bool allow_null_lhs, bool include_stack_allocated) const
Returns an inclusion check expression of lhs over all tracked cars.
Definition: instrument_spec_assigns.cpp:732
instrument_spec_assignst::mode
const irep_idt & mode
Language mode.
Definition: instrument_spec_assigns.h:495
instrument_spec_assignst::from_heap_alloc
car_expr_listt from_heap_alloc
Definition: instrument_spec_assigns.h:630
to_symbol_expr
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
Definition: std_expr.h:222
instrument_spec_assignst::must_track_decl
bool must_track_decl(const goto_programt::const_targett &target) const
Returns true iff a DECL x must be explicitly added to the write set.
Definition: instrument_spec_assigns.cpp:973
message_handlert
Definition: message.h:27
dstringt::empty
bool empty() const
Definition: dstring.h:88
instrument_spec_assignst::functions
const goto_functionst & functions
Other functions of the model.
Definition: instrument_spec_assigns.h:480
instrument_spec_assignst::must_check_assign
bool must_check_assign(const goto_programt::const_targett &target)
Returns true iff an ASSIGN lhs := rhs instruction must be instrumented.
Definition: instrument_spec_assigns.cpp:905
instrument_spec_assignst::location_intervalt::anywhere
void anywhere()
Grows the interval cover the maximum range [(size_t::min, size_t::min), (size_t::min,...
Definition: instrument_spec_assigns.h:278
instrument_spec_assignst::location_intervalt::max_col
std::size_t max_col
Definition: instrument_spec_assigns.h:404
instrument_spec_assignst::instrument_assign_statement
void instrument_assign_statement(goto_programt::targett &instruction_it, goto_programt &body) const
Inserts an assertion in body immediately before the assignment at instruction_it, to ensure that the ...
Definition: instrument_spec_assigns.cpp:1001
conditional_target_group_exprt
A class for an expression that represents a conditional target or a list of targets sharing a common ...
Definition: c_expr.h:231
goto_program.h
car_havoc_methodt
car_havoc_methodt
method to use to havoc a target
Definition: instrument_spec_assigns.h:63
source_locationt
Definition: source_location.h:18
instrument_spec_assignst::location_intervalt::col_to_size_t
std::size_t col_to_size_t(const source_locationt &source_location, std::size_t default_value)
If line or col is missing use default.
Definition: instrument_spec_assigns.h:336
instrument_spec_assignst::track_static_locals_between
void track_static_locals_between(goto_programt::const_targett it, const goto_programt::const_targett end, goto_programt &dest)
Searches the goto instructions reachable between the given it and end target instructions to identify...
Definition: instrument_spec_assigns.cpp:183
instrument_spec_assignst::location_intervalt::min_line
std::size_t min_line
Definition: instrument_spec_assigns.h:401
goto_functionst
A collection of goto functions.
Definition: goto_functions.h:24
instrument_spec_assignst::track_static_locals
void track_static_locals(goto_programt &dest)
Searches the goto instructions reachable from the start to the end of the instrumented function's ins...
Definition: instrument_spec_assigns.cpp:155
instrument_spec_assignst::invalidate_stack_allocated
void invalidate_stack_allocated(const symbol_exprt &symbol_expr, goto_programt &dest)
Generate instructions to invalidate a stack-allocated object that goes DEAD in dest.
Definition: instrument_spec_assigns.cpp:112
instrument_spec_assignst::track_plain_spec_target
void track_plain_spec_target(const exprt &expr, goto_programt &dest)
Track and generate snaphsot instructions and target validity checking assertions for a conditional ta...
Definition: instrument_spec_assigns.cpp:430
car_havoc_methodt::HAVOC_SLICE
@ HAVOC_SLICE
instrument_spec_assignst::instrument_call_statement
void instrument_call_statement(goto_programt::targett &instruction_it, goto_programt &body)
Inserts an assertion in body immediately before the function call at instruction_it,...
Definition: instrument_spec_assigns.cpp:1012
car_exprt::target
const exprt & target() const
The target expression.
Definition: instrument_spec_assigns.h:113
instrument_spec_assignst::create_fresh_symbol
const symbolt create_fresh_symbol(const std::string &suffix, const typet &type, const source_locationt &location) const
Creates a fresh symbolt with given suffix, scoped to function_id.
Definition: instrument_spec_assigns.cpp:444
instrument_spec_assignst::car_expr_listt
std::list< car_exprt > car_expr_listt
List of malloc'd conditional address ranges.
Definition: instrument_spec_assigns.h:629
instrument_spec_assignst::must_track_decl_or_dead
bool must_track_decl_or_dead(const irep_idt &ident) const
Returns true iff a function-local symbol must be tracked.
Definition: instrument_spec_assigns.cpp:966
symbolt
Symbol table entry.
Definition: symbol.h:27
instrument_spec_assignst::covered_locationst
std::unordered_map< irep_idt, location_intervalt > covered_locationst
Map type from function identifiers to covered locations.
Definition: instrument_spec_assigns.h:408
instrument_spec_assignst::instrument_instructions
void instrument_instructions(goto_programt &body, goto_programt::targett instruction_it, const goto_programt::targett &instruction_end, const std::function< bool(const goto_programt::targett &)> &pred={})
Instruments a sequence of instructions with inclusion checks.
Definition: instrument_spec_assigns.cpp:322
instrument_spec_assignst::location_intervalt::contains
bool contains(const source_locationt &source_location)
True iff the interval contains the given location.
Definition: instrument_spec_assigns.h:306
instrument_spec_assignst::collect_static_symbols
void collect_static_symbols(covered_locationst &covered_locations, std::unordered_set< symbol_exprt, irep_hash > &dest)
Collects static symbols from the symbol table that have a source location included in one of the cove...
Definition: instrument_spec_assigns.cpp:283
instrument_spec_assignst::location_intervalt::line_to_size_t
std::size_t line_to_size_t(const source_locationt &source_location, std::size_t default_value)
If line is missing use default.
Definition: instrument_spec_assigns.h:356
add_pragma_disable_pointer_checks
void add_pragma_disable_pointer_checks(source_locationt &source_location)
Adds a pragma on a source location disable all pointer checks.
Definition: instrument_spec_assigns.cpp:51
instrument_spec_assignst::create_car_from_heap_alloc
const car_exprt & create_car_from_heap_alloc(const exprt &target)
Definition: instrument_spec_assigns.cpp:848
car_exprt::target_start_address
const exprt & target_start_address() const
Start address of the target.
Definition: instrument_spec_assigns.h:119
goto_programt
A generic container class for the GOTO intermediate representation of one function.
Definition: goto_program.h:72
instrument_spec_assignst::location_intervalt::min_col
std::size_t min_col
Definition: instrument_spec_assigns.h:402
instrument_spec_assignst::track_heap_allocated
void track_heap_allocated(const exprt &expr, goto_programt &dest)
Track a whole heap-alloc object and generate snaphsot instructions in dest.
Definition: instrument_spec_assigns.cpp:131
goto_programt::const_targett
instructionst::const_iterator const_targett
Definition: goto_program.h:587
instrument_spec_assignst::track_spec_target
void track_spec_target(const exprt &expr, goto_programt &dest)
Track an assigns clause target and generate snaphsot instructions and well-definedness assertions in ...
Definition: instrument_spec_assigns.cpp:89
instrument_spec_assignst::location_intervalt::update
void update(const source_locationt &source_location)
Grows the interval to include the given (line, col) location.
Definition: instrument_spec_assigns.h:287
instrument_spec_assignst::cfg_info
cfg_infot & cfg_info
CFG information for simplification.
Definition: instrument_spec_assigns.h:483
exprt::operands
operandst & operands()
Definition: expr.h:94
car_exprt
Class that represents a normalized conditional address range, with:
Definition: instrument_spec_assigns.h:76
exprt::add_source_location
source_locationt & add_source_location()
Definition: expr.h:216
instrument_spec_assignst::instrument_spec_assignst
instrument_spec_assignst(const irep_idt &_function_id, const goto_functionst &_functions, cfg_infot &_cfg_info, symbol_tablet &_st, message_handlert &_message_handler)
Class constructor.
Definition: instrument_spec_assigns.h:199
instrument_spec_assignst::exprt_to_car_mapt
std::unordered_map< const exprt, const car_exprt, irep_hash > exprt_to_car_mapt
Definition: instrument_spec_assigns.h:626
instrument_spec_assignst::track_spec_target_group
void track_spec_target_group(const conditional_target_group_exprt &group, goto_programt &dest)
Track and generate snaphsot instructions and target validity checking assertions for a conditional ta...
Definition: instrument_spec_assigns.cpp:406
message.h
instrument_spec_assignst::propagated_static_localst
std::unordered_set< symbol_exprt, irep_hash > propagated_static_localst
Definition: instrument_spec_assigns.h:409
instrument_spec_assignst::symbol_exprt_to_car_mapt
std::unordered_map< const symbol_exprt, const car_exprt, irep_hash > symbol_exprt_to_car_mapt
Definition: instrument_spec_assigns.h:618
goto_programt::instructiont
This class represents an instruction in the GOTO intermediate representation.
Definition: goto_program.h:180
conditional_target_exprt::target
const exprt & target() const
Target expression.
Definition: instrument_spec_assigns.h:56
instrument_spec_assignst::stack_allocated_is_tracked
bool stack_allocated_is_tracked(const symbol_exprt &symbol_expr) const
Returns true if the expression is tracked.
Definition: instrument_spec_assigns.cpp:106
conditional_target_exprt::condition
const exprt & condition() const
Condition expression.
Definition: instrument_spec_assigns.h:50
instrument_spec_assignst::location_intervalt::is_lte
static bool is_lte(size_t line0, size_t col0, size_t line1, size_t col1)
True iff (line0, col0) <= (line1, col1) in lexicographic ordering.
Definition: instrument_spec_assigns.h:374
instrument_spec_assignst::track_stack_allocated
void track_stack_allocated(const symbol_exprt &symbol_expr, goto_programt &dest)
Track a stack-allocated object and generate snaphsot instructions in dest.
Definition: instrument_spec_assigns.cpp:99
instrument_spec_assignst::location_intervalt::max_line
std::size_t max_line
Definition: instrument_spec_assigns.h:403
goto_programt::targett
instructionst::iterator targett
Definition: goto_program.h:586
validation_modet::INVARIANT
@ INVARIANT
instrument_spec_assignst::create_car_from_stack_alloc
const car_exprt & create_car_from_stack_alloc(const symbol_exprt &target)
Definition: instrument_spec_assigns.cpp:827