Skip to content

Commit abdfc00

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 06d8bea commit abdfc00

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/goto-programs/goto_program.h

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,19 @@ 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+
/// If there are multiple targets, pick one non-deterministically.
110111
/// - RETURN:
111112
/// Set the value returned by `code` (which shall be either nil or an
112113
/// instance of code_returnt) and then jump to the end of the function.
114+
/// Many analysis tools remove these instructions before they start.
113115
/// - DECL:
114116
/// Introduces a symbol denoted by the field `code` (an instance of
115117
/// code_declt), the life-time of which is bounded by a corresponding DEAD
116-
/// instruction.
118+
/// instruction. Symbols must be DECL'd before they are used.
119+
/// - DEAD:
120+
/// Ends the life of the symbol denoted by the field `code`.
121+
/// After a DEAD instruction the symbol must be DECL'd again before use.
117122
/// - FUNCTION_CALL:
118123
/// Invoke the function denoted by field `code` (an instance of
119124
/// code_function_callt).
@@ -124,7 +129,8 @@ class goto_programt
124129
/// Execute the `code` (an instance of codet of kind ID_fence, ID_printf,
125130
/// ID_array_copy, ID_array_set, ID_input, ID_output, ...).
126131
/// - ASSUME:
127-
/// Wait for `guard` to evaluate to true.
132+
/// This thread of execution waits for `guard` to evaluate to true.
133+
/// Assume does not "retro-actively" affect the thread or any ASSERTs.
128134
/// - ASSERT:
129135
/// Using ASSERT instructions is the one and only way to express
130136
/// properties to be verified. Execution paths abort if `guard` evaluates
@@ -134,17 +140,21 @@ class goto_programt
134140
/// - ATOMIC_BEGIN, ATOMIC_END:
135141
/// When a thread executes ATOMIC_BEGIN, no thread other will be able to
136142
/// execute any instruction until the same thread executes ATOMIC_END.
143+
/// Concurrency is not support by all analysis tools.
137144
/// - END_FUNCTION:
138-
/// Can only occur as the last instruction of the list.
145+
/// Must occur as the last instruction of the list and nowhere else.
139146
/// - START_THREAD:
140147
/// Create a new thread and run the code of this function starting from
141148
/// targets[0]. Quite often the instruction pointed by targets[0] will be
142149
/// just a FUNCTION_CALL, followed by an END_THREAD.
150+
/// Concurrency is not support by all analysis tools.
143151
/// - END_THREAD:
144152
/// Terminate the calling thread.
153+
/// Concurrency is not support by all analysis tools.
145154
/// - THROW:
146155
/// throw `exception1`, ..., `exceptionN`
147156
/// where the list of exceptions is extracted from the `code` field
157+
/// Many analysis tools remove these instructions before they start.
148158
/// - CATCH, when code.find(ID_exception_list) is non-empty:
149159
/// Establishes that from here to the next occurrence of CATCH with an
150160
/// empty list (see below) if
@@ -156,6 +166,7 @@ class goto_programt
156166
/// - CATCH, when empty code.find(ID_exception_list) is empty:
157167
/// clears all the catch clauses established as per the above in this
158168
/// function?
169+
/// Many analysis tools remove these instructions before they start.
159170
class instructiont final
160171
{
161172
public:

0 commit comments

Comments
 (0)