@@ -23,8 +23,11 @@ Author: Chris Smowton, chris.smowton@diffblue.com
2323class remove_instanceoft
2424{
2525public:
26- explicit remove_instanceoft (symbol_table_baset &symbol_table)
27- : symbol_table(symbol_table), ns(symbol_table)
26+ remove_instanceoft (
27+ symbol_table_baset &symbol_table, message_handlert &message_handler)
28+ : symbol_table(symbol_table)
29+ , ns(symbol_table)
30+ , message_handler(message_handler)
2831 {
2932 class_hierarchy (symbol_table);
3033 }
@@ -39,6 +42,7 @@ class remove_instanceoft
3942 symbol_table_baset &symbol_table;
4043 namespacet ns;
4144 class_hierarchyt class_hierarchy;
45+ message_handlert &message_handler;
4246
4347 bool lower_instanceof (
4448 exprt &, goto_programt &, goto_programt::targett);
@@ -154,24 +158,15 @@ bool remove_instanceoft::lower_instanceof(
154158 // Replace the instanceof construct with instanceof_result:
155159 expr = instanceof_result_sym.symbol_expr ();
156160
157- std::ostringstream convert_output;
158- stream_message_handlert convert_message_handler (convert_output);
159- convert_message_handler.set_verbosity (messaget::message_levelt::M_WARNING);
160-
161161 // Insert the new test block before it:
162162 goto_programt new_check_program;
163163 goto_convert (
164164 is_null_branch,
165165 symbol_table,
166166 new_check_program,
167- convert_message_handler ,
167+ message_handler ,
168168 ID_java);
169169
170- INVARIANT (
171- convert_output.str ().empty (),
172- " remove_instanceof generated test should be goto-converted without error, "
173- " but goto_convert reported: " + convert_output.str ());
174-
175170 goto_program.destructive_insert (this_inst, new_check_program);
176171
177172 return true ;
@@ -245,12 +240,14 @@ bool remove_instanceoft::lower_instanceof(goto_programt &goto_program)
245240// / \param target: The instruction to work on.
246241// / \param goto_program: The function body containing the instruction.
247242// / \param symbol_table: The symbol table to add symbols to.
243+ // / \param message_handler: logging output
248244void remove_instanceof (
249245 goto_programt::targett target,
250246 goto_programt &goto_program,
251- symbol_table_baset &symbol_table)
247+ symbol_table_baset &symbol_table,
248+ message_handlert &message_handler)
252249{
253- remove_instanceoft rem (symbol_table);
250+ remove_instanceoft rem (symbol_table, message_handler );
254251 rem.lower_instanceof (goto_program, target);
255252}
256253
@@ -259,11 +256,13 @@ void remove_instanceof(
259256// / \remarks Extra auxiliary variables may be introduced into symbol_table.
260257// / \param function: The function to work on.
261258// / \param symbol_table: The symbol table to add symbols to.
259+ // / \param message_handler: logging output
262260void remove_instanceof (
263261 goto_functionst::goto_functiont &function,
264- symbol_table_baset &symbol_table)
262+ symbol_table_baset &symbol_table,
263+ message_handlert &message_handler)
265264{
266- remove_instanceoft rem (symbol_table);
265+ remove_instanceoft rem (symbol_table, message_handler );
267266 rem.lower_instanceof (function.body );
268267}
269268
@@ -272,11 +271,13 @@ void remove_instanceof(
272271// / \remarks Extra auxiliary variables may be introduced into symbol_table.
273272// / \param goto_functions: The functions to work on.
274273// / \param symbol_table: The symbol table to add symbols to.
274+ // / \param message_handler: logging output
275275void remove_instanceof (
276276 goto_functionst &goto_functions,
277- symbol_table_baset &symbol_table)
277+ symbol_table_baset &symbol_table,
278+ message_handlert &message_handler)
278279{
279- remove_instanceoft rem (symbol_table);
280+ remove_instanceoft rem (symbol_table, message_handler );
280281 bool changed=false ;
281282 for (auto &f : goto_functions.function_map )
282283 changed=rem.lower_instanceof (f.second .body ) || changed;
@@ -288,8 +289,12 @@ void remove_instanceof(
288289// / class-identifier test.
289290// / \remarks Extra auxiliary variables may be introduced into symbol_table.
290291// / \param goto_model: The functions to work on and the symbol table to add
292+ // / \param message_handler: logging output
291293// / symbols to.
292- void remove_instanceof (goto_modelt &goto_model)
294+ void remove_instanceof (
295+ goto_modelt &goto_model,
296+ message_handlert &message_handler)
293297{
294- remove_instanceof (goto_model.goto_functions , goto_model.symbol_table );
298+ remove_instanceof (
299+ goto_model.goto_functions , goto_model.symbol_table , message_handler);
295300}
0 commit comments