50 if(lhs.
id()==ID_symbol)
52 if(lhs.
type().
id()==ID_pointer)
54 unsigned dest_pointer=
objects.number(lhs);
60 get_rec(rhs_set, rhs, loc_info_src);
63 for(object_sett::const_iterator
72 else if(lhs.
id()==ID_dereference)
77 if(lhs.
type().
id()==ID_pointer)
79 for(std::size_t i=0; i<
objects.size(); i++)
85 if(
dirty(identifier) || !
locals.is_local(identifier))
94 else if(lhs.
id()==ID_index)
98 else if(lhs.
id()==ID_member)
101 to_member_expr(lhs).struct_op(), rhs, loc_info_src, loc_info_dest);
103 else if(lhs.
id()==ID_typecast)
107 else if(lhs.
id()==ID_if)
116 const exprt &rhs)
const
118 local_cfgt::loc_mapt::const_iterator loc_it=
cfg.loc_map.find(t);
124 get_rec(result_tmp, rhs, loc_info_src);
126 std::set<exprt> result;
128 for(object_sett::const_iterator
129 it=result_tmp.begin();
130 it!=result_tmp.end();
143 local_cfgt::loc_mapt::const_iterator loc_it=
cfg.loc_map.find(t);
149 get_rec(tmp1, src1, loc_info_src);
150 get_rec(tmp2, src2, loc_info_src);
156 std::list<unsigned> result;
158 std::set_intersection(
159 tmp1.begin(), tmp1.end(),
160 tmp2.begin(), tmp2.end(),
161 std::back_inserter(result));
163 return !result.empty();
176 dest.insert(
objects.number(
exprt(ID_integer_address_object)));
178 else if(rhs.
id()==ID_symbol)
180 if(rhs.
type().
id()==ID_pointer)
182 unsigned src_pointer=
objects.number(rhs);
184 dest.insert(src_pointer);
186 for(std::size_t i=0; i<loc_info_src.
aliases.
size(); i++)
193 else if(rhs.
id()==ID_if)
198 else if(rhs.
id()==ID_address_of)
202 if(
object.
id()==ID_symbol)
204 unsigned object_nr=
objects.number(rhs);
205 dest.insert(object_nr);
207 for(std::size_t i=0; i<loc_info_src.
aliases.
size(); i++)
211 else if(
object.
id()==ID_index)
214 if(index_expr.
array().
id()==ID_symbol)
219 unsigned object_nr=
objects.number(tmp2);
220 dest.insert(object_nr);
222 for(std::size_t i=0; i<loc_info_src.
aliases.
size(); i++)
226 else if(index_expr.
array().
id()==ID_string_constant)
231 unsigned object_nr=
objects.number(tmp2);
232 dest.insert(object_nr);
234 for(std::size_t i=0; i<loc_info_src.
aliases.
size(); i++)
244 else if(rhs.
id()==ID_typecast)
248 else if(rhs.
id()==ID_plus)
252 if(plus_expr.operands().size() >= 3)
255 plus_expr.op0().type().id() == ID_pointer,
256 "pointer in pointer-typed sum must be op0");
257 get_rec(dest, plus_expr.op0(), loc_info_src);
259 else if(plus_expr.operands().size() == 2)
262 if(plus_expr.op0().type().id() == ID_pointer)
264 get_rec(dest, plus_expr.op0(), loc_info_src);
266 else if(plus_expr.op1().type().id() == ID_pointer)
268 get_rec(dest, plus_expr.op1(), loc_info_src);
276 else if(rhs.
id()==ID_minus)
280 if(op0.type().id() == ID_pointer)
282 get_rec(dest, op0, loc_info_src);
287 else if(rhs.
id()==ID_member)
291 else if(rhs.
id()==ID_index)
295 else if(rhs.
id()==ID_dereference)
299 else if(rhs.
id()==ID_side_effect)
304 if(statement==ID_allocate)
321 if(
cfg.nodes.empty())
337 for(code_typet::parameterst::const_iterator
338 it=goto_function.type.parameters().begin();
339 it!=goto_function.type.parameters().end();
342 const irep_idt &identifier=it->get_identifier();
343 if(is_tracked(identifier))
350 for(localst::locals_mapt::const_iterator
351 l_it=
locals.locals_map.begin();
352 l_it!=
locals.locals_map.end();
355 if(is_tracked(l_it->first))
361 while(!work_queue.empty())
371 switch(instruction.
type())
395 const auto &lhs = instruction.
call_lhs();
402 for(std::size_t i = 0; i <
objects.size(); i++)
404 if(
objects[i].
id() == ID_symbol)
408 if(
dirty(identifier) || !
locals.is_local(identifier))
420 DATA_INVARIANT(
false,
"Exceptions must be removed before analysis");
424 DATA_INVARIANT(
false,
"SET_RETURN_VALUE must be removed before analysis");
441 false,
"Unclear what is a safe over-approximation of OTHER");
446 DATA_INVARIANT(
false,
"Only complete instructions can be analyzed");
450 for(local_cfgt::successorst::const_iterator
456 work_queue.push(*it);
470 out <<
"**** " << instruction.source_location() <<
"\n";
474 for(std::size_t i=0; i<loc_info.
aliases.
size(); i++)
480 for(std::size_t j=0; j<loc_info.
aliases.
size(); j++)
485 if(
objects[j].
id() == ID_symbol)
496 instruction.output(out);
bitvector_typet c_index_type()
Operator to return the address of an object.
Base class for all expressions.
bool is_constant() const
Return whether the expression is a constant.
typet & type()
Return the type of the expression.
This class represents an instruction in the GOTO intermediate representation.
const symbol_exprt & dead_symbol() const
Get the symbol for DEAD.
const exprt & call_lhs() const
Get the lhs of a FUNCTION_CALL (may be nil).
const symbol_exprt & decl_symbol() const
Get the declared symbol for DECL.
const exprt & assign_lhs() const
Get the lhs of the assignment for ASSIGN.
const exprt & assign_rhs() const
Get the rhs of the assignment for ASSIGN.
goto_program_instruction_typet type() const
What kind of instruction?
instructionst instructions
The list of instructions in the goto program.
instructionst::const_iterator const_targett
const irep_idt & id() const
goto_programt::const_targett t
bool merge(const loc_infot &src)
void output(std::ostream &out, const goto_functiont &goto_function, const namespacet &ns) const
void assign_lhs(const exprt &lhs, const exprt &rhs, const loc_infot &loc_info_src, loc_infot &loc_info_dest)
void build(const goto_functiont &goto_function)
numberingt< exprt, irep_hash > objects
std::set< exprt > get(const goto_programt::const_targett t, const exprt &src) const
void get_rec(object_sett &dest, const exprt &rhs, const loc_infot &loc_info_src) const
std::stack< local_cfgt::node_nrt > work_queuet
bool aliases(const goto_programt::const_targett t, const exprt &src1, const exprt &src2) const
std::set< unsigned > object_sett
goto_functionst::goto_functiont goto_functiont
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
An expression containing a side effect.
const irep_idt & get_statement() const
void identifier(const irep_idt &identifier)
size_type find(size_type a) const
size_type count(size_type a) const
void make_union(size_type a, size_type b)
bool same_set(size_type a, size_type b) const
void isolate(size_type a)
std::string from_expr(const namespacet &ns, const irep_idt &identifier, const exprt &expr)
Field-insensitive, location-sensitive may-alias analysis.
API to expression classes for Pointers.
const address_of_exprt & to_address_of_expr(const exprt &expr)
Cast an exprt to an address_of_exprt.
#define CHECK_RETURN(CONDITION)
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
#define INVARIANT(CONDITION, REASON)
This macro uses the wrapper function 'invariant_violated_string'.
side_effect_exprt & to_side_effect_expr(exprt &expr)
const index_exprt & to_index_expr(const exprt &expr)
Cast an exprt to an index_exprt.
const typecast_exprt & to_typecast_expr(const exprt &expr)
Cast an exprt to a typecast_exprt.
const plus_exprt & to_plus_expr(const exprt &expr)
Cast an exprt to a plus_exprt.
const if_exprt & to_if_expr(const exprt &expr)
Cast an exprt to an if_exprt.
const member_exprt & to_member_expr(const exprt &expr)
Cast an exprt to a member_exprt.
const minus_exprt & to_minus_expr(const exprt &expr)
Cast an exprt to a minus_exprt.
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
void merge(string_constraintst &result, string_constraintst other)
Merge two sets of constraints by appending to the first one.