CBMC
ssa_step.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Symbolic Execution
4 
5 Author: Romain Brenguier <romain.brenguier@diffblue.com>
6 
7 *******************************************************************/
8 
9 #ifndef CPROVER_GOTO_SYMEX_SSA_STEP_H
10 #define CPROVER_GOTO_SYMEX_SSA_STEP_H
11 
12 #include <util/ssa_expr.h>
13 
15 
16 #include "symex_target.h"
17 
46 class SSA_stept
47 {
48 public:
51 
52  bool is_assert() const
53  {
55  }
56 
57  bool is_assume() const
58  {
60  }
61 
62  bool is_assignment() const
63  {
65  }
66 
67  bool is_goto() const
68  {
70  }
71 
72  bool is_constraint() const
73  {
75  }
76 
77  bool is_location() const
78  {
80  }
81 
82  bool is_output() const
83  {
85  }
86 
87  bool is_decl() const
88  {
90  }
91 
92  bool is_function_call() const
93  {
95  }
96 
97  bool is_function_return() const
98  {
100  }
101 
102  bool is_shared_read() const
103  {
105  }
106 
107  bool is_shared_write() const
108  {
110  }
111 
112  bool is_spawn() const
113  {
115  }
116 
117  bool is_memory_barrier() const
118  {
120  }
121 
122  bool is_atomic_begin() const
123  {
125  }
126 
127  bool is_atomic_end() const
128  {
130  }
131 
132  // we may choose to hide
133  bool hidden = false;
134 
137 
138  // for ASSIGNMENT and DECL
143 
144  // for ASSUME/ASSERT/GOTO/CONSTRAINT
147  std::string comment;
148  // for ASSERT (which includes loop unwinding assertions)
150 
152  {
153  return ((is_shared_read() || is_shared_write()) ? ssa_lhs : cond_expr);
154  }
155 
156  // for INPUT/OUTPUT
158  bool formatted = false;
159  std::list<exprt> io_args;
160  std::list<exprt> converted_io_args;
161 
162  // for function calls: the function that is called
164 
165  // for function calls
167 
168  // for SHARED_READ/SHARED_WRITE and ATOMIC_BEGIN/ATOMIC_END
169  unsigned atomic_section_id = 0;
170 
171  // for slicing
172  bool ignore = false;
173 
174  // for incremental conversion
175  bool converted = false;
176 
178  const symex_targett::sourcet &_source,
180  : source(_source),
181  type(_type),
182  hidden(false),
183  guard(static_cast<const exprt &>(get_nil_irep())),
185  ssa_lhs(static_cast<const ssa_exprt &>(get_nil_irep())),
186  ssa_full_lhs(static_cast<const exprt &>(get_nil_irep())),
187  original_full_lhs(static_cast<const exprt &>(get_nil_irep())),
188  ssa_rhs(static_cast<const exprt &>(get_nil_irep())),
189  assignment_type(symex_targett::assignment_typet::STATE),
190  cond_expr(static_cast<const exprt &>(get_nil_irep())),
192  formatted(false),
194  ignore(false)
195  {
196  }
197 
198  void output(std::ostream &out) const;
199 
200  void validate(const namespacet &ns, const validation_modet vm) const;
201 };
202 
204 {
205 public:
208  exprt guard,
212  exprt ssa_rhs,
214 };
215 
216 #endif // CPROVER_GOTO_SYMEX_SSA_STEP_H
SSA_assignment_stept(symex_targett::sourcet source, exprt guard, ssa_exprt ssa_lhs, exprt ssa_full_lhs, exprt original_full_lhs, exprt ssa_rhs, symex_targett::assignment_typet assignment_type)
Definition: ssa_step.cpp:189
Single SSA step in the equation.
Definition: ssa_step.h:47
irep_idt io_id
Definition: ssa_step.h:157
bool ignore
Definition: ssa_step.h:172
irep_idt called_function
Definition: ssa_step.h:163
bool is_assume() const
Definition: ssa_step.h:57
exprt guard_handle
Definition: ssa_step.h:136
void validate(const namespacet &ns, const validation_modet vm) const
Check that the SSA step is well-formed.
Definition: ssa_step.cpp:129
std::vector< exprt > ssa_function_arguments
Definition: ssa_step.h:166
bool is_location() const
Definition: ssa_step.h:77
exprt cond_expr
Definition: ssa_step.h:145
exprt cond_handle
Definition: ssa_step.h:146
unsigned atomic_section_id
Definition: ssa_step.h:169
irep_idt format_string
Definition: ssa_step.h:157
symex_targett::assignment_typet assignment_type
Definition: ssa_step.h:142
std::list< exprt > converted_io_args
Definition: ssa_step.h:160
bool is_function_return() const
Definition: ssa_step.h:97
bool formatted
Definition: ssa_step.h:158
exprt ssa_full_lhs
Definition: ssa_step.h:140
bool is_atomic_end() const
Definition: ssa_step.h:127
goto_trace_stept::typet type
Definition: ssa_step.h:50
bool hidden
Definition: ssa_step.h:133
bool is_constraint() const
Definition: ssa_step.h:72
exprt guard
Definition: ssa_step.h:135
bool is_shared_write() const
Definition: ssa_step.h:107
exprt ssa_rhs
Definition: ssa_step.h:141
std::string comment
Definition: ssa_step.h:147
bool is_goto() const
Definition: ssa_step.h:67
symex_targett::sourcet source
Definition: ssa_step.h:49
bool is_atomic_begin() const
Definition: ssa_step.h:122
exprt original_full_lhs
Definition: ssa_step.h:140
exprt get_ssa_expr() const
Definition: ssa_step.h:151
bool converted
Definition: ssa_step.h:175
bool is_shared_read() const
Definition: ssa_step.h:102
bool is_decl() const
Definition: ssa_step.h:87
irep_idt property_id
Definition: ssa_step.h:149
std::list< exprt > io_args
Definition: ssa_step.h:159
bool is_output() const
Definition: ssa_step.h:82
bool is_function_call() const
Definition: ssa_step.h:92
void output(std::ostream &out) const
Definition: ssa_step.cpp:14
SSA_stept(const symex_targett::sourcet &_source, goto_trace_stept::typet _type)
Definition: ssa_step.h:177
bool is_memory_barrier() const
Definition: ssa_step.h:117
bool is_assignment() const
Definition: ssa_step.h:62
std::vector< exprt > converted_function_arguments
Definition: ssa_step.h:166
ssa_exprt ssa_lhs
Definition: ssa_step.h:139
bool is_spawn() const
Definition: ssa_step.h:112
bool is_assert() const
Definition: ssa_step.h:52
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:38
Base class for all expressions.
Definition: expr.h:56
The Boolean constant false.
Definition: std_expr.h:3064
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition: namespace.h:94
Expression providing an SSA-renamed symbol of expressions.
Definition: ssa_expr.h:17
The interface of the target container for symbolic execution to record its symbolic steps into.
Definition: symex_target.h:25
Traces of GOTO Programs.
const irept & get_nil_irep()
Definition: irep.cpp:19
Identifies source in the context of symbolic execution.
Definition: symex_target.h:37
Generate Equation using Symbolic Execution.
validation_modet