Skip to content

Commit 31fcbd2

Browse files
author
martin
committed
Create a new kind of abstract interpreter that does function-local analysis
1 parent 8346a3f commit 31fcbd2

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

src/analyses/ai.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,27 @@ bool ai_baset::visit_end_function(
531531
return false;
532532
}
533533

534+
void ai_localt::
535+
operator()(const goto_functionst &goto_functions, const namespacet &ns)
536+
{
537+
initialize(goto_functions);
538+
for(const auto &gf_entry : goto_functions.function_map)
539+
{
540+
if(gf_entry.second.body_available())
541+
{
542+
trace_ptrt p = entry_state(gf_entry.second.body);
543+
fixedpoint(p, gf_entry.first, gf_entry.second.body, goto_functions, ns);
544+
}
545+
}
546+
finalize();
547+
}
548+
549+
void ai_localt::operator()(const abstract_goto_modelt &goto_model)
550+
{
551+
const namespacet ns(goto_model.get_symbol_table());
552+
operator()(goto_model.get_goto_functions(), ns);
553+
}
554+
534555
void ai_recursive_interproceduralt::
535556
operator()(const goto_functionst &goto_functions, const namespacet &ns)
536557
{

src/analyses/ai.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,27 @@ class ai_baset
505505
message_handlert &message_handler;
506506
};
507507

508+
// Perform function local analysis on all functions in a program.
509+
// No interprocedural analysis other than what a domain does when
510+
// visit()'ing an edge that skips a function call.
511+
class ai_localt : public ai_baset
512+
{
513+
public:
514+
ai_localt(
515+
std::unique_ptr<ai_history_factory_baset> &&hf,
516+
std::unique_ptr<ai_domain_factory_baset> &&df,
517+
std::unique_ptr<ai_storage_baset> &&st,
518+
message_handlert &mh)
519+
: ai_baset(std::move(hf), std::move(df), std::move(st), mh)
520+
{
521+
}
522+
523+
// Handle every function independently
524+
void operator()(const goto_functionst &goto_functions, const namespacet &ns)
525+
override;
526+
void operator()(const abstract_goto_modelt &goto_model) override;
527+
};
528+
508529
// Perform interprocedural analysis by simply recursing in the interpreter
509530
// This can lead to a call stack overflow if the domain has a large height
510531
class ai_recursive_interproceduralt : public ai_baset

0 commit comments

Comments
 (0)