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 
134  irep_idt get_property_id() const;
135 
136  // we may choose to hide
137  bool hidden = false;
138 
141 
142  // for ASSIGNMENT and DECL
147 
148  // for ASSUME/ASSERT/GOTO/CONSTRAINT
151  std::string comment;
152 
154  {
155  return ((is_shared_read() || is_shared_write()) ? ssa_lhs : cond_expr);
156  }
157 
158  // for INPUT/OUTPUT
160  bool formatted = false;
161  std::list<exprt> io_args;
162  std::list<exprt> converted_io_args;
163 
164  // for function calls: the function that is called
166 
167  // for function calls
169 
170  // for SHARED_READ/SHARED_WRITE and ATOMIC_BEGIN/ATOMIC_END
171  unsigned atomic_section_id = 0;
172 
173  // for slicing
174  bool ignore = false;
175 
176  // for incremental conversion
177  bool converted = false;
178 
180  const symex_targett::sourcet &_source,
182  : source(_source),
183  type(_type),
184  hidden(false),
185  guard(static_cast<const exprt &>(get_nil_irep())),
187  ssa_lhs(static_cast<const ssa_exprt &>(get_nil_irep())),
188  ssa_full_lhs(static_cast<const exprt &>(get_nil_irep())),
189  original_full_lhs(static_cast<const exprt &>(get_nil_irep())),
190  ssa_rhs(static_cast<const exprt &>(get_nil_irep())),
191  assignment_type(symex_targett::assignment_typet::STATE),
192  cond_expr(static_cast<const exprt &>(get_nil_irep())),
194  formatted(false),
196  ignore(false)
197  {
198  }
199 
200  void output(std::ostream &out) const;
201 
202  void validate(const namespacet &ns, const validation_modet vm) const;
203 };
204 
206 {
207 public:
210  exprt guard,
214  exprt ssa_rhs,
216 };
217 
218 #endif // CPROVER_GOTO_SYMEX_SSA_STEP_H
dstringt
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:36
SSA_assignment_stept::SSA_assignment_stept
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:217
symex_targett::assignment_typet
assignment_typet
Definition: symex_target.h:68
SSA_stept::validate
void validate(const namespacet &ns, const validation_modet vm) const
Check that the SSA step is well-formed.
Definition: ssa_step.cpp:128
goto_trace_stept::typet::LOCATION
@ LOCATION
SSA_stept::cond_handle
exprt cond_handle
Definition: ssa_step.h:150
SSA_stept::output
void output(std::ostream &out) const
Definition: ssa_step.cpp:13
goto_trace_stept::typet::ASSUME
@ ASSUME
SSA_stept::comment
std::string comment
Definition: ssa_step.h:151
SSA_stept::get_ssa_expr
exprt get_ssa_expr() const
Definition: ssa_step.h:153
SSA_stept::atomic_section_id
unsigned atomic_section_id
Definition: ssa_step.h:171
SSA_stept::converted_function_arguments
std::vector< exprt > converted_function_arguments
Definition: ssa_step.h:168
SSA_stept
Single SSA step in the equation.
Definition: ssa_step.h:46
SSA_stept::is_assert
bool is_assert() const
Definition: ssa_step.h:52
SSA_stept::is_function_return
bool is_function_return() const
Definition: ssa_step.h:97
SSA_stept::assignment_type
symex_targett::assignment_typet assignment_type
Definition: ssa_step.h:146
exprt
Base class for all expressions.
Definition: expr.h:55
SSA_stept::is_location
bool is_location() const
Definition: ssa_step.h:77
SSA_stept::formatted
bool formatted
Definition: ssa_step.h:160
SSA_stept::guard
exprt guard
Definition: ssa_step.h:139
SSA_stept::source
symex_targett::sourcet source
Definition: ssa_step.h:49
SSA_stept::called_function
irep_idt called_function
Definition: ssa_step.h:165
SSA_stept::ssa_function_arguments
std::vector< exprt > ssa_function_arguments
Definition: ssa_step.h:168
SSA_stept::is_memory_barrier
bool is_memory_barrier() const
Definition: ssa_step.h:117
SSA_stept::is_constraint
bool is_constraint() const
Definition: ssa_step.h:72
SSA_stept::is_shared_write
bool is_shared_write() const
Definition: ssa_step.h:107
SSA_stept::is_shared_read
bool is_shared_read() const
Definition: ssa_step.h:102
goto_trace.h
SSA_stept::io_args
std::list< exprt > io_args
Definition: ssa_step.h:161
SSA_stept::converted
bool converted
Definition: ssa_step.h:177
ssa_exprt
Expression providing an SSA-renamed symbol of expressions.
Definition: ssa_expr.h:16
namespacet
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition: namespace.h:90
goto_trace_stept::typet::OUTPUT
@ OUTPUT
goto_trace_stept::typet::FUNCTION_RETURN
@ FUNCTION_RETURN
SSA_stept::io_id
irep_idt io_id
Definition: ssa_step.h:159
SSA_assignment_stept
Definition: ssa_step.h:205
goto_trace_stept::typet::DECL
@ DECL
goto_trace_stept::typet
typet
Definition: goto_trace.h:74
SSA_stept::ssa_lhs
ssa_exprt ssa_lhs
Definition: ssa_step.h:143
SSA_stept::is_atomic_begin
bool is_atomic_begin() const
Definition: ssa_step.h:122
goto_trace_stept::typet::ASSERT
@ ASSERT
SSA_stept::ssa_full_lhs
exprt ssa_full_lhs
Definition: ssa_step.h:144
SSA_stept::cond_expr
exprt cond_expr
Definition: ssa_step.h:149
SSA_stept::is_atomic_end
bool is_atomic_end() const
Definition: ssa_step.h:127
SSA_stept::is_decl
bool is_decl() const
Definition: ssa_step.h:87
goto_trace_stept::typet::ASSIGNMENT
@ ASSIGNMENT
SSA_stept::is_output
bool is_output() const
Definition: ssa_step.h:82
validation_modet
validation_modet
Definition: validation_mode.h:12
false_exprt
The Boolean constant false.
Definition: std_expr.h:3016
goto_trace_stept::typet::ATOMIC_END
@ ATOMIC_END
SSA_stept::ignore
bool ignore
Definition: ssa_step.h:174
SSA_stept::is_goto
bool is_goto() const
Definition: ssa_step.h:67
SSA_stept::hidden
bool hidden
Definition: ssa_step.h:137
goto_trace_stept::typet::SPAWN
@ SPAWN
goto_trace_stept::typet::MEMORY_BARRIER
@ MEMORY_BARRIER
goto_trace_stept::typet::SHARED_WRITE
@ SHARED_WRITE
ssa_expr.h
goto_trace_stept::typet::GOTO
@ GOTO
SSA_stept::original_full_lhs
exprt original_full_lhs
Definition: ssa_step.h:144
SSA_stept::SSA_stept
SSA_stept(const symex_targett::sourcet &_source, goto_trace_stept::typet _type)
Definition: ssa_step.h:179
SSA_stept::type
goto_trace_stept::typet type
Definition: ssa_step.h:50
SSA_stept::is_assignment
bool is_assignment() const
Definition: ssa_step.h:62
SSA_stept::ssa_rhs
exprt ssa_rhs
Definition: ssa_step.h:145
goto_trace_stept::typet::ATOMIC_BEGIN
@ ATOMIC_BEGIN
SSA_stept::guard_handle
exprt guard_handle
Definition: ssa_step.h:140
SSA_stept::format_string
irep_idt format_string
Definition: ssa_step.h:159
SSA_stept::is_spawn
bool is_spawn() const
Definition: ssa_step.h:112
get_nil_irep
const irept & get_nil_irep()
Definition: irep.cpp:20
goto_trace_stept::typet::SHARED_READ
@ SHARED_READ
symex_targett::sourcet
Identifies source in the context of symbolic execution.
Definition: symex_target.h:36
goto_trace_stept::typet::FUNCTION_CALL
@ FUNCTION_CALL
SSA_stept::get_property_id
irep_idt get_property_id() const
Returns the property ID if this is a step resulting from an ASSERT, or builds a unique name for an un...
Definition: ssa_step.cpp:187
symex_target.h
symex_targett
The interface of the target container for symbolic execution to record its symbolic steps into.
Definition: symex_target.h:24
SSA_stept::is_function_call
bool is_function_call() const
Definition: ssa_step.h:92
goto_trace_stept::typet::CONSTRAINT
@ CONSTRAINT
SSA_stept::is_assume
bool is_assume() const
Definition: ssa_step.h:57
SSA_stept::converted_io_args
std::list< exprt > converted_io_args
Definition: ssa_step.h:162