@@ -124,8 +124,12 @@ digraph G {
124
124
}
125
125
\enddot
126
126
127
- At this stage, CBMC constructs a goto-program from a symbol table. It
128
- does not use the parse tree or the source file at all for this step. This
127
+ At this stage, CBMC constructs a goto-program from a symbol table.
128
+ Each symbol in the symbol table with function type (that is, the symbol's ` type `
129
+ field contains a \ref code_typet) will be converted to a corresponding GOTO
130
+ program.
131
+
132
+ It does not use the parse tree or the source file at all for this step. This
129
133
may seem surprising, because the symbols are stored in a hash table and
130
134
therefore have no intrinsic order; nevertheless, every \ref symbolt is
131
135
associated with a \ref source_locationt, allowing CBMC to figure out the
@@ -282,18 +286,6 @@ This is not the final form of the goto-functions, since the lists of
282
286
instructions will be 'normalized' in the next step (Instrumentation),
283
287
which removes some instructions and adds targets to others.
284
288
285
- Note that goto_programt and goto_functionst are each template
286
- instantiations; they are currently the * only* specialization of
287
- goto_program_templatet and goto_functions_templatet, respectively. This
288
- means that the generated Doxygen documentation can be somewhat obtuse
289
- about the actual types of things, and is unable to generate links to the
290
- correct classes. Note that the
291
- \ref goto_programt::instructiont::code "code" member of a
292
- goto_programt's instruction has type \ref codet (its type in the
293
- goto_program_templatet documentation is given as "codeT", as this is the
294
- name of the template's type parameter); similarly, the type of a guard
295
- of an instruction is \ref guardt.
296
-
297
289
---
298
290
\section instrumentation Instrumentation
299
291
@@ -324,8 +316,15 @@ previous stage:
324
316
are littered with \ref code_skipt "skip" statements. The
325
317
instrumentation stage removes the majority of these.
326
318
327
- * Function pointers are removed. They are turned into switch statements
328
- (but see the next point; switch statements are further transformed).
319
+ * Variable lifespan implied by \ref code_declt instructions and lexical scopes
320
+ described by \ref code_blockt nodes is replaced by ` DECL ` and corresponding
321
+ ` DEAD ` instructions. There are therefore no lexical scopes in GOTO programs
322
+ (not even local variable death on function exit is enforced).
323
+
324
+ * Expressions with side-effects are explicitly ordered so that there is one
325
+ effect per instruction (apart from function call instructions, which can
326
+ still have many). For example, ` y = f() + x++ ` will have become something like
327
+ ` tmp1 = f(); y = tmp1 + x; x = x + 1; `
329
328
330
329
* Compound blocks are eliminated. There are several subclasses of
331
330
\ref codet that count as 'compound blocks;' therefore, later stages in
@@ -362,13 +361,7 @@ previous stage:
362
361
* \ref code_returnt "return statements" are transformed into
363
362
(unconditional) GOTOs whose target is the \ref END_FUNCTION
364
363
instruction. Each goto_programt should have precisely one such
365
- instruction. Note the presence of \ref code_deadt, which has a
366
- \ref code_deadt::symbol() "symbol()" member. Deads mark symbols that
367
- have just gone out of scope; typically, a GOTO that jumps to an
368
- END_FUNCTION instruction is preceded by a series of deads. Deads also
369
- follow sequences of instructions that were part of the body of a
370
- block (loop, conditional etc.) if there were symbols declared in that
371
- block.
364
+ instruction.
372
365
373
366
This stage concludes the * analysis-independent* program transformations.
374
367
0 commit comments