cprover
goto_functions.cpp
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 #include "goto_functions.h"
15 
16 #include <algorithm>
17 
19 {
21  for(auto &func : function_map)
22  {
23  // Side-effect: bumps unused_location_number.
24  func.second.body.compute_location_numbers(unused_location_number);
25  }
26 }
27 
29  goto_programt &program)
30 {
31  // Renumber just this single function. Use fresh numbers in case it has
32  // grown since it was last numbered.
34 }
35 
37 {
38  for(auto &func : function_map)
39  {
40  func.second.body.compute_incoming_edges();
41  }
42 }
43 
45 {
46  for(auto &func : function_map)
47  {
48  func.second.body.compute_target_numbers();
49  }
50 }
51 
53 {
54  for(auto &func : function_map)
55  {
56  func.second.body.compute_loop_numbers();
57  }
58 }
59 
61 std::vector<goto_functionst::function_mapt::const_iterator>
63 {
64  std::vector<function_mapt::const_iterator> result;
65 
66  result.reserve(function_map.size());
67 
68  for(auto it = function_map.begin(); it != function_map.end(); it++)
69  result.push_back(it);
70 
71  std::sort(
72  result.begin(),
73  result.end(),
74  [](function_mapt::const_iterator a, function_mapt::const_iterator b) {
75  return id2string(a->first) < id2string(b->first);
76  });
77 
78  return result;
79 }
80 
82 std::vector<goto_functionst::function_mapt::iterator> goto_functionst::sorted()
83 {
84  std::vector<function_mapt::iterator> result;
85 
86  result.reserve(function_map.size());
87 
88  for(auto it = function_map.begin(); it != function_map.end(); it++)
89  result.push_back(it);
90 
91  std::sort(
92  result.begin(),
93  result.end(),
94  [](function_mapt::iterator a, function_mapt::iterator b) {
95  return id2string(a->first) < id2string(b->first);
96  });
97 
98  return result;
99 }
goto_functionst::compute_location_numbers
void compute_location_numbers()
Definition: goto_functions.cpp:18
goto_functionst::function_map
function_mapt function_map
Definition: goto_functions.h:27
goto_functionst::compute_target_numbers
void compute_target_numbers()
Definition: goto_functions.cpp:44
id2string
const std::string & id2string(const irep_idt &d)
Definition: irep.h:44
goto_programt::compute_location_numbers
void compute_location_numbers(unsigned &nr)
Compute location numbers.
Definition: goto_program.h:578
goto_functionst::compute_loop_numbers
void compute_loop_numbers()
Definition: goto_functions.cpp:52
goto_functions.h
goto_programt
A generic container class for the GOTO intermediate representation of one function.
Definition: goto_program.h:72
goto_functionst::sorted
std::vector< function_mapt::const_iterator > sorted() const
returns a vector of the iterators in alphabetical order
Definition: goto_functions.cpp:62
goto_functionst::compute_incoming_edges
void compute_incoming_edges()
Definition: goto_functions.cpp:36
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:35