Go to the documentation of this file.
45 #ifndef CPROVER_ANALYSES_AI_H
46 #define CPROVER_ANALYSES_AI_H
129 std::unique_ptr<ai_history_factory_baset> &&hf,
130 std::unique_ptr<ai_domain_factory_baset> &&df,
131 std::unique_ptr<ai_storage_baset> &&st,
153 fixedpoint(p, function_id, goto_program, goto_functions, ns);
187 fixedpoint(p, function_id, goto_function.body, goto_functions, ns);
198 return storage->abstract_traces_before(l);
210 INVARIANT(!l->is_end_function(),
"No state after the last instruction");
211 return storage->abstract_traces_before(std::next(l));
240 INVARIANT(!l->is_end_function(),
"No state after the last instruction");
253 INVARIANT(!l->is_end_function(),
"No state after the last instruction");
257 auto step_return = p->step(
259 *(
storage->abstract_traces_before(n)),
282 std::ostream &out)
const;
288 std::ostream &out)
const;
293 std::ostream &out)
const
303 std::ostream &out)
const
423 working_set.insert(t);
483 const irep_idt &calling_function_id,
532 std::unique_ptr<ai_history_factory_baset> &&hf,
533 std::unique_ptr<ai_domain_factory_baset> &&df,
534 std::unique_ptr<ai_storage_baset> &&st,
536 :
ai_baset(std::move(hf), std::move(df), std::move(st), mh)
543 const irep_idt &calling_function_id,
562 template <
typename domainT>
577 explicit ait(std::unique_ptr<ai_domain_factory_baset> &&df)
594 DEPRECATED(
SINCE(2019, 08, 01,
"use abstract_state_{before,after} instead"))
599 if(p.use_count() == 1)
602 throw std::out_of_range(
"failed to find state");
605 return static_cast<const domainT &
>(*p);
651 template<
typename domainT>
663 :
ait<domainT>(std::move(df))
675 static_cast<const domainT &
>(src), from, to, ns);
705 : function_id(_function_id),
706 goto_program(&_goto_program),
716 typedef std::list<wl_entryt> thread_wlt;
717 thread_wlt thread_wl;
723 if(is_threaded(t_it))
726 wl_entryt(gf_entry.first, gf_entry.second.body, t_it));
729 gf_entry.second.body.instructions.end();
739 bool new_shared =
true;
744 for(
const auto &wl_entry : thread_wl)
754 while(!working_set.empty())
760 wl_entry.function_id,
763 *(wl_entry.goto_program),
770 if(l->is_end_function())
771 new_shared |=
merge_shared(shared_state, l, sh_target, ns);
778 #endif // CPROVER_ANALYSES_AI_H
xmlt output_xml(const namespacet &ns, const goto_programt &goto_program) const
Output the abstract states for a single function as XML.
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
virtual cstate_ptrt abstract_state_after(const trace_ptrt &p) const
virtual jsont output_json(const namespacet &ns, const goto_functionst &goto_functions) const
Output the abstract states for the whole program as JSON.
trace_ptrt get_next(working_sett &working_set)
Get the next location from the work queue.
virtual const symbol_tablet & get_symbol_table() const =0
Accessor to get the symbol table.
virtual ctrace_set_ptrt abstract_traces_after(locationt l) const
Returns all of the histories that have reached the end of the instruction.
void fixedpoint(ai_baset::trace_ptrt start_trace, const goto_functionst &goto_functions, const namespacet &ns) override
virtual bool visit_end_function(const irep_idt &function_id, trace_ptrt p, working_sett &working_set, const goto_programt &goto_program, const goto_functionst &goto_functions, const namespacet &ns)
goto_programt::const_targett locationt
trace_sett working_sett
The work queue, sorted using the history's ordering operator.
virtual bool merge_shared(const statet &src, locationt from, locationt to, const namespacet &ns)
The common case of history is to only care about where you are now, not how you got there!...
null_message_handlert no_logging
virtual bool visit_function_call(const irep_idt &function_id, trace_ptrt p_call, working_sett &working_set, const goto_programt &goto_program, const goto_functionst &goto_functions, const namespacet &ns)
void dummy(const domainT &s)
This function exists to enforce that domainT is derived from ai_domain_baset.
ai_recursive_interproceduralt(std::unique_ptr< ai_history_factory_baset > &&hf, std::unique_ptr< ai_domain_factory_baset > &&df, std::unique_ptr< ai_storage_baset > &&st, message_handlert &mh)
void operator()(const abstract_goto_modelt &goto_model)
Run abstract interpretation on a whole program.
virtual std::unique_ptr< statet > make_temporary_state(const statet &s)
Make a copy of a state.
message_handlert & message_handler
virtual bool visit(const irep_idt &function_id, trace_ptrt p, working_sett &working_set, const goto_programt &goto_program, const goto_functionst &goto_functions, const namespacet &ns)
Perform one step of abstract interpretation from trace t Depending on the instruction type it may com...
void put_in_working_set(working_sett &working_set, trace_ptrt t)
virtual xmlt output_xml(const namespacet &ns, const goto_functionst &goto_functions) const
Output the abstract states for the whole program as XML.
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
virtual cstate_ptrt abstract_state_before(locationt l) const
Get a copy of the abstract state before the given instruction, without needing to know what kind of d...
static const trace_ptrt no_caller_history
function_mapt function_map
statet & get_state(trace_ptrt p, const ai_domain_factory_baset &fac) override
Look up the analysis state for a given history, instantiating a new domain if required.
virtual cstate_ptrt abstract_state_after(locationt l) const
Get a copy of the abstract state after the given instruction, without needing to know what kind of do...
ai_baset(std::unique_ptr< ai_history_factory_baset > &&hf, std::unique_ptr< ai_domain_factory_baset > &&df, std::unique_ptr< ai_storage_baset > &&st, message_handlert &mh)
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
targett add_instruction()
Adds an instruction at the end.
std::unique_ptr< T > util_make_unique(Ts &&... ts)
virtual statet & get_state(trace_ptrt p)
Get the state for the given history, creating it with the factory if it doesn't exist.
std::set< trace_ptrt, compare_historyt > trace_sett
goto_programt::const_targett locationt
void operator()(const goto_functionst &goto_functions, const namespacet &ns)
Run abstract interpretation on a whole program.
An easy factory implementation for histories that don't need parameters.
jsont output_json(const namespacet &ns, const goto_functionst::goto_functiont &goto_function) const
Output the abstract states for a single function as JSON.
void output(const goto_modelt &goto_model, std::ostream &out) const
Output the abstract states for a whole program.
std::unique_ptr< ai_domain_factory_baset > domain_factory
For creating domain objects.
std::shared_ptr< const trace_sett > ctrace_set_ptrt
std::unique_ptr< ai_storage_baset > storage
concurrency_aware_ait(std::unique_ptr< ai_domain_factory_baset > &&df)
virtual ctrace_set_ptrt abstract_traces_before(locationt l) const
Returns all of the histories that have reached the start of the instruction.
jsont output_json(const namespacet &ns, const goto_programt &goto_program) const
Output the abstract states for a single function as JSON.
ai_storage_baset::cstate_ptrt cstate_ptrt
std::unique_ptr< ai_history_factory_baset > history_factory
For creating history objects.
#define SINCE(year, month, day, msg)
virtual void finalize()
Override this to add a cleanup or post-processing step after fixedpoint has run.
The most conventional storage; one domain per location.
bool visit_edge(const irep_idt &function_id, trace_ptrt p, const irep_idt &to_function_id, locationt to_l, trace_ptrt caller_history, const namespacet &ns, working_sett &working_set)
trace_ptrt entry_state(const goto_programt &goto_program)
Set the abstract state of the entry location of a single function to the entry state required by the ...
virtual bool merge(const statet &src, trace_ptrt from, trace_ptrt to)
Merge the state src, flowing from tracet from to tracet to, into the state currently stored for trace...
virtual cstate_ptrt abstract_state_before(const trace_ptrt &p) const
The same interfaces but with histories.
::goto_functiont goto_functiont
instructionst instructions
The list of instructions in the goto program.
virtual void initialize(const irep_idt &function_id, const goto_programt &goto_program)
Initialize all the abstract states for a single function.
A collection of goto functions.
void output(const namespacet &ns, const goto_functionst::goto_functiont &goto_function, std::ostream &out) const
Output the abstract states for a function.
goto_programt::const_targett locationt
virtual const goto_functionst & get_goto_functions() const =0
Accessor to get a raw goto_functionst.
virtual bool fixedpoint(trace_ptrt starting_trace, const irep_idt &function_id, const goto_programt &goto_program, const goto_functionst &goto_functions, const namespacet &ns)
Run the fixedpoint algorithm until it reaches a fixed point.
goto_functionst goto_functions
GOTO functions.
ai_history_baset::trace_sett trace_sett
virtual void output(const namespacet &ns, const irep_idt &function_id, const goto_programt &goto_program, std::ostream &out) const
Output the abstract states for a single function.
std::shared_ptr< const ai_history_baset > trace_ptrt
History objects are intended to be immutable so they can be shared to reduce memory overhead.
std::shared_ptr< const statet > cstate_ptrt
Base class for concurrency-aware abstract interpretation.
This is the basic interface of the abstract interpreter with default implementations of the core func...
jsont output_json(const goto_modelt &goto_model) const
Output the abstract states for a whole program as JSON.
void operator()(const irep_idt &function_id, const goto_programt &goto_program, const namespacet &ns)
Run abstract interpretation on a single function.
ait(std::unique_ptr< ai_domain_factory_baset > &&df)
A generic container class for the GOTO intermediate representation of one function.
virtual bool visit_edge_function_call(const irep_idt &calling_function_id, trace_ptrt p_call, locationt l_return, const irep_idt &callee_function_id, working_sett &working_set, const goto_programt &callee, const goto_functionst &goto_functions, const namespacet &ns)
ai_history_baset::trace_ptrt trace_ptrt
virtual void clear()
Reset the abstract state.
instructionst::const_iterator const_targett
ai_storage_baset::ctrace_set_ptrt ctrace_set_ptrt
Abstract interface to eager or lazy GOTO models.
The interface offered by a domain, allows code to manipulate domains without knowing their exact type...
xmlt output_xml(const goto_modelt &goto_model) const
Output the abstract states for the whole program as XML.
virtual statet & get_state(locationt l)
xmlt output_xml(const namespacet &ns, const goto_functionst::goto_functiont &goto_function) const
Output the abstract states for a single function as XML.
symbol_tablet symbol_table
Symbol table.
void operator()(const irep_idt &function_id, const goto_functionst::goto_functiont &goto_function, const namespacet &ns)
Run abstract interpretation on a single function.
#define forall_goto_program_instructions(it, program)
bool visit_edge_function_call(const irep_idt &calling_function_id, trace_ptrt p_call, locationt l_return, const irep_idt &callee_function_id, working_sett &working_set, const goto_programt &callee, const goto_functionst &goto_functions, const namespacet &ns) override