cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
remove_virtual_functions.h
Go to the documentation of this file.
1
/*******************************************************************\
2
3
Module: Remove Virtual Function (Method) Calls
4
5
Author: Daniel Kroening
6
7
Date: April 2016
8
9
\*******************************************************************/
10
14
15
#ifndef CPROVER_GOTO_PROGRAMS_REMOVE_VIRTUAL_FUNCTIONS_H
16
#define CPROVER_GOTO_PROGRAMS_REMOVE_VIRTUAL_FUNCTIONS_H
17
18
#include <
util/std_expr.h
>
19
20
#include "
goto_program.h
"
21
22
#include <map>
23
24
class
class_hierarchyt
;
25
class
goto_functionst
;
26
class
goto_model_functiont
;
27
class
goto_modelt
;
28
class
symbol_table_baset
;
29
30
// For all of the following the class-hierarchy and non-class-hierarchy
31
// overloads are equivalent, but the class-hierarchy-taking one saves time if
32
// you already have a class-hierarchy object available.
33
34
void
remove_virtual_functions
(
35
goto_modelt
&goto_model);
36
37
void
remove_virtual_functions
(
38
goto_modelt
&goto_model,
39
const
class_hierarchyt
&class_hierarchy);
40
41
void
remove_virtual_functions
(
42
symbol_table_baset
&symbol_table,
43
goto_functionst
&goto_functions);
44
45
void
remove_virtual_functions
(
46
symbol_table_baset
&symbol_table,
47
goto_functionst
&goto_functions,
48
const
class_hierarchyt
&class_hierarchy);
49
50
void
remove_virtual_functions
(
goto_model_functiont
&function);
51
52
void
remove_virtual_functions
(
53
goto_model_functiont
&function,
54
const
class_hierarchyt
&class_hierarchy);
55
58
enum class
virtual_dispatch_fallback_actiont
59
{
62
CALL_LAST_FUNCTION
,
65
ASSUME_FALSE
66
};
67
68
class
dispatch_table_entryt
69
{
70
public
:
71
explicit
dispatch_table_entryt
(
const
irep_idt
&_class_id)
72
:
symbol_expr
(),
class_id
(_class_id)
73
{
74
}
75
76
#if defined(__GNUC__) && __GNUC__ < 7
77
// GCC up to version 6.5 warns about irept::data being used uninitialized upon
78
// the move triggered by std::sort; using operator= works around this
79
dispatch_table_entryt
(
dispatch_table_entryt
&&other)
80
{
81
symbol_expr
= other.symbol_expr;
82
class_id
= other.class_id;
83
}
84
85
dispatch_table_entryt
&operator=(
const
dispatch_table_entryt
&other)
86
{
87
symbol_expr
= other.
symbol_expr
;
88
class_id
= other.
class_id
;
89
return
*
this
;
90
}
91
92
dispatch_table_entryt
(
const
dispatch_table_entryt
&other)
93
:
symbol_expr
(other.
symbol_expr
),
class_id
(other.
class_id
)
94
{
95
}
96
#endif
97
98
std::optional<symbol_exprt>
symbol_expr
;
99
irep_idt
class_id
;
100
};
101
102
typedef
std::vector<dispatch_table_entryt>
dispatch_table_entriest
;
103
typedef
std::map<irep_idt, dispatch_table_entryt>
dispatch_table_entries_mapt
;
104
105
goto_programt::targett
remove_virtual_function
(
106
goto_modelt
&goto_model,
107
const
irep_idt
&function_id,
108
goto_programt
&goto_program,
109
goto_programt::targett
instruction,
110
const
dispatch_table_entriest
&dispatch_table,
111
virtual_dispatch_fallback_actiont
fallback_action);
112
113
goto_programt::targett
remove_virtual_function
(
114
symbol_table_baset
&symbol_table,
115
const
irep_idt
&function_id,
116
goto_programt
&goto_program,
117
goto_programt::targett
instruction,
118
const
dispatch_table_entriest
&dispatch_table,
119
virtual_dispatch_fallback_actiont
fallback_action);
120
129
void
collect_virtual_function_callees
(
130
const
exprt
&function,
131
const
symbol_table_baset
&symbol_table,
132
const
class_hierarchyt
&class_hierarchy,
133
dispatch_table_entriest
&overridden_functions);
134
135
#endif
// CPROVER_GOTO_PROGRAMS_REMOVE_VIRTUAL_FUNCTIONS_H
class_hierarchyt
Non-graph-based representation of the class hierarchy.
Definition
class_hierarchy.h:41
dispatch_table_entryt
Definition
remove_virtual_functions.h:69
dispatch_table_entryt::dispatch_table_entryt
dispatch_table_entryt(const irep_idt &_class_id)
Definition
remove_virtual_functions.h:71
dispatch_table_entryt::symbol_expr
std::optional< symbol_exprt > symbol_expr
Definition
remove_virtual_functions.h:98
dispatch_table_entryt::class_id
irep_idt class_id
Definition
remove_virtual_functions.h:99
exprt
Base class for all expressions.
Definition
expr.h:57
goto_functionst
A collection of goto functions.
Definition
goto_functions.h:25
goto_model_functiont
Interface providing access to a single function in a GOTO model, plus its associated symbol table.
Definition
goto_model.h:190
goto_modelt
Definition
goto_model.h:27
goto_programt
A generic container class for the GOTO intermediate representation of one function.
Definition
goto_program.h:72
goto_programt::targett
instructionst::iterator targett
Definition
goto_program.h:613
symbol_table_baset
The symbol table base class interface.
Definition
symbol_table_base.h:23
goto_program.h
Concrete Goto Program.
remove_virtual_functions
void remove_virtual_functions(goto_modelt &goto_model)
Remove virtual function calls from the specified model.
Definition
remove_virtual_functions.cpp:744
dispatch_table_entries_mapt
std::map< irep_idt, dispatch_table_entryt > dispatch_table_entries_mapt
Definition
remove_virtual_functions.h:103
collect_virtual_function_callees
void collect_virtual_function_callees(const exprt &function, const symbol_table_baset &symbol_table, const class_hierarchyt &class_hierarchy, dispatch_table_entriest &overridden_functions)
Given a function expression representing a virtual method of a class, the function computes all overr...
Definition
remove_virtual_functions.cpp:848
virtual_dispatch_fallback_actiont
virtual_dispatch_fallback_actiont
Specifies remove_virtual_function's behaviour when the actual supplied parameter does not match any o...
Definition
remove_virtual_functions.h:59
virtual_dispatch_fallback_actiont::ASSUME_FALSE
@ ASSUME_FALSE
When no callee type matches, ASSUME false, thus preventing any complete trace from using this path.
Definition
remove_virtual_functions.h:65
virtual_dispatch_fallback_actiont::CALL_LAST_FUNCTION
@ CALL_LAST_FUNCTION
When no callee type matches, call the last passed function, which is expected to be some safe default...
Definition
remove_virtual_functions.h:62
dispatch_table_entriest
std::vector< dispatch_table_entryt > dispatch_table_entriest
Definition
remove_virtual_functions.h:102
remove_virtual_function
goto_programt::targett remove_virtual_function(goto_modelt &goto_model, const irep_idt &function_id, goto_programt &goto_program, goto_programt::targett instruction, const dispatch_table_entriest &dispatch_table, virtual_dispatch_fallback_actiont fallback_action)
Definition
remove_virtual_functions.cpp:831
std_expr.h
API to expression classes.
irep_idt
dstringt irep_idt
Definition
verification_result.h:16
goto-programs
remove_virtual_functions.h
Generated by
1.17.0