Skip to content

Commit f97c169

Browse files
authored
Merge pull request #1132 from cesaro/feature/documentation
Documentation for goto_program_templatet and cfg_baset
2 parents b59d0c7 + 26e8fec commit f97c169

File tree

4 files changed

+202
-67
lines changed

4 files changed

+202
-67
lines changed

src/goto-programs/cfg.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,31 @@ struct cfg_base_nodet:public graph_nodet<empty_edget>, public T
3131
I PC;
3232
};
3333

34+
/// A multi-procedural control flow graph (CFG) whose nodes store references to
35+
/// instructions in a GOTO program.
36+
///
37+
/// An instance of cfg_baset<T> is a directed graph whose nodes inherit from a
38+
/// user-provided type T and store a pointer to an instruction of some
39+
/// goto program in the field `PC`. The field `PC` of every node points to the
40+
/// original GOTO instruction that gave rise to the node, and the field
41+
/// cfg_baset::entry_map maps every GOTO instruction to some CFG node.
42+
///
43+
/// The CFG is constructed on the operator() from either one goto_programt or
44+
/// multiple goto_programt objects (stored in a goto_functionst). The edges of
45+
/// the CFG are created on the method compute_edges(), and notably include:
46+
///
47+
/// - Edges from location A to B if both A and B belong to the same
48+
/// goto_programt and A can flow into B.
49+
/// - An edge from each FUNCTION_CALL instruction and the first instruction of
50+
/// the called function, when that function body is available and its body is
51+
/// non-empty.
52+
/// - For each FUNCTION_CALL instruction found, an edge between the exit point
53+
/// of the called function and the instruction immediately after the
54+
/// FUNCTION_CALL, when the function body is available and its body is
55+
/// non-empty.
56+
///
57+
/// Note that cfg_baset is the base class of many other subclasses and the
58+
/// specific edges constructed by operator() can be different in those.
3459
template<class T,
3560
typename P=const goto_programt,
3661
typename I=goto_programt::const_targett>

src/goto-programs/goto_program.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,13 @@ std::ostream &goto_programt::output_instruction(
3333
return output_instruction(ns, identifier, out, *it);
3434
}
3535

36-
/// Writes to out a two line string representation of the specific instruction.
37-
/// It is of the format: // {location} file {source file} line {line in source
38-
/// file} {representation of the instruction}
36+
/// Writes to \p out a two/three line string representation of a given
37+
/// \p instruction. The output is of the format:
38+
/// ```
39+
/// // {location} file {source file} line {line in source file}
40+
/// // Labels: {list-of-labels}
41+
/// {representation of the instruction}
42+
/// ```
3943
/// \param ns: the namespace to resolve the expressions in
4044
/// \param identifier: the identifier used to find a symbol to identify the
4145
/// source language

0 commit comments

Comments
 (0)