24 if(
auto member = expr_try_dynamic_cast<member_exprt>(expr))
27 <<
".." << member->get_component_name();
29 if(
auto index = expr_try_dynamic_cast<index_exprt>(expr))
34 if(
auto symbol = expr_try_dynamic_cast<symbol_exprt>(expr))
35 return os << symbol->get_identifier();
42 set(ID_C_SSA_symbol,
true);
43 add(ID_expression, expr);
45 std::ostringstream os;
47 const std::string
id = os.str();
49 set(ID_L1_object_identifier,
id);
56 static void build_ssa_identifier_rec(
62 std::ostream &l1_object_os)
64 if(expr.
id()==ID_member)
68 build_ssa_identifier_rec(member.
struct_op(), l0, l1, l2, os, l1_object_os);
73 else if(expr.
id()==ID_index)
77 build_ssa_identifier_rec(index.
array(), l0, l1, l2, os, l1_object_os);
80 os <<
"[[" << idx <<
"]]";
81 l1_object_os <<
"[[" << idx <<
"]]";
83 else if(expr.
id()==ID_symbol)
87 l1_object_os << symid;
93 l1_object_os <<
'!' << l0;
100 l1_object_os <<
'@' << l1;
113 static std::pair<irep_idt, irep_idt> build_identifier(
119 std::ostringstream oss;
120 std::ostringstream l1_object_oss;
122 build_ssa_identifier_rec(expr, l0, l1, l2, oss, l1_object_oss);
127 static void update_identifier(
ssa_exprt &ssa)
135 ssa.
set(ID_L1_object_identifier, idpair.second);
141 add(ID_expression, std::move(expr));
142 ::update_identifier(*
this);
149 if(original_expr.
id() == ID_symbol)
162 root.set(ID_L0,
get(ID_L0));
164 root.set(ID_L1,
get(ID_L1));
165 ::update_identifier(root);
177 return get(ID_L1_object_identifier);
184 ::update_identifier(*
this);
190 ::update_identifier(*
this);
196 ::update_identifier(*
this);
209 if(expr.
id() == ID_symbol)
211 else if(expr.
id() == ID_member)
213 else if(expr.
id() == ID_index)
const T & as_const(T &value)
Return a reference to the same object but ensures the type is const.
const irep_idt & get_value() const
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Base class for all expressions.
const source_locationt & source_location() const
typet & type()
Return the type of the expression.
const irep_idt & get(const irep_idt &name) const
void remove(const irep_idt &name)
void set(const irep_idt &name, const irep_idt &value)
const irep_idt & id() const
irept & add(const irep_idt &name)
Extract member of struct or union.
const exprt & struct_op() const
irep_idt get_component_name() const
Split an expression into a base object and a (byte) offset.
const exprt & root_object() const
Expression providing an SSA-renamed symbol of expressions.
const irep_idt get_level_1() const
const irep_idt get_l1_object_identifier() const
void set_level_1(std::size_t i)
void set_level_2(std::size_t i)
const ssa_exprt get_l1_object() const
static bool can_build_identifier(const exprt &src)
Used to determine whether or not an identifier can be built before trying and getting an exception.
void set_expression(exprt expr)
Replace the underlying, original expression by expr while maintaining SSA indices.
const irep_idt get_level_2() const
const irep_idt get_level_0() const
void set_level_0(std::size_t i)
ssa_exprt(const exprt &expr)
Constructor.
const exprt & get_original_expr() const
irep_idt get_object_name() const
Expression to hold a symbol (variable)
void set_identifier(const irep_idt &identifier)
const irep_idt & get_identifier() const
API to expression classes for Pointers.
#define UNREACHABLE
This should be used to mark dead code.
static std::ostream & initialize_ssa_identifier(std::ostream &os, const exprt &expr)
If expr is:
ssa_exprt remove_level_2(ssa_exprt ssa)
const constant_exprt & to_constant_expr(const exprt &expr)
Cast an exprt to a constant_exprt.
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
const member_exprt & to_member_expr(const exprt &expr)
Cast an exprt to a member_exprt.
const index_exprt & to_index_expr(const exprt &expr)
Cast an exprt to an index_exprt.