cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
goto_function.cpp
Go to the documentation of this file.
1
/*******************************************************************\
2
3
Module: A GOTO Function
4
5
Author: Daniel Kroening
6
7
Date: May 2018
8
9
\*******************************************************************/
10
13
14
#include "
goto_function.h
"
15
16
#include <
util/namespace.h
>
17
#include <
util/symbol.h
>
18
21
void
get_local_identifiers
(
22
const
goto_functiont
&goto_function,
23
std::set<irep_idt> &dest)
24
{
25
goto_function.
body
.
get_decl_identifiers
(dest);
26
27
// add parameters
28
for
(
const
auto
&identifier : goto_function.
parameter_identifiers
)
29
{
30
if
(!identifier.empty())
31
dest.insert(identifier);
32
}
33
}
34
39
void
goto_functiont::validate
(
const
namespacet
&ns,
const
validation_modet
vm)
40
const
41
{
42
for
(
const
auto
&identifier :
parameter_identifiers
)
43
{
44
DATA_CHECK_WITH_DIAGNOSTICS
(
45
vm,
46
identifier.empty() || ns.
lookup
(identifier).is_parameter,
47
"parameter should be marked 'is_parameter' in the symbol table"
,
48
"affected parameter: "
,
49
identifier);
50
}
51
52
// function body must end with an END_FUNCTION instruction
53
if
(
body_available
())
54
{
55
DATA_CHECK
(
56
vm,
57
body
.instructions.back().is_end_function(),
58
"last instruction should be of end function type"
);
59
}
60
61
body
.validate(ns, vm);
62
}
goto_functiont
A goto function, consisting of function body (see body) and parameter identifiers (see parameter_iden...
Definition
goto_function.h:24
goto_functiont::body
goto_programt body
Definition
goto_function.h:26
goto_functiont::parameter_identifiers
parameter_identifierst parameter_identifiers
The identifiers of the parameters of this function.
Definition
goto_function.h:33
goto_functiont::validate
void validate(const namespacet &ns, const validation_modet vm) const
Check that the goto function is well-formed.
Definition
goto_function.cpp:39
goto_functiont::body_available
bool body_available() const
Definition
goto_function.h:35
goto_programt::get_decl_identifiers
void get_decl_identifiers(decl_identifierst &decl_identifiers) const
get the variables in decl statements
Definition
goto_program.cpp:319
namespacet
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition
namespace.h:91
namespacet::lookup
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See documentation for namespace_baset::lookup().
Definition
namespace.cpp:134
get_local_identifiers
void get_local_identifiers(const goto_functiont &goto_function, std::set< irep_idt > &dest)
Return in dest the identifiers of the local variables declared in the goto_function and the identifie...
Definition
goto_function.cpp:21
goto_function.h
Goto Function.
namespace.h
symbol.h
Symbol table entry.
DATA_CHECK_WITH_DIAGNOSTICS
#define DATA_CHECK_WITH_DIAGNOSTICS(vm, condition, message,...)
Definition
validate.h:37
DATA_CHECK
#define DATA_CHECK(vm, condition, message)
This macro takes a condition which denotes a well-formedness criterion on goto programs,...
Definition
validate.h:22
validation_modet
validation_modet
Definition
validation_mode.h:13
goto-programs
goto_function.cpp
Generated by
1.17.0