@@ -35,10 +35,14 @@ class remove_instanceoft
35
35
}
36
36
37
37
// Lower instanceof for a single function
38
- bool lower_instanceof (goto_programt &);
38
+ bool lower_instanceof (
39
+ const irep_idt &function_identifier,
40
+ goto_programt &);
39
41
40
42
// Lower instanceof for a single instruction
41
- bool lower_instanceof (goto_programt &, goto_programt::targett);
43
+ bool lower_instanceof (
44
+ const irep_idt &function_identifier,
45
+ goto_programt &, goto_programt::targett);
42
46
43
47
protected:
44
48
symbol_table_baset &symbol_table;
@@ -47,6 +51,7 @@ class remove_instanceoft
47
51
message_handlert &message_handler;
48
52
49
53
bool lower_instanceof (
54
+ const irep_idt &function_identifier,
50
55
exprt &, goto_programt &, goto_programt::targett);
51
56
};
52
57
@@ -58,6 +63,7 @@ class remove_instanceoft
58
63
// / \param this_inst: instruction the expression is found at
59
64
// / \return true if any instanceof instructionw was replaced
60
65
bool remove_instanceoft::lower_instanceof (
66
+ const irep_idt &function_identifier,
61
67
exprt &expr,
62
68
goto_programt &goto_program,
63
69
goto_programt::targett this_inst)
@@ -66,7 +72,7 @@ bool remove_instanceoft::lower_instanceof(
66
72
{
67
73
bool changed = false ;
68
74
Forall_operands (it, expr)
69
- changed |= lower_instanceof (*it, goto_program, this_inst);
75
+ changed |= lower_instanceof (function_identifier, *it, goto_program, this_inst);
70
76
return changed;
71
77
}
72
78
@@ -109,15 +115,15 @@ bool remove_instanceoft::lower_instanceof(
109
115
110
116
symbolt &clsid_tmp_sym = get_fresh_aux_symbol (
111
117
object_clsid.type (),
112
- id2string (this_inst-> function ),
118
+ id2string (function_identifier ),
113
119
" class_identifier_tmp" ,
114
120
source_locationt (),
115
121
ID_java,
116
122
symbol_table);
117
123
118
124
symbolt &instanceof_result_sym = get_fresh_aux_symbol (
119
125
bool_typet (),
120
- id2string (this_inst-> function ),
126
+ id2string (function_identifier ),
121
127
" instanceof_result_tmp" ,
122
128
source_locationt (),
123
129
ID_java,
@@ -195,6 +201,7 @@ static bool contains_instanceof(const exprt &e)
195
201
// / \param target: instruction to check for instanceof expressions
196
202
// / \return true if an instanceof has been replaced
197
203
bool remove_instanceoft::lower_instanceof (
204
+ const irep_idt &function_identifier,
198
205
goto_programt &goto_program,
199
206
goto_programt::targett target)
200
207
{
@@ -210,24 +217,26 @@ bool remove_instanceoft::lower_instanceof(
210
217
++target;
211
218
}
212
219
213
- return lower_instanceof (target->code , goto_program, target) |
214
- lower_instanceof (target->guard , goto_program, target);
220
+ return lower_instanceof (function_identifier, target->code , goto_program, target) |
221
+ lower_instanceof (function_identifier, target->guard , goto_program, target);
215
222
}
216
223
217
224
// / Replace every instanceof in the passed function body with an explicit
218
225
// / class-identifier test.
219
226
// / Extra auxiliary variables may be introduced into symbol_table.
220
227
// / \param goto_program: The function body to work on.
221
228
// / \return true if one or more instanceof expressions have been replaced
222
- bool remove_instanceoft::lower_instanceof (goto_programt &goto_program)
229
+ bool remove_instanceoft::lower_instanceof (
230
+ const irep_idt &function_identifier,
231
+ goto_programt &goto_program)
223
232
{
224
233
bool changed=false ;
225
234
for (goto_programt::instructionst::iterator target=
226
235
goto_program.instructions .begin ();
227
236
target!=goto_program.instructions .end ();
228
237
++target)
229
238
{
230
- changed=lower_instanceof (goto_program, target) || changed;
239
+ changed=lower_instanceof (function_identifier, goto_program, target) || changed;
231
240
}
232
241
if (!changed)
233
242
return false ;
@@ -244,14 +253,15 @@ bool remove_instanceoft::lower_instanceof(goto_programt &goto_program)
244
253
// / \param class_hierarchy: class hierarchy analysis of symbol_table
245
254
// / \param message_handler: logging output
246
255
void remove_instanceof (
256
+ const irep_idt &function_identifier,
247
257
goto_programt::targett target,
248
258
goto_programt &goto_program,
249
259
symbol_table_baset &symbol_table,
250
260
const class_hierarchyt &class_hierarchy,
251
261
message_handlert &message_handler)
252
262
{
253
263
remove_instanceoft rem (symbol_table, class_hierarchy, message_handler);
254
- rem.lower_instanceof (goto_program, target);
264
+ rem.lower_instanceof (function_identifier, goto_program, target);
255
265
}
256
266
257
267
// / Replace every instanceof in the passed function with an explicit
@@ -262,13 +272,14 @@ void remove_instanceof(
262
272
// / \param class_hierarchy: class hierarchy analysis of symbol_table
263
273
// / \param message_handler: logging output
264
274
void remove_instanceof (
275
+ const irep_idt &function_identifier,
265
276
goto_functionst::goto_functiont &function,
266
277
symbol_table_baset &symbol_table,
267
278
const class_hierarchyt &class_hierarchy,
268
279
message_handlert &message_handler)
269
280
{
270
281
remove_instanceoft rem (symbol_table, class_hierarchy, message_handler);
271
- rem.lower_instanceof (function.body );
282
+ rem.lower_instanceof (function_identifier, function.body );
272
283
}
273
284
274
285
// / Replace every instanceof in every function with an explicit
@@ -287,7 +298,7 @@ void remove_instanceof(
287
298
remove_instanceoft rem (symbol_table, class_hierarchy, message_handler);
288
299
bool changed=false ;
289
300
for (auto &f : goto_functions.function_map )
290
- changed=rem.lower_instanceof (f.second .body ) || changed;
301
+ changed=rem.lower_instanceof (f.first , f. second .body ) || changed;
291
302
if (changed)
292
303
goto_functions.compute_location_numbers ();
293
304
}
0 commit comments