Skip to content

Commit c043179

Browse files
Applied doxygen style to all new comments
1 parent 3ab10aa commit c043179

19 files changed

+202
-469
lines changed

src/analyses/call_graph.cpp

+48-135
Original file line numberDiff line numberDiff line change
@@ -122,40 +122,21 @@ void call_grapht::output_xml(std::ostream &out) const
122122
}
123123
}
124124

125-
/*******************************************************************\
126-
127-
Function: call_grapht::out_edges
128-
129-
Inputs: `caller`: node to search for
130-
131-
Outputs: Returns list of edges whose first component is `caller`.
132-
133-
Purpose:
134-
135-
\*******************************************************************/
136-
125+
/// \par parameters: `caller`: node to search for
126+
/// \return Returns list of edges whose first component is `caller`.
137127
call_grapht::call_edges_ranget
138128
call_grapht::out_edges(const irep_idt &caller) const
139129
{
140130
return graph.equal_range(caller);
141131
}
142132

143-
/*******************************************************************\
144-
145-
Function: inverted_partial_topological_order
146-
147-
Inputs: `call_graph`: Call graph
148-
`start_function`: start node, must occur in call graph
149-
`processed_functions`: set of functions already seen
150-
151-
Outputs: `output`: inverted topological sort of the graph reachable
152-
from start node (i.e. leaves first, root last)
153-
`processed_functions`: set of functions already seen
154-
155-
Purpose: Get reverse-top-sorted subgraph
156-
157-
\*******************************************************************/
158-
133+
/// Get reverse-top-sorted subgraph
134+
/// \par parameters: `call_graph`: Call graph
135+
/// `start_function`: start node, must occur in call graph
136+
/// `processed_functions`: set of functions already seen
137+
/// \return `output`: inverted topological sort of the graph reachable from
138+
/// start node (i.e. leaves first, root last) `processed_functions`: set of
139+
/// functions already seen
159140
void inverted_partial_topological_order(
160141
const call_grapht &call_graph,
161142
const irep_idt &start_function,
@@ -176,22 +157,12 @@ void inverted_partial_topological_order(
176157
output.push_back(start_function);
177158
}
178159

179-
/*******************************************************************\
180-
181-
Function: get_inverted_topological_order
182-
183-
Inputs: `call_graph`: Call graph
184-
`functions`: map containing all functions of interest;
185-
only function names are used to index into call graph;
186-
function bodies are ignored.
187-
188-
Outputs: `output`: inverted topological sort of the graph reachable
189-
from start node (i.e. leaves first, root last)
190-
191-
Purpose: Get reverse-top-sorted call graph
192-
193-
\*******************************************************************/
194-
160+
/// Get reverse-top-sorted call graph
161+
/// \par parameters: `call_graph`: Call graph
162+
/// `functions`: map containing all functions of interest; only function names
163+
/// are used to index into call graph; function bodies are ignored.
164+
/// \return `output`: inverted topological sort of the graph reachable from
165+
/// start node (i.e. leaves first, root last)
195166
void get_inverted_topological_order(
196167
const call_grapht& call_graph,
197168
const goto_functionst& functions,
@@ -206,21 +177,11 @@ void get_inverted_topological_order(
206177
output);
207178
}
208179

209-
/*******************************************************************\
210-
211-
Function: exists_direct_call
212-
213-
Inputs: `call_graph`: Call graph
214-
`caller`: Caller
215-
`callee`: Potential callee
216-
217-
Outputs: Returns true if call graph says caller calls callee.
218-
219-
Purpose: See output
220-
221-
\*******************************************************************/
222-
223-
180+
/// See output
181+
/// \par parameters: `call_graph`: Call graph
182+
/// `caller`: Caller
183+
/// `callee`: Potential callee
184+
/// \return Returns true if call graph says caller calls callee.
224185
bool exists_direct_call(
225186
const call_grapht &call_graph,
226187
const irep_idt &caller,
@@ -234,24 +195,14 @@ bool exists_direct_call(
234195
return false;
235196
}
236197

237-
/*******************************************************************\
238-
239-
Function: exists_direct_or_indirect_call
240-
241-
Inputs: `call_graph`: Call graph
242-
`caller`: Caller
243-
`callee`: Potential callee
244-
`ignored_functions`: Functions to exclude from call graph
245-
for the purposes of finding a path
246-
247-
Outputs: Returns true if call graph says caller can reach callee
248-
via any intermediate sequence of callees not occurring
249-
in ignored_functions
250-
251-
Purpose: See output
252-
253-
\*******************************************************************/
254-
198+
/// See output
199+
/// \par parameters: `call_graph`: Call graph
200+
/// `caller`: Caller
201+
/// `callee`: Potential callee
202+
/// `ignored_functions`: Functions to exclude from call graph for the purposes
203+
/// of finding a path
204+
/// \return Returns true if call graph says caller can reach callee via any
205+
/// intermediate sequence of callees not occurring in ignored_functions
255206
bool exists_direct_or_indirect_call(
256207
const call_grapht &call_graph,
257208
const irep_idt &caller,
@@ -275,21 +226,12 @@ bool exists_direct_or_indirect_call(
275226
return false;
276227
}
277228

278-
/*******************************************************************\
279-
280-
Function: exists_direct_or_indirect_call
281-
282-
Inputs: `call_graph`: Call graph
283-
`caller`: Caller
284-
`callee`: Potential callee
285-
286-
Outputs: Returns true if call graph says caller can reach callee
287-
via any intermediate sequence of callees
288-
289-
Purpose: See output
290-
291-
\*******************************************************************/
292-
229+
/// See output
230+
/// \par parameters: `call_graph`: Call graph
231+
/// `caller`: Caller
232+
/// `callee`: Potential callee
233+
/// \return Returns true if call graph says caller can reach callee via any
234+
/// intermediate sequence of callees
293235
bool exists_direct_or_indirect_call(
294236
const call_grapht &call_graph,
295237
const irep_idt &caller,
@@ -299,19 +241,10 @@ bool exists_direct_or_indirect_call(
299241
return exists_direct_or_indirect_call(call_graph, caller, callee, ignored);
300242
}
301243

302-
/*******************************************************************\
303-
304-
Function: computed_inverted_call_graph
305-
306-
Inputs: `original_call_graph`: call graph
307-
308-
Outputs: `output_inverted_call_graph`: input call graph with caller->
309-
callee edges reversed.
310-
311-
Purpose: See output
312-
313-
\*******************************************************************/
314-
244+
/// See output
245+
/// \par parameters: `original_call_graph`: call graph
246+
/// \return `output_inverted_call_graph`: input call graph with caller-> callee
247+
/// edges reversed.
315248
void compute_inverted_call_graph(
316249
const call_grapht &original_call_graph,
317250
call_grapht &output_inverted_call_graph)
@@ -324,23 +257,12 @@ void compute_inverted_call_graph(
324257
{elem.first, elem.second}));
325258
}
326259

327-
/*******************************************************************\
328-
329-
Function: find_leaves_below_function
330-
331-
Inputs: `call_graph`: call graph
332-
`function`: start node
333-
`to_avoid`: functions already visited
334-
335-
Outputs: `output`: set of leaves reachable from 'function'
336-
`to_avoid`: functions already visited (with 'function'
337-
added)
338-
339-
Purpose: See output
340-
341-
\*******************************************************************/
342-
343-
260+
/// See output
261+
/// \par parameters: `call_graph`: call graph
262+
/// `function`: start node
263+
/// `to_avoid`: functions already visited
264+
/// \return `output`: set of leaves reachable from 'function' `to_avoid`:
265+
/// functions already visited (with 'function' added)
344266
void find_leaves_below_function(
345267
const call_grapht &call_graph,
346268
const irep_idt &function,
@@ -361,19 +283,10 @@ void find_leaves_below_function(
361283
}
362284
}
363285

364-
/*******************************************************************\
365-
366-
Function: find_leaves_below_function
367-
368-
Inputs: `call_graph`: call graph
369-
`function`: start node
370-
371-
Outputs: `output`: set of leaves reachable from 'function'
372-
373-
Purpose: See output
374-
375-
\*******************************************************************/
376-
286+
/// See output
287+
/// \par parameters: `call_graph`: call graph
288+
/// `function`: start node
289+
/// \return `output`: set of leaves reachable from 'function'
377290
void find_leaves_below_function(
378291
const call_grapht &call_graph,
379292
const irep_idt &function,

src/analyses/call_graph.h

+32-42
Original file line numberDiff line numberDiff line change
@@ -90,48 +90,38 @@ class call_grapht
9090
map_from_edges_to_call_locationst map_from_edges_to_call_locations;
9191
};
9292

93-
/*******************************************************************\
94-
95-
Function: inverted_partial_topological_order
96-
97-
Inputs: See purpose
98-
99-
Outputs: See purpose
100-
101-
Purpose:
102-
103-
For DAG call graphs it computes an inverted topological order of all
104-
functions in the call graph. Otherwise, it computes only a partial
105-
inverted topological order (all loops are broken at some (randomly)
106-
chosen edge to get a DAG). The topolocical order is stored in the
107-
'output' vector.
108-
109-
Since the algorithm is implemented using DFS, those 'breaks' are
110-
implemented naturally by a set of processed (vidited) functions.
111-
112-
The function actually performs only one DFS from a passed 'start_function'.
113-
So, to get whole inverted (partial) topological order of all functions in
114-
the call graph, this function has to be called for all functions in the
115-
program.
116-
117-
NOTE: The order is 'inverted'. It means that
118-
119-
Typical usage:
120-
// Let's assume there is 'goto_modelt GM' and 'call_grapht CG'
121-
std::vector<irep_idt> result; // Here we will store the topological order.
122-
{
123-
std::unordered_set<irep_idt, dstring_hash> processed;
124-
for (const auto &elem : GM.goto_functions.function_map)
125-
partial_topological_order(CG, elem.first, processed, result);
126-
// Now we reverse the result to get the classic (partial)
127-
// topological order instead of the inverted one.
128-
std::reverse(result.begin(), result.end());
129-
}
130-
std::cout << "A (partial) topological order of my call graph is: ";
131-
for (const irep_idt &fn_name : result)
132-
std::cout << fn_name << ", ";
133-
134-
\*******************************************************************/
93+
/// For DAG call graphs it computes an inverted topological order of all
94+
/// functions in the call graph. Otherwise, it computes only a partial
95+
/// inverted topological order (all loops are broken at some (randomly)
96+
/// chosen edge to get a DAG). The topolocical order is stored in the
97+
/// 'output' vector.
98+
///
99+
/// Since the algorithm is implemented using DFS, those 'breaks' are
100+
/// implemented naturally by a set of processed (vidited) functions.
101+
///
102+
/// The function actually performs only one DFS from a passed 'start_function'.
103+
/// So, to get whole inverted (partial) topological order of all functions in
104+
/// the call graph, this function has to be called for all functions in the
105+
/// program.
106+
///
107+
/// NOTE: The order is 'inverted'. It means that
108+
///
109+
/// Typical usage:
110+
/// // Let's assume there is 'goto_modelt GM' and 'call_grapht CG'
111+
/// std::vector<irep_idt> result; // Here we will store the topological order.
112+
/// {
113+
/// std::unordered_set<irep_idt, dstring_hash> processed;
114+
/// for (const auto &elem : GM.goto_functions.function_map)
115+
/// partial_topological_order(CG, elem.first, processed, result);
116+
/// // Now we reverse the result to get the classic (partial)
117+
/// // topological order instead of the inverted one.
118+
/// std::reverse(result.begin(), result.end());
119+
/// }
120+
/// std::cout << "A (partial) topological order of my call graph is: ";
121+
/// for (const irep_idt &fn_name : result)
122+
/// std::cout << fn_name << ", ";
123+
/// \par parameters: See purpose
124+
/// \return See purpose
135125
void inverted_partial_topological_order(
136126
const call_grapht &call_graph,
137127
const irep_idt &start_function,

0 commit comments

Comments
 (0)