Skip to content

Commit e0afc7d

Browse files
martinmartin-cs
authored andcommitted
Move the handling of whole program analysis into the interprocedural code
1 parent 5bdff46 commit e0afc7d

File tree

3 files changed

+52
-24
lines changed

3 files changed

+52
-24
lines changed

src/analyses/ai.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,47 @@ bool ai_baset::visit_end_function(
536536
return false;
537537
}
538538

539+
void ai_localt::operator()(
540+
const goto_functionst &goto_functions,
541+
const namespacet &ns)
542+
{
543+
initialize(goto_functions);
544+
for(const auto &gf_entry : goto_functions.function_map)
545+
{
546+
if(gf_entry.second.body_available())
547+
{
548+
trace_ptrt p = entry_state(gf_entry.second.body);
549+
fixedpoint(p, gf_entry.first, gf_entry.second.body, goto_functions, ns);
550+
}
551+
}
552+
finalize();
553+
}
554+
555+
void ai_localt::operator()(const abstract_goto_modelt &goto_model)
556+
{
557+
const namespacet ns(goto_model.get_symbol_table());
558+
operator()(goto_model.get_goto_functions(), ns);
559+
}
560+
561+
void ai_recursive_interproceduralt::
562+
operator()(const goto_functionst &goto_functions, const namespacet &ns)
563+
{
564+
initialize(goto_functions);
565+
trace_ptrt p = entry_state(goto_functions);
566+
fixedpoint(p, goto_functions, ns);
567+
finalize();
568+
}
569+
570+
void ai_recursive_interproceduralt::operator()(
571+
const abstract_goto_modelt &goto_model)
572+
{
573+
const namespacet ns(goto_model.get_symbol_table());
574+
initialize(goto_model.get_goto_functions());
575+
trace_ptrt p = entry_state(goto_model.get_goto_functions());
576+
fixedpoint(p, goto_model.get_goto_functions(), ns);
577+
finalize();
578+
}
579+
539580
bool ai_recursive_interproceduralt::visit_edge_function_call(
540581
const irep_idt &calling_function_id,
541582
trace_ptrt p_call,

src/analyses/ai.h

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -153,28 +153,12 @@ class ai_baset
153153
}
154154

155155
/// Run abstract interpretation on a whole program
156-
void operator()(
157-
const goto_functionst &goto_functions,
158-
const namespacet &ns)
159-
{
160-
initialize(goto_functions);
161-
trace_ptrt p = entry_state(goto_functions);
162-
fixedpoint(p, goto_functions, ns);
163-
finalize();
164-
}
165-
166-
/// Run abstract interpretation on a whole program
167-
void operator()(const abstract_goto_modelt &goto_model)
168-
{
169-
const namespacet ns(goto_model.get_symbol_table());
170-
initialize(goto_model.get_goto_functions());
171-
trace_ptrt p = entry_state(goto_model.get_goto_functions());
172-
fixedpoint(p, goto_model.get_goto_functions(), ns);
173-
finalize();
174-
}
156+
virtual void
157+
operator()(const goto_functionst &goto_functions, const namespacet &ns) = 0;
158+
virtual void operator()(const abstract_goto_modelt &goto_model) = 0;
175159

176160
/// Run abstract interpretation on a single function
177-
void operator()(
161+
virtual void operator()(
178162
const irep_idt &function_id,
179163
const goto_functionst::goto_functiont &goto_function,
180164
const namespacet &ns)
@@ -308,9 +292,7 @@ class ai_baset
308292
std::ostream &out) const;
309293

310294
/// Output the abstract states for a whole program
311-
void output(
312-
const goto_modelt &goto_model,
313-
std::ostream &out) const
295+
virtual void output(const goto_modelt &goto_model, std::ostream &out) const
314296
{
315297
const namespacet ns(goto_model.symbol_table);
316298
output(ns, goto_model.goto_functions, out);
@@ -535,6 +517,11 @@ class ai_recursive_interproceduralt : public ai_baset
535517
{
536518
}
537519

520+
// Whole program analysis by starting at the entry function and recursing
521+
void operator()(const goto_functionst &goto_functions, const namespacet &ns)
522+
override;
523+
void operator()(const abstract_goto_modelt &goto_model) override;
524+
538525
protected:
539526
// Override the function that handles a single function call edge
540527
bool visit_edge_function_call(

src/analyses/constant_propagator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ class constant_propagator_ait:public ait<constant_propagator_domaint>
207207
should_track_valuet should_track_value = track_all_values)
208208
: dirty(goto_function), should_track_value(should_track_value)
209209
{
210-
operator()(function_identifier, goto_function, ns);
210+
ai_baset::operator()(function_identifier, goto_function, ns);
211211
replace(goto_function, ns);
212212
}
213213

0 commit comments

Comments
 (0)