cprover
value_set_dereference.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Pointer Dereferencing
4 
5 Author: Daniel Kroening, kroening@kroening.com
6 
7 \*******************************************************************/
8 
11 
12 #ifndef CPROVER_POINTER_ANALYSIS_VALUE_SET_DEREFERENCE_H
13 #define CPROVER_POINTER_ANALYSIS_VALUE_SET_DEREFERENCE_H
14 
15 #include <unordered_set>
16 
17 #include <util/message.h>
18 #include <util/std_expr.h>
19 
20 #include "dereference_callback.h"
21 
22 class symbol_tablet;
23 class optionst;
24 class symbolt;
25 
28 {
29 public:
37  // given dereference may follow a null pointer
40  const namespacet &_ns,
41  symbol_tablet &_new_symbol_table,
42  dereference_callbackt &_dereference_callback,
43  const irep_idt _language_mode,
44  bool _exclude_null_derefs,
45  const messaget &_log)
46  : ns(_ns),
47  new_symbol_table(_new_symbol_table),
48  dereference_callback(_dereference_callback),
49  language_mode(_language_mode),
50  exclude_null_derefs(_exclude_null_derefs),
51  log(_log)
52  { }
53 
55 
60  exprt dereference(const exprt &pointer, bool display_points_to_sets = false);
61 
66  try_add_offset_to_indices(const exprt &expr, const exprt &offset);
67 
69  class valuet
70  {
71  public:
75 
78  {
79  }
80  };
81 
82  static bool should_ignore_value(
83  const exprt &what,
85  const irep_idt &language_mode);
86 
87  static valuet build_reference_to(
88  const exprt &what,
89  const exprt &pointer,
90  const namespacet &ns);
91 
92  static bool dereference_type_compare(
93  const typet &object_type,
94  const typet &dereference_type,
95  const namespacet &ns);
96 
97  static bool memory_model(
98  exprt &value,
99  const typet &type,
100  const exprt &offset,
101  const namespacet &ns);
102 
103  static bool memory_model_bytes(
104  exprt &value,
105  const typet &type,
106  const exprt &offset,
107  const namespacet &ns);
108 
109 private:
110  const namespacet &ns;
119  const messaget &log;
120  valuet get_failure_value(const exprt &pointer, const typet &type);
122  const exprt &pointer,
123  bool display_points_to_sets);
124 };
125 
126 #endif // CPROVER_POINTER_ANALYSIS_VALUE_SET_DEREFERENCE_H
Base class for pointer value set analysis.
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:37
Base class for all expressions.
Definition: expr.h:54
The Boolean constant false.
Definition: std_expr.h:2726
Class that provides messages with a built-in verbosity 'level'.
Definition: message.h:155
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition: namespace.h:92
The NIL expression.
Definition: std_expr.h:2735
The symbol table.
Definition: symbol_table.h:20
Symbol table entry.
Definition: symbol.h:28
The type of an expression, extends irept.
Definition: type.h:28
Return value for build_reference_to; see that method for documentation.
Wrapper for a function dereferencing pointer expressions using a value set.
static bool memory_model_bytes(exprt &value, const typet &type, const exprt &offset, const namespacet &ns)
Replace value by an expression of type to_type corresponding to the value at memory address value + o...
valuet get_failure_value(const exprt &pointer, const typet &type)
exprt handle_dereference_base_case(const exprt &pointer, bool display_points_to_sets)
value_set_dereferencet(const namespacet &_ns, symbol_tablet &_new_symbol_table, dereference_callbackt &_dereference_callback, const irep_idt _language_mode, bool _exclude_null_derefs, const messaget &_log)
const bool exclude_null_derefs
Flag indicating whether value_set_dereferencet::dereference should disregard an apparent attempt to d...
static bool dereference_type_compare(const typet &object_type, const typet &dereference_type, const namespacet &ns)
Check if the two types have matching number of ID_pointer levels, with the dereference type eventuall...
dereference_callbackt & dereference_callback
exprt dereference(const exprt &pointer, bool display_points_to_sets=false)
Dereference the given pointer-expression.
const irep_idt language_mode
language_mode: ID_java, ID_C or another language identifier if we know the source language in use,...
static valuet build_reference_to(const exprt &what, const exprt &pointer, const namespacet &ns)
optionalt< exprt > try_add_offset_to_indices(const exprt &expr, const exprt &offset)
If expr is of the form (c1 ? e1[o1] : c2 ? e2[o2] : c3 ? ...) then return c1 ? e1[o1 + offset] : e2[o...
static bool should_ignore_value(const exprt &what, bool exclude_null_derefs, const irep_idt &language_mode)
Determine whether possible alias what should be ignored when replacing a pointer by its referees.
static bool memory_model(exprt &value, const typet &type, const exprt &offset, const namespacet &ns)
Replace value by an expression of type to_type corresponding to the value at memory address value + o...
Pointer Dereferencing.
nonstd::optional< T > optionalt
Definition: optional.h:35
API to expression classes.