CBMC
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;
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 
35  goto_modelt &goto_model);
36 
38  goto_modelt &goto_model,
39  const class_hierarchyt &class_hierarchy);
40 
42  symbol_table_baset &symbol_table,
43  goto_functionst &goto_functions);
44 
46  symbol_table_baset &symbol_table,
47  goto_functionst &goto_functions,
48  const class_hierarchyt &class_hierarchy);
49 
51 
53  goto_model_functiont &function,
54  const class_hierarchyt &class_hierarchy);
55 
59 {
66 };
67 
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
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 
93  : symbol_expr(other.symbol_expr), class_id(other.class_id)
94  {
95  }
96 #endif
97 
98  std::optional<symbol_exprt> symbol_expr;
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 
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 
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 
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
Non-graph-based representation of the class hierarchy.
dispatch_table_entryt(const irep_idt &_class_id)
std::optional< symbol_exprt > symbol_expr
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:38
Base class for all expressions.
Definition: expr.h:56
A collection of goto functions.
Interface providing access to a single function in a GOTO model, plus its associated symbol table.
Definition: goto_model.h:190
A generic container class for the GOTO intermediate representation of one function.
Definition: goto_program.h:73
instructionst::iterator targett
Definition: goto_program.h:614
The symbol table base class interface.
Concrete Goto Program.
void remove_virtual_functions(goto_modelt &goto_model)
Remove virtual function calls from the specified model.
std::map< irep_idt, dispatch_table_entryt > dispatch_table_entries_mapt
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...
virtual_dispatch_fallback_actiont
Specifies remove_virtual_function's behaviour when the actual supplied parameter does not match any o...
@ ASSUME_FALSE
When no callee type matches, ASSUME false, thus preventing any complete trace from using this path.
@ CALL_LAST_FUNCTION
When no callee type matches, call the last passed function, which is expected to be some safe default...
std::vector< dispatch_table_entryt > dispatch_table_entriest
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)
API to expression classes.