@@ -33,23 +33,27 @@ class remove_java_newt : public messaget
33
33
}
34
34
35
35
// Lower java_new for a single function
36
- bool lower_java_new (goto_programt &);
36
+ bool lower_java_new (const irep_idt &function_identifier, goto_programt &);
37
37
38
38
// Lower java_new for a single instruction
39
- goto_programt::targett
40
- lower_java_new (goto_programt &, goto_programt::targett);
39
+ goto_programt::targett lower_java_new (
40
+ const irep_idt &function_identifier,
41
+ goto_programt &,
42
+ goto_programt::targett);
41
43
42
44
protected:
43
45
symbol_table_baset &symbol_table;
44
46
namespacet ns;
45
47
46
48
goto_programt::targett lower_java_new (
49
+ const irep_idt &function_identifier,
47
50
exprt lhs,
48
51
side_effect_exprt rhs,
49
52
goto_programt &,
50
53
goto_programt::targett);
51
54
52
55
goto_programt::targett lower_java_new_array (
56
+ const irep_idt &function_identifier,
53
57
exprt lhs,
54
58
side_effect_exprt rhs,
55
59
goto_programt &,
@@ -60,6 +64,7 @@ class remove_java_newt : public messaget
60
64
// / two instructions:
61
65
// / lhs = ALLOCATE(java_type)
62
66
// / *lhs = { zero-initialized java_type }
67
+ // / \param function_identifier: Name of the function containing \p target.
63
68
// / \param lhs: the lhs
64
69
// / \param rhs: the rhs
65
70
// / \param dest: the goto program to modify
@@ -68,6 +73,7 @@ class remove_java_newt : public messaget
68
73
// / Note: we have to take a copy of `lhs` and `rhs` since they would suffer
69
74
// / destruction when replacing the instruction.
70
75
goto_programt::targett remove_java_newt::lower_java_new (
76
+ const irep_idt &function_identifier,
71
77
exprt lhs,
72
78
side_effect_exprt rhs,
73
79
goto_programt &dest,
@@ -108,6 +114,7 @@ goto_programt::targett remove_java_newt::lower_java_new(
108
114
// / the following code:
109
115
// / lhs = ALLOCATE(java_type)
110
116
// / loops to initialize the elements (including multi-dimensional arrays)
117
+ // / \param function_identifier: Name of the function containing \p target.
111
118
// / \param lhs: the lhs
112
119
// / \param rhs: the rhs
113
120
// / \param dest: the goto program to modify
@@ -116,6 +123,7 @@ goto_programt::targett remove_java_newt::lower_java_new(
116
123
// / Note: we have to take a copy of `lhs` and `rhs` since they would suffer
117
124
// / destruction when replacing the instruction.
118
125
goto_programt::targett remove_java_newt::lower_java_new_array (
126
+ const irep_idt &function_identifier,
119
127
exprt lhs,
120
128
side_effect_exprt rhs,
121
129
goto_programt &dest,
@@ -206,7 +214,7 @@ goto_programt::targett remove_java_newt::lower_java_new_array(
206
214
// `x=typecast_exprt(side_effect_exprt(...))`
207
215
symbol_exprt new_array_data_symbol = get_fresh_aux_symbol (
208
216
data_java_new_expr.type (),
209
- id2string (target-> function ),
217
+ id2string (function_identifier ),
210
218
" tmp_new_data_array" ,
211
219
location,
212
220
ID_java,
@@ -254,7 +262,7 @@ goto_programt::targett remove_java_newt::lower_java_new_array(
254
262
255
263
symbol_exprt tmp_i = get_fresh_aux_symbol (
256
264
length.type (),
257
- id2string (target-> function ),
265
+ id2string (function_identifier ),
258
266
" tmp_index" ,
259
267
location,
260
268
ID_java,
@@ -286,7 +294,7 @@ goto_programt::targett remove_java_newt::lower_java_new_array(
286
294
code_blockt for_body;
287
295
symbol_exprt init_sym = get_fresh_aux_symbol (
288
296
sub_type,
289
- id2string (target-> function ),
297
+ id2string (function_identifier ),
290
298
" subarray_init" ,
291
299
location,
292
300
ID_java,
@@ -311,7 +319,7 @@ goto_programt::targett remove_java_newt::lower_java_new_array(
311
319
goto_convert (for_loop, symbol_table, tmp, get_message_handler (), ID_java);
312
320
313
321
// lower new side effects recursively
314
- lower_java_new (tmp);
322
+ lower_java_new (function_identifier, tmp);
315
323
316
324
dest.destructive_insert (next, tmp);
317
325
}
@@ -321,10 +329,12 @@ goto_programt::targett remove_java_newt::lower_java_new_array(
321
329
322
330
// / Replace every java_new or java_new_array by a malloc side-effect
323
331
// / and zero initialization.
332
+ // / \param function_identifier: Name of the function containing \p target.
324
333
// / \param goto_program: program to process
325
334
// / \param target: instruction to check for java_new expressions
326
335
// / \return true if a replacement has been made
327
336
goto_programt::targett remove_java_newt::lower_java_new (
337
+ const irep_idt &function_identifier,
328
338
goto_programt &goto_program,
329
339
goto_programt::targett target)
330
340
{
@@ -338,13 +348,14 @@ goto_programt::targett remove_java_newt::lower_java_new(
338
348
339
349
if (rhs.id () == ID_side_effect && rhs.get (ID_statement) == ID_java_new)
340
350
{
341
- return lower_java_new (lhs, to_side_effect_expr (rhs), goto_program, target);
351
+ return lower_java_new (
352
+ function_identifier, lhs, to_side_effect_expr (rhs), goto_program, target);
342
353
}
343
354
344
355
if (rhs.id () == ID_side_effect && rhs.get (ID_statement) == ID_java_new_array)
345
356
{
346
357
return lower_java_new_array (
347
- lhs, to_side_effect_expr (rhs), goto_program, target);
358
+ function_identifier, lhs, to_side_effect_expr (rhs), goto_program, target);
348
359
}
349
360
350
361
return target;
@@ -353,17 +364,21 @@ goto_programt::targett remove_java_newt::lower_java_new(
353
364
// / Replace every java_new or java_new_array by a malloc side-effect
354
365
// / and zero initialization.
355
366
// / Extra auxiliary variables may be introduced into symbol_table.
367
+ // / \param function_identifier: Name of the function \p goto_program.
356
368
// / \param goto_program: The function body to work on.
357
369
// / \return true if one or more java_new expressions have been replaced
358
- bool remove_java_newt::lower_java_new (goto_programt &goto_program)
370
+ bool remove_java_newt::lower_java_new (
371
+ const irep_idt &function_identifier,
372
+ goto_programt &goto_program)
359
373
{
360
374
bool changed = false ;
361
375
for (goto_programt::instructionst::iterator target =
362
376
goto_program.instructions .begin ();
363
377
target != goto_program.instructions .end ();
364
378
++target)
365
379
{
366
- goto_programt::targett new_target = lower_java_new (goto_program, target);
380
+ goto_programt::targett new_target =
381
+ lower_java_new (function_identifier, goto_program, target);
367
382
changed = changed || new_target == target;
368
383
target = new_target;
369
384
}
@@ -376,33 +391,37 @@ bool remove_java_newt::lower_java_new(goto_programt &goto_program)
376
391
// / Replace every java_new or java_new_array by a malloc side-effect
377
392
// / and zero initialization.
378
393
// / \remarks Extra auxiliary variables may be introduced into symbol_table.
394
+ // / \param function_identifier: Name of the function containing \p target.
379
395
// / \param target: The instruction to work on.
380
396
// / \param goto_program: The function body containing the instruction.
381
397
// / \param symbol_table: The symbol table to add symbols to.
382
398
// / \param message_handler: a message handler
383
399
void remove_java_new (
400
+ const irep_idt &function_identifier,
384
401
goto_programt::targett target,
385
402
goto_programt &goto_program,
386
403
symbol_table_baset &symbol_table,
387
404
message_handlert &message_handler)
388
405
{
389
406
remove_java_newt rem (symbol_table, message_handler);
390
- rem.lower_java_new (goto_program, target);
407
+ rem.lower_java_new (function_identifier, goto_program, target);
391
408
}
392
409
393
410
// / Replace every java_new or java_new_array by a malloc side-effect
394
411
// / and zero initialization.
395
412
// / \remarks Extra auxiliary variables may be introduced into symbol_table.
413
+ // / \param function_identifier: Name of the function \p function.
396
414
// / \param function: The function to work on.
397
415
// / \param symbol_table: The symbol table to add symbols to.
398
416
// / \param message_handler: a message handler
399
417
void remove_java_new (
418
+ const irep_idt &function_identifier,
400
419
goto_functionst::goto_functiont &function,
401
420
symbol_table_baset &symbol_table,
402
421
message_handlert &message_handler)
403
422
{
404
423
remove_java_newt rem (symbol_table, message_handler);
405
- rem.lower_java_new (function.body );
424
+ rem.lower_java_new (function_identifier, function.body );
406
425
}
407
426
408
427
// / Replace every java_new or java_new_array by a malloc side-effect
@@ -419,7 +438,7 @@ void remove_java_new(
419
438
remove_java_newt rem (symbol_table, message_handler);
420
439
bool changed = false ;
421
440
for (auto &f : goto_functions.function_map )
422
- changed = rem.lower_java_new (f.second .body ) || changed;
441
+ changed = rem.lower_java_new (f.first , f. second .body ) || changed;
423
442
if (changed)
424
443
goto_functions.compute_location_numbers ();
425
444
}
0 commit comments