cprover
remove_virtual_functionst Class Reference
+ Collaboration diagram for remove_virtual_functionst:

Public Member Functions

 remove_virtual_functionst (const symbol_table_baset &_symbol_table, const class_hierarchyt &_class_hierarchy)
 
void operator() (goto_functionst &goto_functions)
 Remove virtual function calls from all functions in the specified list and replace them with their most derived implementations. More...
 
bool remove_virtual_functions (goto_programt &goto_program)
 Remove all virtual function calls in a GOTO program and replace them with calls to their most derived implementations. More...
 
goto_programt::targett remove_virtual_function (goto_programt &goto_program, goto_programt::targett target, const dispatch_table_entriest &functions, virtual_dispatch_fallback_actiont fallback_action)
 Replace virtual function call with a static function call Achieved by substituting a virtual function with its most derived implementation. More...
 
void get_functions (const exprt &, dispatch_table_entriest &)
 Used to get dispatch entries to call for the given function. More...
 

Protected Types

typedef std::function< resolve_inherited_componentt::inherited_componentt(const irep_idt &, const irep_idt &)> function_call_resolvert
 

Protected Member Functions

goto_programt::targett remove_virtual_function (goto_programt &goto_program, goto_programt::targett target)
 Replace specified virtual function call with a static call to its most derived implementation. More...
 
void get_child_functions_rec (const irep_idt &, const symbol_exprt &, const irep_idt &, dispatch_table_entriest &, dispatch_table_entries_mapt &, const function_call_resolvert &) const
 Used by get_functions to track the most-derived parent that provides an override of a given function. More...
 
exprt get_method (const irep_idt &class_id, const irep_idt &component_name) const
 Returns symbol pointing to a specified method in a specified class. More...
 

Protected Attributes

const namespacet ns
 
const symbol_table_basetsymbol_table
 
const class_hierarchytclass_hierarchy
 

Detailed Description

Definition at line 22 of file remove_virtual_functions.cpp.

Member Typedef Documentation

◆ function_call_resolvert

Constructor & Destructor Documentation

◆ remove_virtual_functionst()

remove_virtual_functionst::remove_virtual_functionst ( const symbol_table_baset _symbol_table,
const class_hierarchyt _class_hierarchy 
)

Definition at line 66 of file remove_virtual_functions.cpp.

Member Function Documentation

◆ get_child_functions_rec()

void remove_virtual_functionst::get_child_functions_rec ( const irep_idt this_id,
const symbol_exprt last_method_defn,
const irep_idt component_name,
dispatch_table_entriest functions,
dispatch_table_entries_mapt entry_map,
const function_call_resolvert resolve_function_call 
) const
protected

Used by get_functions to track the most-derived parent that provides an override of a given function.

Parameters
this_idclass name
last_method_defnthe most-derived parent of this_id to define the requested function
component_namename of the function searched for
[out]functionsfunctions is assigned a list of {class name, function symbol} pairs indicating that if this is of the given class, then the call will target the given function. Thus if A <: B <: C and A and C provide overrides of f (but B does not), get_child_functions_rec("C", C.f, "f") -> [{"C", C.f}, {"B", C.f}, {"A", A.f}]
entry_mapmap of class identifiers to dispatch table entries
resolve_function_call`function to resolve abstract method call

Definition at line 338 of file remove_virtual_functions.cpp.

◆ get_functions()

void remove_virtual_functionst::get_functions ( const exprt function,
dispatch_table_entriest functions 
)

Used to get dispatch entries to call for the given function.

Parameters
functionfunction that should be called
[out]functionsis assigned a list of dispatch entries, i.e., pairs of class names and function symbol to call when encountering the class.

Definition at line 407 of file remove_virtual_functions.cpp.

◆ get_method()

exprt remove_virtual_functionst::get_method ( const irep_idt class_id,
const irep_idt component_name 
) const
protected

Returns symbol pointing to a specified method in a specified class.

Parameters
class_idClass identifier to look up
component_nameName of the function to look up
Returns
nil_exprt instance on error and a symbol_exprt pointing to the method on success

Definition at line 495 of file remove_virtual_functions.cpp.

◆ operator()()

void remove_virtual_functionst::operator() ( goto_functionst goto_functions)

Remove virtual function calls from all functions in the specified list and replace them with their most derived implementations.

Definition at line 547 of file remove_virtual_functions.cpp.

◆ remove_virtual_function() [1/2]

goto_programt::targett remove_virtual_functionst::remove_virtual_function ( goto_programt goto_program,
goto_programt::targett  target,
const dispatch_table_entriest functions,
virtual_dispatch_fallback_actiont  fallback_action 
)

Replace virtual function call with a static function call Achieved by substituting a virtual function with its most derived implementation.

If there's a type mismatch between implementation and the instance type or if fallback_action is set to ASSUME_FALSE, then function is substituted with a call to ASSUME(false)

Parameters
goto_program[in/out]: GOTO program to modify
targetIterator to the GOTO instruction in the supplied GOTO program to be removed. Must point to a function call
functionsDispatch table - all possible implementations of this function sorted from the least to the most derived
fallback_action- ASSUME_FALSE to replace virtual function calls with ASSUME(false) or CALL_LAST_FUNCTION to replace them with the most derived matching call
Returns
Returns a pointer to the statement in the supplied GOTO program after replaced function call

Definition at line 144 of file remove_virtual_functions.cpp.

◆ remove_virtual_function() [2/2]

goto_programt::targett remove_virtual_functionst::remove_virtual_function ( goto_programt goto_program,
goto_programt::targett  target 
)
protected

Replace specified virtual function call with a static call to its most derived implementation.

Parameters
goto_program[in/out]: GOTO program to modify
targetiterator: to a function in the supplied GOTO program to replace. Must point to a virtual function call.
Returns
Returns a pointer to the statement in the supplied GOTO program after replaced function call

Definition at line 82 of file remove_virtual_functions.cpp.

◆ remove_virtual_functions()

bool remove_virtual_functionst::remove_virtual_functions ( goto_programt goto_program)

Remove all virtual function calls in a GOTO program and replace them with calls to their most derived implementations.

Returns true if at least one function has been replaced.

Definition at line 513 of file remove_virtual_functions.cpp.

Member Data Documentation

◆ class_hierarchy

const class_hierarchyt& remove_virtual_functionst::class_hierarchy
protected

Definition at line 45 of file remove_virtual_functions.cpp.

◆ ns

const namespacet remove_virtual_functionst::ns
protected

Definition at line 42 of file remove_virtual_functions.cpp.

◆ symbol_table

const symbol_table_baset& remove_virtual_functionst::symbol_table
protected

Definition at line 43 of file remove_virtual_functions.cpp.


The documentation for this class was generated from the following file: