@@ -170,6 +170,9 @@ class goto_programt
170
170
// / clears all the catch clauses established as per the above in this
171
171
// / function?
172
172
// / Many analysis tools remove these instructions before they start.
173
+ // / - INCOMPLETE GOTO:
174
+ // / goto for which the target is yet to be determined. The target set
175
+ // / shall be empty
173
176
class instructiont final
174
177
{
175
178
public:
@@ -421,15 +424,34 @@ class goto_programt
421
424
return t;
422
425
}
423
426
427
+ // / Get the id of the function that contains the instruction pointed-to by the
428
+ // / given instruction iterator.
429
+ // /
430
+ // / \param l: instruction iterator
431
+ // / \return id of the function that contains the pointed-to goto instruction
424
432
static const irep_idt get_function_id (
425
433
const_targett l)
426
434
{
435
+ // The field `function` of an instruction may not always contain the id of
436
+ // the function it is currently in, due to goto program modifications such
437
+ // as inlining. For example, if an instruction in a function `f` is inlined
438
+ // into a function `g`, the instruction may, depending on the arguments to
439
+ // the inliner, retain the original value of `f` in the function field.
440
+ // However, instructions of type END_FUNCTION are never inlined into other
441
+ // functions, hence they contain the id of the function they are in. Thus,
442
+ // this function takes the END_FUNCTION instruction of the goto program and
443
+ // returns the value of its function field.
444
+
427
445
while (!l->is_end_function ())
428
446
++l;
429
447
430
448
return l->function ;
431
449
}
432
450
451
+ // / Get the id of the function that contains the given goto program.
452
+ // /
453
+ // / \param p: the goto program
454
+ // / \return id of the function that contains the goto program
433
455
static const irep_idt get_function_id (
434
456
const goto_programt &p)
435
457
{
@@ -474,14 +496,16 @@ class goto_programt
474
496
instructions.splice (next, p.instructions );
475
497
}
476
498
477
- // / Insertion before the given target
499
+ // / Insertion before the instruction pointed-to by the given instruction
500
+ // / iterator `target`.
478
501
// / \return newly inserted location
479
502
targett insert_before (const_targett target)
480
503
{
481
504
return instructions.insert (target, instructiont ());
482
505
}
483
506
484
- // / Insertion after the given target
507
+ // / Insertion after the instruction pointed-to by the given instruction
508
+ // / iterator `target`.
485
509
// / \return newly inserted location
486
510
targett insert_after (const_targett target)
487
511
{
@@ -619,6 +643,8 @@ class goto_programt
619
643
instructions.clear ();
620
644
}
621
645
646
+ // / Get an instruction iterator pointing to the END_FUNCTION instruction of
647
+ // / the goto program
622
648
targett get_end_function ()
623
649
{
624
650
PRECONDITION (!instructions.empty ());
@@ -628,6 +654,8 @@ class goto_programt
628
654
return end_function;
629
655
}
630
656
657
+ // / Get an instruction iterator pointing to the END_FUNCTION instruction of
658
+ // / the goto program
631
659
const_targett get_end_function () const
632
660
{
633
661
PRECONDITION (!instructions.empty ());
@@ -653,6 +681,18 @@ class goto_programt
653
681
bool equals (const goto_programt &other) const ;
654
682
};
655
683
684
+ // / Get control-flow successors of a given instruction. The instruction is
685
+ // / represented by a pointer `target` of type `Target`. An instruction has
686
+ // / either 0, 1, or 2 successors (more than two successors is deprecated). For
687
+ // / example, an `ASSUME` instruction with the `guard` being a `false_exprt` has
688
+ // / 0 successors, and `ASSIGN` instruction has 1 successor, and a `GOTO`
689
+ // / instruction with the `guard` not being a `true_exprt` has 2 successors.
690
+ // /
691
+ // / \tparam Target: type used to represent a pointer to an instruction in a goto
692
+ // / program
693
+ // / \param target: pointer to the instruction of which to get the successors of
694
+ // / \return List of control-flow successors of the pointed-to goto program
695
+ // / instruction
656
696
template <typename Target>
657
697
std::list<Target> goto_programt::get_successors (
658
698
Target target) const
0 commit comments