Skip to content

Commit e03b0cb

Browse files
committed
Abstract interpreter: add finalize hook
At least dependence_grapht has good reason to do work at the end of the day-- namely to create an alternative data representation that is trickier to keep up to date incrementally than to produce in one go at the end. It seems likely other AIs will have use for a post-fixedpoint hook.
1 parent 94ffce3 commit e03b0cb

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/analyses/ai.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,11 @@ void ai_baset::initialize(const goto_functionst &goto_functions)
280280
initialize(it->second);
281281
}
282282

283+
void ai_baset::finalize()
284+
{
285+
// Nothing to do per default
286+
}
287+
283288
ai_baset::locationt ai_baset::get_next(
284289
working_sett &working_set)
285290
{

src/analyses/ai.h

+7
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ class ai_baset
133133
initialize(goto_program);
134134
entry_state(goto_program);
135135
fixedpoint(goto_program, goto_functions, ns);
136+
finalize();
136137
}
137138

138139
void operator()(
@@ -142,6 +143,7 @@ class ai_baset
142143
initialize(goto_functions);
143144
entry_state(goto_functions);
144145
fixedpoint(goto_functions, ns);
146+
finalize();
145147
}
146148

147149
void operator()(const goto_modelt &goto_model)
@@ -150,6 +152,7 @@ class ai_baset
150152
initialize(goto_model.goto_functions);
151153
entry_state(goto_model.goto_functions);
152154
fixedpoint(goto_model.goto_functions, ns);
155+
finalize();
153156
}
154157

155158
void operator()(
@@ -160,6 +163,7 @@ class ai_baset
160163
initialize(goto_function);
161164
entry_state(goto_function.body);
162165
fixedpoint(goto_function.body, goto_functions, ns);
166+
finalize();
163167
}
164168

165169
/// Returns the abstract state before the given instruction
@@ -264,6 +268,9 @@ class ai_baset
264268
virtual void initialize(const goto_functionst::goto_functiont &);
265269
virtual void initialize(const goto_functionst &);
266270

271+
// override to add a cleanup step after fixedpoint has run
272+
virtual void finalize();
273+
267274
void entry_state(const goto_programt &);
268275
void entry_state(const goto_functionst &);
269276

0 commit comments

Comments
 (0)