12 #define USE_DEPRECATED_STATIC_ANALYSIS_H
29 else if(std::next(from) == to)
32 return from->get_condition();
41 if(to->is_end_function())
45 assert(to->is_function_call());
47 return to->call_lhs();
63 fixedpoint(function_identifier, goto_program, goto_functions);
68 std::ostream &out)
const
72 if(gf_entry.second.body_available())
75 out <<
"//// Function: " << gf_entry.first <<
"\n";
79 output(gf_entry.second.body, gf_entry.first, out);
87 std::ostream &out)
const
91 out <<
"**** " << i_it->location_number <<
" " << i_it->source_location()
121 update(gf_entry.second.body);
149 assert(!working_set.empty());
151 working_sett::iterator i=working_set.begin();
153 working_set.erase(i);
159 const irep_idt &function_identifier,
174 while(!working_set.empty())
178 if(
visit(function_identifier, l, working_set, goto_program, goto_functions))
186 const irep_idt &function_identifier,
203 std::unique_ptr<statet> tmp_state(
206 statet &new_values=*tmp_state;
208 if(l->is_function_call())
222 ns, function_identifier, l, function_identifier, to_l);
226 bool have_new_values=
227 merge(other, new_values, to_l);
232 if(have_new_values || !other.
seen)
244 const goto_functionst::function_mapt::const_iterator f_it,
250 if(!goto_function.body_available())
253 assert(!goto_function.body.instructions.empty());
257 locationt l_begin=goto_function.body.instructions.begin();
261 tmp_state->transform(
ns, calling_function, l_call, f_it->first, l_begin);
268 if(
merge(begin_state, *tmp_state, l_begin))
283 fixedpoint(f_it->first, goto_function.body, goto_functions);
289 locationt l_end=--goto_function.body.instructions.end();
291 assert(l_end->is_end_function());
296 std::unique_ptr<statet> tmp_state(
298 tmp_state->transform(
ns, f_it->first, l_end, calling_function, l_return);
303 merge(new_state, *tmp_state, l_return);
309 ns, calling_function, l_call, calling_function, l_return);
317 const exprt &
function,
326 if(
function.
id()==ID_symbol)
338 goto_functionst::function_mapt::const_iterator it=
342 throw "failed to find function "+
id2string(identifier);
355 else if(
function.
id()==ID_if)
357 if(
function.operands().size()!=3)
358 throw "if takes three arguments";
380 merge(new_state, *n2, l_return);
382 else if(
function.
id()==ID_dereference)
385 std::list<exprt> values;
391 for(
const auto &value : values)
393 if(value.id()==ID_object_descriptor)
405 merge(new_state, *n2, l_return);
409 else if(
function.
id() == ID_null_object ||
410 function.
id() == ID_integer_address)
414 else if(
function.
id()==ID_member ||
function.
id()==ID_index)
418 else if(
function.
id()==
"builtin-function")
424 throw "unexpected function_call argument: "+
425 function.id_string();
437 fixedpoint(gf_entry.first, gf_entry.second.body, goto_functions);
459 const irep_idt &_function_identifier,
462 : function_identifier(_function_identifier),
463 goto_program(&_goto_program),
473 typedef std::list<wl_entryt> thread_wlt;
474 thread_wlt thread_wl;
480 if(is_threaded(t_it))
483 wl_entryt(gf_entry.first, gf_entry.second.body, t_it));
486 gf_entry.second.body.instructions.end();
497 bool new_shared=
true;
502 for(
const auto &thread : thread_wl)
508 merge(begin_state, shared_state, thread.location);
510 while(!working_set.empty())
515 thread.function_identifier,
518 *thread.goto_program,
524 if(l->is_end_function())
527 new_shared|=
merge_shared(shared_state, end_state, sh_target);
virtual void output(const namespacet &, std::ostream &) const
virtual void transform(const namespacet &ns, const irep_idt &function_from, locationt from, const irep_idt &function_to, locationt to)=0
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Base class for all expressions.
std::vector< exprt > operandst
A collection of goto functions.
function_mapt function_map
::goto_functiont goto_functiont
A generic container class for the GOTO intermediate representation of one function.
instructionst instructions
The list of instructions in the goto program.
instructionst::const_iterator const_targett
targett add_instruction()
Adds an instruction at the end.
std::ostream & output_instruction(const namespacet &ns, const irep_idt &identifier, std::ostream &out, const instructionst::value_type &instruction) const
Output a single instruction.
std::list< Target > get_successors(Target target) const
Get control-flow successors of a given instruction.
Split an expression into a base object and a (byte) offset.
void generate_states(const goto_functionst &goto_functions)
void do_function_call(const irep_idt &calling_function, locationt l_call, locationt l_return, const goto_functionst &goto_functions, const goto_functionst::function_mapt::const_iterator f_it, const exprt::operandst &arguments, statet &new_state)
locationt get_next(working_sett &working_set)
virtual bool has_location(locationt l) const =0
bool visit(const irep_idt &function_identifier, locationt l, working_sett &working_set, const goto_programt &goto_program, const goto_functionst &goto_functions)
virtual std::unique_ptr< statet > make_temporary_state(statet &s)=0
bool fixedpoint(const irep_idt &function_identifier, const goto_programt &goto_program, const goto_functionst &goto_functions)
virtual void get_reference_set(locationt l, const exprt &expr, std::list< exprt > &dest)=0
void put_in_working_set(working_sett &working_set, locationt l)
void sequential_fixedpoint(const goto_functionst &goto_functions)
void concurrent_fixedpoint(const goto_functionst &goto_functions)
virtual void operator()(const irep_idt &function_identifier, const goto_programt &goto_program)
static exprt get_return_lhs(locationt to)
virtual void generate_state(locationt l)=0
virtual void update(const goto_programt &goto_program)
void do_function_call_rec(const irep_idt &calling_function, locationt l_call, locationt l_return, const exprt &function, const exprt::operandst &arguments, statet &new_state, const goto_functionst &goto_functions)
static exprt get_guard(locationt from, locationt to)
functions_donet functions_done
virtual void initialize(const goto_programt &goto_program)
std::map< unsigned, locationt > working_sett
goto_programt::const_targett locationt
virtual bool merge_shared(statet &a, const statet &b, locationt to)=0
virtual bool merge(statet &a, const statet &b, locationt to)=0
virtual void output(const goto_functionst &goto_functions, std::ostream &out) const
recursion_sett recursion_set
virtual statet & get_state(locationt l)=0
const irep_idt & get_identifier() const
The Boolean constant true.
exprt boolean_negate(const exprt &src)
negate a Boolean expression, possibly removing a not_exprt, and swapping false and true
Deprecated expression utility functions.
#define forall_goto_program_instructions(it, program)
const irept & get_nil_irep()
const std::string & id2string(const irep_idt &d)
Over-approximate Concurrency for Threaded Goto Programs.
API to expression classes for Pointers.
const object_descriptor_exprt & to_object_descriptor_expr(const exprt &expr)
Cast an exprt to an object_descriptor_exprt.
const if_exprt & to_if_expr(const exprt &expr)
Cast an exprt to an if_exprt.
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.