Skip to content

Commit 8346a3f

Browse files
author
martin
committed
Move the handling of whole program analysis into the interprocedural code
1 parent 47c1c7e commit 8346a3f

File tree

3 files changed

+30
-24
lines changed

3 files changed

+30
-24
lines changed

src/analyses/ai.cpp

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

534+
void ai_recursive_interproceduralt::
535+
operator()(const goto_functionst &goto_functions, const namespacet &ns)
536+
{
537+
initialize(goto_functions);
538+
trace_ptrt p = entry_state(goto_functions);
539+
fixedpoint(p, goto_functions, ns);
540+
finalize();
541+
}
542+
543+
void ai_recursive_interproceduralt::
544+
operator()(const abstract_goto_modelt &goto_model)
545+
{
546+
const namespacet ns(goto_model.get_symbol_table());
547+
initialize(goto_model.get_goto_functions());
548+
trace_ptrt p = entry_state(goto_model.get_goto_functions());
549+
fixedpoint(p, goto_model.get_goto_functions(), ns);
550+
finalize();
551+
}
552+
534553
bool ai_recursive_interproceduralt::visit_edge_function_call(
535554
const irep_idt &calling_function_id,
536555
trace_ptrt p_call,

src/analyses/ai.h

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -155,28 +155,12 @@ class ai_baset
155155
}
156156

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

178162
/// Run abstract interpretation on a single function
179-
void operator()(
163+
virtual void operator()(
180164
const irep_idt &function_id,
181165
const goto_functionst::goto_functiont &goto_function,
182166
const namespacet &ns)
@@ -288,9 +272,7 @@ class ai_baset
288272
std::ostream &out) const;
289273

290274
/// Output the abstract states for a whole program
291-
void output(
292-
const goto_modelt &goto_model,
293-
std::ostream &out) const
275+
virtual void output(const goto_modelt &goto_model, std::ostream &out) const
294276
{
295277
const namespacet ns(goto_model.symbol_table);
296278
output(ns, goto_model.goto_functions, out);
@@ -537,6 +519,11 @@ class ai_recursive_interproceduralt : public ai_baset
537519
{
538520
}
539521

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

src/analyses/constant_propagator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ class constant_propagator_ait:public ait<constant_propagator_domaint>
212212
should_track_valuet should_track_value = track_all_values)
213213
: dirty(goto_function), should_track_value(should_track_value)
214214
{
215-
operator()(function_identifier, goto_function, ns);
215+
ai_baset::operator()(function_identifier, goto_function, ns);
216216
replace(goto_function, ns);
217217
}
218218

0 commit comments

Comments
 (0)