CBMC
goto_functions.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Goto Programs with Functions
4 
5 Author: Daniel Kroening
6 
7 Date: June 2003
8 
9 \*******************************************************************/
10 
13 
14 #ifndef CPROVER_GOTO_PROGRAMS_GOTO_FUNCTIONS_H
15 #define CPROVER_GOTO_PROGRAMS_GOTO_FUNCTIONS_H
16 
17 #include "goto_function.h"
18 
19 #include <util/cprover_prefix.h>
20 
21 #include <map>
22 
25 {
26 public:
28  typedef std::map<irep_idt, goto_functiont> function_mapt;
30 
31 private:
38 
39 public:
42  {
43  }
44 
45  // Copying is unavailable as base class copy is deleted
46  // MSVC is unable to automatically determine this
47  goto_functionst(const goto_functionst &)=delete;
48  goto_functionst &operator=(const goto_functionst &)=delete;
49 
50  // Move operations need to be explicitly enabled as they are deleted with the
51  // copy operations
52  // default for move operations isn't available on Windows yet, so define
53  // explicitly (see https://msdn.microsoft.com/en-us/library/hh567368.aspx
54  // under "Defaulted and Deleted Functions")
55 
57  function_map(std::move(other.function_map)),
59  {
60  }
61 
63  {
64  function_map=std::move(other.function_map);
65  unused_location_number=other.unused_location_number;
66  return *this;
67  }
68 
70  void unload(const irep_idt &name) { function_map.erase(name); }
71 
72  void clear()
73  {
74  function_map.clear();
75  }
76 
79  void compute_loop_numbers();
82 
83  void update()
84  {
89  }
90 
92  static inline irep_idt entry_point()
93  {
94  // do not confuse with C's "int main()"
95  return CPROVER_PREFIX "_start";
96  }
97 
98  void swap(goto_functionst &other)
99  {
100  function_map.swap(other.function_map);
101  }
102 
103  void copy_from(const goto_functionst &other)
104  {
105  for(const auto &fun : other.function_map)
106  function_map[fun.first].copy_from(fun.second);
107  }
108 
109  std::vector<function_mapt::const_iterator> sorted() const;
110  std::vector<function_mapt::iterator> sorted();
111 
116  void validate(const namespacet &, validation_modet) const;
117 };
118 
119 #endif // CPROVER_GOTO_PROGRAMS_GOTO_FUNCTIONS_H
dstringt
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:36
goto_functionst::validate
void validate(const namespacet &, validation_modet) const
Check that the goto functions are well-formed.
Definition: goto_functions.cpp:103
goto_functionst::sorted
std::vector< function_mapt::const_iterator > sorted() const
returns a vector of the iterators in alphabetical order
Definition: goto_functions.cpp:64
goto_functionst::compute_location_numbers
void compute_location_numbers()
Definition: goto_functions.cpp:20
goto_functionst::function_map
function_mapt function_map
Definition: goto_functions.h:29
namespacet
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition: namespace.h:90
goto_functionst::clear
void clear()
Definition: goto_functions.h:72
goto_functionst::compute_target_numbers
void compute_target_numbers()
Definition: goto_functions.cpp:46
goto_functionst::function_mapt
std::map< irep_idt, goto_functiont > function_mapt
Definition: goto_functions.h:28
goto_functionst::goto_functionst
goto_functionst(goto_functionst &&other)
Definition: goto_functions.h:56
validation_modet
validation_modet
Definition: validation_mode.h:12
goto_functiont
A goto function, consisting of function body (see body) and parameter identifiers (see parameter_iden...
Definition: goto_function.h:23
goto_functionst::compute_loop_numbers
void compute_loop_numbers()
Definition: goto_functions.cpp:54
cprover_prefix.h
goto_functionst::operator=
goto_functionst & operator=(const goto_functionst &)=delete
goto_functionst::unload
void unload(const irep_idt &name)
Remove function from the function map.
Definition: goto_functions.h:70
goto_functionst::goto_functiont
::goto_functiont goto_functiont
Definition: goto_functions.h:27
goto_functionst
A collection of goto functions.
Definition: goto_functions.h:24
goto_functionst::goto_functionst
goto_functionst()
Definition: goto_functions.h:40
goto_functionst::copy_from
void copy_from(const goto_functionst &other)
Definition: goto_functions.h:103
CPROVER_PREFIX
#define CPROVER_PREFIX
Definition: cprover_prefix.h:14
goto_functionst::update
void update()
Definition: goto_functions.h:83
goto_functionst::swap
void swap(goto_functionst &other)
Definition: goto_functions.h:98
goto_programt
A generic container class for the GOTO intermediate representation of one function.
Definition: goto_program.h:72
goto_functionst::entry_point
static irep_idt entry_point()
Get the identifier of the entry point to a goto model.
Definition: goto_functions.h:92
goto_function.h
goto_functionst::compute_incoming_edges
void compute_incoming_edges()
Definition: goto_functions.cpp:38
goto_functionst::operator=
goto_functionst & operator=(goto_functionst &&other)
Definition: goto_functions.h:62
goto_functionst::unused_location_number
unsigned unused_location_number
A location number such that numbers in the interval [unused_location_number, MAX_UINT] are all unused...
Definition: goto_functions.h:37