CBMC
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 <util/std_expr.h>
16 
18 class messaget;
19 class symbol_tablet;
20 
23 {
24 public:
32  // given dereference may follow a null pointer
35  const namespacet &_ns,
36  symbol_tablet &_new_symbol_table,
37  dereference_callbackt &_dereference_callback,
38  const irep_idt _language_mode,
39  bool _exclude_null_derefs,
40  const messaget &_log)
41  : ns(_ns),
42  new_symbol_table(_new_symbol_table),
43  dereference_callback(_dereference_callback),
44  language_mode(_language_mode),
45  exclude_null_derefs(_exclude_null_derefs),
46  log(_log)
47  { }
48 
50 
55  exprt dereference(const exprt &pointer, bool display_points_to_sets = false);
56 
58  class valuet
59  {
60  public:
64 
67  {
68  }
69  };
70 
71  static bool should_ignore_value(
72  const exprt &what,
74  const irep_idt &language_mode);
75 
76  static valuet build_reference_to(
77  const exprt &what,
78  const exprt &pointer,
79  const namespacet &ns);
80 
81  static bool dereference_type_compare(
82  const typet &object_type,
83  const typet &dereference_type,
84  const namespacet &ns);
85 
86  static bool memory_model(
87  exprt &value,
88  const typet &type,
89  const exprt &offset,
90  const namespacet &ns);
91 
92  static bool memory_model_bytes(
93  exprt &value,
94  const typet &type,
95  const exprt &offset,
96  const namespacet &ns);
97 
98 private:
99  const namespacet &ns;
108  const messaget &log;
109  valuet get_failure_value(const exprt &pointer, const typet &type);
111  const exprt &pointer,
112  bool display_points_to_sets);
113 };
114 
115 #endif // CPROVER_POINTER_ANALYSIS_VALUE_SET_DEREFERENCE_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
value_set_dereferencet::valuet
Return value for build_reference_to; see that method for documentation.
Definition: value_set_dereference.h:58
value_set_dereferencet::valuet::pointer_guard
exprt pointer_guard
Definition: value_set_dereference.h:63
value_set_dereferencet::memory_model
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...
Definition: value_set_dereference.cpp:683
value_set_dereferencet::ns
const namespacet & ns
Definition: value_set_dereference.h:99
typet
The type of an expression, extends irept.
Definition: type.h:28
dereference_callbackt
Base class for pointer value set analysis.
Definition: dereference_callback.h:27
value_set_dereferencet::language_mode
const irep_idt language_mode
language_mode: ID_java, ID_C or another language identifier if we know the source language in use,...
Definition: value_set_dereference.h:104
value_set_dereferencet::should_ignore_value
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.
Definition: value_set_dereference.cpp:416
value_set_dereferencet::exclude_null_derefs
const bool exclude_null_derefs
Flag indicating whether value_set_dereferencet::dereference should disregard an apparent attempt to d...
Definition: value_set_dereference.h:107
exprt
Base class for all expressions.
Definition: expr.h:55
value_set_dereferencet::get_failure_value
valuet get_failure_value(const exprt &pointer, const typet &type)
Definition: value_set_dereference.cpp:290
value_set_dereferencet::~value_set_dereferencet
virtual ~value_set_dereferencet()
Definition: value_set_dereference.h:49
value_set_dereferencet::dereference_type_compare
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...
Definition: value_set_dereference.cpp:337
value_set_dereferencet::new_symbol_table
symbol_tablet & new_symbol_table
Definition: value_set_dereference.h:100
namespacet
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition: namespace.h:90
value_set_dereferencet::log
const messaget & log
Definition: value_set_dereference.h:108
value_set_dereferencet::valuet::pointer
exprt pointer
Definition: value_set_dereference.h:62
nil_exprt
The NIL expression.
Definition: std_expr.h:3025
value_set_dereferencet::dereference_callback
dereference_callbackt & dereference_callback
Definition: value_set_dereference.h:101
false_exprt
The Boolean constant false.
Definition: std_expr.h:3016
value_set_dereferencet::memory_model_bytes
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...
Definition: value_set_dereference.cpp:730
value_set_dereferencet::valuet::valuet
valuet()
Definition: value_set_dereference.h:65
value_set_dereferencet
Wrapper for a function dereferencing pointer expressions using a value set.
Definition: value_set_dereference.h:22
value_set_dereferencet::build_reference_to
static valuet build_reference_to(const exprt &what, const exprt &pointer, const namespacet &ns)
Definition: value_set_dereference.cpp:453
value_set_dereferencet::value_set_dereferencet
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)
Definition: value_set_dereference.h:34
std_expr.h
value_set_dereferencet::dereference
exprt dereference(const exprt &pointer, bool display_points_to_sets=false)
Dereference the given pointer-expression.
Definition: value_set_dereference.cpp:141
value_set_dereferencet::valuet::value
exprt value
Definition: value_set_dereference.h:61
value_set_dereferencet::handle_dereference_base_case
exprt handle_dereference_base_case(const exprt &pointer, bool display_points_to_sets)
Definition: value_set_dereference.cpp:213