@@ -72,6 +72,13 @@ remove_virtual_functionst::remove_virtual_functionst(
72
72
{
73
73
}
74
74
75
+ // / Replace specified virtual function call with a static call to its
76
+ // / most derived implementation
77
+ // / \param goto_program [in/out]: GOTO program to modify
78
+ // / \param target iterator: to a function in the supplied GOTO program
79
+ // / to replace. Must point to a virtual function call.
80
+ // / \return Returns a pointer to the statement in the supplied GOTO
81
+ // / program after replaced function call
75
82
goto_programt::targett remove_virtual_functionst::remove_virtual_function (
76
83
goto_programt &goto_program,
77
84
goto_programt::targett target)
@@ -119,6 +126,21 @@ static void create_static_function_call(
119
126
call.arguments ()[0 ].make_typecast (need_type);
120
127
}
121
128
129
+ // / Replace virtual function call with a static function call
130
+ // / Achieved by substituting a virtual function with its most derived
131
+ // / implementation. If there's a type mismatch between implementation
132
+ // / and the instance type or if fallback_action is set to
133
+ // / ASSUME_FALSE, then function is substituted with a call to ASSUME(false)
134
+ // / \param goto_program [in/out]: GOTO program to modify
135
+ // / \param target: Iterator to the GOTO instruction in the supplied
136
+ // / GOTO program to be removed. Must point to a function call
137
+ // / \param functions: Dispatch table - all possible implementations of
138
+ // / this function sorted from the least to the most derived
139
+ // / \param fallback_action: - ASSUME_FALSE to replace virtual function
140
+ // / calls with ASSUME(false) or CALL_LAST_FUNCTION to replace them
141
+ // / with the most derived matching call
142
+ // / \return Returns a pointer to the statement in the supplied GOTO
143
+ // / program after replaced function call
122
144
goto_programt::targett remove_virtual_functionst::remove_virtual_function (
123
145
goto_programt &goto_program,
124
146
goto_programt::targett target,
@@ -223,9 +245,9 @@ goto_programt::targett remove_virtual_functionst::remove_virtual_function(
223
245
// No definition for this type; shouldn't be possible...
224
246
t1->make_assertion (false_exprt ());
225
247
t1->source_location .set_comment (
226
- ( " cannot find calls for " +
227
- id2string (code.function ().get (ID_identifier)) + " dispatching " +
228
- id2string (fun.class_id ) ));
248
+ " cannot find calls for " +
249
+ id2string (code.function ().get (ID_identifier)) + " dispatching " +
250
+ id2string (fun.class_id ));
229
251
}
230
252
insertit.first ->second =t1;
231
253
// goto final
@@ -465,6 +487,11 @@ void remove_virtual_functionst::get_functions(
465
487
});
466
488
}
467
489
490
+ // / Returns symbol pointing to a specified method in a specified class
491
+ // / \param class_id: Class identifier to look up
492
+ // / \param component_name: Name of the function to look up
493
+ // / \return nil_exprt instance on error and a symbol_exprt pointing to
494
+ // / the method on success
468
495
exprt remove_virtual_functionst::get_method (
469
496
const irep_idt &class_id,
470
497
const irep_idt &component_name) const
@@ -480,6 +507,9 @@ exprt remove_virtual_functionst::get_method(
480
507
return symbol->symbol_expr ();
481
508
}
482
509
510
+ // / Remove all virtual function calls in a GOTO program and replace
511
+ // / them with calls to their most derived implementations. Returns
512
+ // / true if at least one function has been replaced.
483
513
bool remove_virtual_functionst::remove_virtual_functions (
484
514
goto_programt &goto_program)
485
515
{
@@ -512,6 +542,8 @@ bool remove_virtual_functionst::remove_virtual_functions(
512
542
return did_something;
513
543
}
514
544
545
+ // / Remove virtual function calls from all functions in the specified
546
+ // / list and replace them with their most derived implementations
515
547
void remove_virtual_functionst::operator ()(goto_functionst &functions)
516
548
{
517
549
bool did_something=false ;
@@ -531,6 +563,8 @@ void remove_virtual_functionst::operator()(goto_functionst &functions)
531
563
functions.compute_location_numbers ();
532
564
}
533
565
566
+ // / Remove virtual function calls from all functions in the specified
567
+ // / list and replace them with their most derived implementations
534
568
void remove_virtual_functions (
535
569
const symbol_table_baset &symbol_table,
536
570
goto_functionst &goto_functions)
@@ -541,12 +575,14 @@ void remove_virtual_functions(
541
575
rvf (goto_functions);
542
576
}
543
577
578
+ // / Remove virtual function calls from the specified model
544
579
void remove_virtual_functions (goto_modelt &goto_model)
545
580
{
546
581
remove_virtual_functions (
547
582
goto_model.symbol_table , goto_model.goto_functions );
548
583
}
549
584
585
+ // / Remove virtual function calls from the specified model function
550
586
void remove_virtual_functions (goto_model_functiont &function)
551
587
{
552
588
class_hierarchyt class_hierarchy;
@@ -555,6 +591,22 @@ void remove_virtual_functions(goto_model_functiont &function)
555
591
rvf.remove_virtual_functions (function.get_goto_function ().body );
556
592
}
557
593
594
+ // / Replace virtual function call with a static function call
595
+ // / Achieved by substituting a virtual function with its most derived
596
+ // / implementation. If there's a type mismatch between implementation
597
+ // / and the instance type or if fallback_action is set to
598
+ // / ASSUME_FALSE, then function is substituted with a call to ASSUME(false)
599
+ // / \param symbol_table: Symbol table
600
+ // / \param goto_program [in/out]: GOTO program to modify
601
+ // / \param instruction: Iterator to the GOTO instruction in the supplied
602
+ // / GOTO program to be removed. Must point to a function call
603
+ // / \param dispatch_table: Dispatch table - all possible implementations of
604
+ // / this function sorted from the least to the most derived
605
+ // / \param fallback_action: - ASSUME_FALSE to replace virtual function
606
+ // / calls with ASSUME(false) or CALL_LAST_FUNCTION to replace them
607
+ // / with the most derived matching call
608
+ // / \return Returns a pointer to the statement in the supplied GOTO
609
+ // / program after replaced function call
558
610
goto_programt::targett remove_virtual_function (
559
611
symbol_tablet &symbol_table,
560
612
goto_programt &goto_program,
0 commit comments