28 std::ostringstream out;
38 std::ostringstream out;
57 if(condition.
id()==ID_index)
61 if(!no_simplification)
64 return no_simplification;
66 else if(condition.
id()==ID_dereference)
70 if(!no_simplification)
73 return no_simplification;
75 else if(condition.
id()==ID_member)
83 if(!no_simplification)
86 return no_simplification;
95 std::ostream &out)
const 99 if(f_it->second.body_available())
102 out <<
"//// Function: " << f_it->first <<
"\n";
106 output(ns, f_it->second.body, f_it->first, out);
115 std::ostream &out)
const 119 out <<
"**** " << i_it->location_number <<
" " 120 << i_it->source_location <<
"\n";
142 if(f_it->second.body_available())
169 location[
"locationNumber"]=
171 location[
"sourceLocation"]=
176 std::ostringstream out;
193 xmlt program(
"program");
197 xmlt function(
"function");
199 function.set_attribute(
201 f_it->second.body_available() ?
"true" :
"false");
203 if(f_it->second.body_available())
205 function.new_element(
output_xml(ns, f_it->second.body, f_it->first));
232 i_it->source_location.as_string());
237 std::ostringstream out;
244 return function_body;
251 goto_functionst::function_mapt::const_iterator
291 assert(!working_set.empty());
293 working_sett::iterator i=working_set.begin();
295 working_set.erase(i);
315 while(!working_set.empty())
342 std::unique_ptr<statet> tmp_state(
345 statet &new_values=*tmp_state;
347 bool have_new_values=
false;
349 if(l->is_function_call() &&
361 have_new_values=
true;
368 new_values.
transform(l, to_l, *
this, ns);
370 if(
merge(new_values, l, to_l))
371 have_new_values=
true;
387 const goto_functionst::function_mapt::const_iterator f_it,
397 if(!goto_function.body_available())
401 tmp_state->
transform(l_call, l_return, *
this, ns);
403 return merge(*tmp_state, l_call, l_return);
406 assert(!goto_function.body.instructions.empty());
412 locationt l_begin=goto_function.body.instructions.begin();
418 tmp_state->
transform(l_call, l_begin, *
this, ns);
423 if(
merge(*tmp_state, l_call, l_begin))
428 fixedpoint(goto_function.body, goto_functions, ns);
435 locationt l_end=--goto_function.body.instructions.end();
436 assert(l_end->is_end_function());
441 if(end_state.is_bottom())
445 tmp_state->
transform(l_end, l_return, *
this, ns);
448 return merge(*tmp_state, l_end, l_return);
454 const exprt &
function,
463 if(
function.
id()==ID_symbol)
467 goto_functionst::function_mapt::const_iterator it=
471 throw "failed to find function "+
id2string(identifier);
480 else if(
function.
id()==ID_if)
482 if(
function.operands().size()!=3)
483 throw "if has three operands";
501 if(new_data1 || new_data2)
504 else if(
function.
id()==ID_dereference)
509 else if(
function.
id() == ID_null_object)
513 else if(
function.
id()==ID_member ||
function.
id()==ID_index)
519 throw "unexpected function_call argument: "+
520 function.id_string();
530 goto_functionst::function_mapt::const_iterator
534 fixedpoint(f_it->second.body, goto_functions, ns);
554 thread_wlt thread_wl;
559 if(is_threaded(t_it))
561 thread_wl.push_back(std::make_pair(&(it->second.body), t_it));
564 it->second.body.instructions.end();
573 bool new_shared=
true;
578 for(
const auto &wl_pair : thread_wl)
584 merge(begin_state, sh_target, wl_pair.second);
586 while(!working_set.empty())
590 visit(l, working_set, *(wl_pair.first), goto_functions, ns);
595 if(l->is_end_function())
596 new_shared|=
merge_shared(shared_state, l, sh_target, ns);
virtual statet & get_state(locationt l)=0
Over-approximate Concurrency for Threaded Goto Programs.
virtual void make_bottom()=0
const std::string & id2string(const irep_idt &d)
void put_in_working_set(working_sett &working_set, locationt l)
goto_programt::const_targett locationt
exprt simplify_expr(const exprt &src, const namespacet &ns)
const irep_idt & get_identifier() const
virtual bool merge(const statet &src, locationt from, locationt to)=0
virtual jsont output_json(const ai_baset &ai, const namespacet &ns) const
function_mapt function_map
virtual jsont output_json(const namespacet &ns, const goto_functionst &goto_functions) const
Output the domains for the whole program as JSON.
xmlt xml(const source_locationt &location)
virtual void transform(locationt from, locationt to, ai_baset &ai, const namespacet &ns)=0
const dereference_exprt & to_dereference_expr(const exprt &expr)
Cast a generic exprt to a dereference_exprt.
Extract member of struct or union.
std::map< unsigned, locationt > working_sett
virtual void output(const namespacet &ns, const goto_functionst &goto_functions, std::ostream &out) const
jsont & push_back(const jsont &json)
const exprt & compound() const
const irep_idt & id() const
bool do_function_call_rec(locationt l_call, locationt l_return, const exprt &function, const exprt::operandst &arguments, const goto_functionst &goto_functions, const namespacet &ns)
bool do_function_call(locationt l_call, locationt l_return, const goto_functionst &goto_functions, const goto_functionst::function_mapt::const_iterator f_it, const exprt::operandst &arguments, const namespacet &ns)
virtual bool ai_simplify(exprt &condition, const namespacet &ns) const
Operator to dereference a pointer.
instructionst instructions
The list of instructions in the goto program.
API to expression classes.
void set_attribute(const std::string &attribute, unsigned value)
instructionst::const_iterator const_targett
std::list< Target > get_successors(Target target) const
::goto_functiont goto_functiont
void entry_state(const goto_programt &)
const member_exprt & to_member_expr(const exprt &expr)
Cast a generic exprt to a member_exprt.
virtual const statet & find_state(locationt l) const =0
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast a generic exprt to a symbol_exprt.
virtual bool merge_shared(const statet &src, locationt from, locationt to, const namespacet &ns)=0
xmlt & new_element(const std::string &name)
void sequential_fixedpoint(const goto_functionst &goto_functions, const namespacet &ns)
std::vector< exprt > operandst
A generic container class for the GOTO intermediate representation of one function.
bool fixedpoint(const goto_programt &goto_program, const goto_functionst &goto_functions, const namespacet &ns)
bool visit(locationt l, working_sett &working_set, const goto_programt &goto_program, const goto_functionst &goto_functions, const namespacet &ns)
virtual std::unique_ptr< statet > make_temporary_state(const statet &s)=0
static irep_idt entry_point()
std::ostream & output_instruction(const namespacet &ns, const irep_idt &identifier, std::ostream &out, const instructionst::value_type &it) const
Output a single instruction.
virtual bool ai_simplify_lhs(exprt &condition, const namespacet &ns) const
Use the information in the domain to simplify the expression on the LHS of an assignment.
targett add_instruction()
Adds an instruction at the end.
virtual xmlt output_xml(const ai_baset &ai, const namespacet &ns) const
Base class for all expressions.
virtual void output(std::ostream &out, const ai_baset &ai, const namespacet &ns) const
locationt get_next(working_sett &working_set)
std::string to_string(const string_constraintt &expr)
Used for debug printing.
bool empty() const
Is the program empty?
virtual void initialize(const goto_programt &)
goto_programt & goto_program
void concurrent_fixedpoint(const goto_functionst &goto_functions, const namespacet &ns)
virtual xmlt output_xml(const namespacet &ns, const goto_functionst &goto_functions) const
Output the domains for the whole program as XML.
#define forall_goto_functions(it, functions)
#define forall_goto_program_instructions(it, program)
const index_exprt & to_index_expr(const exprt &expr)
Cast a generic exprt to an index_exprt.
json_objectt json(const source_locationt &location)
const code_function_callt & to_code_function_call(const codet &code)