Skip to content

Commit a11add8

Browse files
author
martin
committed
Expand the documentation of the goto-program instructions.
This clarifies a few sources of mistakes and misconceptions as well as documenting some common practice.
1 parent a06503b commit a11add8

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/goto-programs/goto_program.h

+16-4
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,20 @@ class goto_programt
106106
/// respective fields in this class:
107107
///
108108
/// - GOTO:
109-
/// if `guard` then goto `targets`
109+
/// goto `targets` if and only if `guard` is true.
110+
/// More than one target is deprecated. Its semantics was a
111+
/// non-deterministic choice.
110112
/// - RETURN:
111113
/// Set the value returned by `code` (which shall be either nil or an
112114
/// instance of code_returnt) and then jump to the end of the function.
115+
/// Many analysis tools remove these instructions before they start.
113116
/// - DECL:
114117
/// Introduces a symbol denoted by the field `code` (an instance of
115118
/// code_declt), the life-time of which is bounded by a corresponding DEAD
116-
/// instruction.
119+
/// instruction. Non-static symbols must be DECL'd before they are used.
120+
/// - DEAD:
121+
/// Ends the life of the symbol denoted by the field `code`.
122+
/// After a DEAD instruction the symbol must be DECL'd again before use.
117123
/// - FUNCTION_CALL:
118124
/// Invoke the function denoted by field `code` (an instance of
119125
/// code_function_callt).
@@ -124,7 +130,8 @@ class goto_programt
124130
/// Execute the `code` (an instance of codet of kind ID_fence, ID_printf,
125131
/// ID_array_copy, ID_array_set, ID_input, ID_output, ...).
126132
/// - ASSUME:
127-
/// Wait for `guard` to evaluate to true.
133+
/// This thread of execution waits for `guard` to evaluate to true.
134+
/// Assume does not "retro-actively" affect the thread or any ASSERTs.
128135
/// - ASSERT:
129136
/// Using ASSERT instructions is the one and only way to express
130137
/// properties to be verified. Execution paths abort if `guard` evaluates
@@ -134,17 +141,21 @@ class goto_programt
134141
/// - ATOMIC_BEGIN, ATOMIC_END:
135142
/// When a thread executes ATOMIC_BEGIN, no thread other will be able to
136143
/// execute any instruction until the same thread executes ATOMIC_END.
144+
/// Concurrency is not supported by all analysis tools.
137145
/// - END_FUNCTION:
138-
/// Can only occur as the last instruction of the list.
146+
/// Must occur as the last instruction of the list and nowhere else.
139147
/// - START_THREAD:
140148
/// Create a new thread and run the code of this function starting from
141149
/// targets[0]. Quite often the instruction pointed by targets[0] will be
142150
/// just a FUNCTION_CALL, followed by an END_THREAD.
151+
/// Concurrency is not supported by all analysis tools.
143152
/// - END_THREAD:
144153
/// Terminate the calling thread.
154+
/// Concurrency is not supported by all analysis tools.
145155
/// - THROW:
146156
/// throw `exception1`, ..., `exceptionN`
147157
/// where the list of exceptions is extracted from the `code` field
158+
/// Many analysis tools remove these instructions before they start.
148159
/// - CATCH, when code.find(ID_exception_list) is non-empty:
149160
/// Establishes that from here to the next occurrence of CATCH with an
150161
/// empty list (see below) if
@@ -156,6 +167,7 @@ class goto_programt
156167
/// - CATCH, when empty code.find(ID_exception_list) is empty:
157168
/// clears all the catch clauses established as per the above in this
158169
/// function?
170+
/// Many analysis tools remove these instructions before they start.
159171
class instructiont final
160172
{
161173
public:

0 commit comments

Comments
 (0)