cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
goto_instruction_code.cpp
Go to the documentation of this file.
1
/*******************************************************************\
2
3
Module: Data structures representing instructions in a GOTO program
4
5
Author: Daniel Kroening, kroening@kroening.com
6
7
\*******************************************************************/
8
11
12
#include "
goto_instruction_code.h
"
13
14
#include <
util/arith_tools.h
>
15
#include <
util/c_types.h
>
16
#include <
util/cprover_prefix.h
>
17
#include <
util/namespace.h
>
18
#include <
util/std_expr.h
>
19
#include <
util/string_constant.h
>
20
#include <
util/symbol.h
>
21
22
code_inputt::code_inputt
(
23
std::vector<exprt> arguments,
24
std::optional<source_locationt> location)
25
:
codet
{ID_input,
std
::move(arguments)}
26
{
27
if
(location)
28
add_source_location
() = std::move(*location);
29
check
(*
this
,
validation_modet::INVARIANT
);
30
}
31
32
code_inputt::code_inputt
(
33
const
irep_idt
&description,
34
exprt
expression,
35
std::optional<source_locationt> location)
36
:
code_inputt
{
37
{
address_of_exprt
(
index_exprt
(
38
string_constantt
(description),
39
from_integer
(0,
c_index_type
()))),
40
std::move(expression)},
41
std::move(location)}
42
{
43
}
44
45
void
code_inputt::check
(
const
codet
&code,
const
validation_modet
vm)
46
{
47
DATA_CHECK
(
48
vm, code.
operands
().size() >= 2,
"input must have at least two operands"
);
49
}
50
51
code_outputt::code_outputt
(
52
std::vector<exprt> arguments,
53
std::optional<source_locationt> location)
54
:
codet
{ID_output,
std
::move(arguments)}
55
{
56
if
(location)
57
add_source_location
() = std::move(*location);
58
check
(*
this
,
validation_modet::INVARIANT
);
59
}
60
61
code_outputt::code_outputt
(
62
const
irep_idt
&description,
63
exprt
expression,
64
std::optional<source_locationt> location)
65
:
code_outputt
{
66
{
address_of_exprt
(
index_exprt
(
67
string_constantt
(description),
68
from_integer
(0,
c_index_type
()))),
69
std::move(expression)},
70
std::move(location)}
71
{
72
}
73
74
void
code_outputt::check
(
const
codet
&code,
const
validation_modet
vm)
75
{
76
DATA_CHECK
(
77
vm, code.
operands
().size() >= 2,
"output must have at least two operands"
);
78
}
79
80
inline
code_function_callt
81
havoc_slice_call
(
const
exprt
&p,
const
exprt
&size,
const
namespacet
&ns)
82
{
83
irep_idt
identifier =
CPROVER_PREFIX
"havoc_slice"
;
84
symbol_exprt
havoc_slice_function = ns.
lookup
(identifier).symbol_expr();
85
code_function_callt::argumentst
arguments = {p, size};
86
return
code_function_callt
{std::move(havoc_slice_function),
87
std::move(arguments)};
88
}
from_integer
constant_exprt from_integer(const mp_integer &int_value, const typet &type)
Definition
arith_tools.cpp:99
arith_tools.h
c_index_type
bitvector_typet c_index_type()
Definition
c_types.cpp:16
c_types.h
address_of_exprt
Operator to return the address of an object.
Definition
pointer_expr.h:540
code_function_callt
goto_instruction_codet representation of a function call statement.
Definition
goto_instruction_code.h:271
code_function_callt::argumentst
exprt::operandst argumentst
Definition
goto_instruction_code.h:280
code_inputt::check
static void check(const goto_instruction_codet &code, const validation_modet vm=validation_modet::INVARIANT)
Definition
goto_instruction_code.cpp:45
code_inputt::code_inputt
code_inputt(std::vector< exprt > arguments, std::optional< source_locationt > location={})
This constructor is for support of calls to __CPROVER_input in user code.
Definition
goto_instruction_code.cpp:22
code_outputt::code_outputt
code_outputt(std::vector< exprt > arguments, std::optional< source_locationt > location={})
This constructor is for support of calls to __CPROVER_output in user code.
Definition
goto_instruction_code.cpp:51
code_outputt::check
static void check(const goto_instruction_codet &code, const validation_modet vm=validation_modet::INVARIANT)
Definition
goto_instruction_code.cpp:74
codet::codet
codet(const irep_idt &statement)
Definition
std_code_base.h:34
exprt
Base class for all expressions.
Definition
expr.h:57
exprt::exprt
exprt()
Definition
expr.h:62
exprt::operands
operandst & operands()
Definition
expr.h:95
exprt::add_source_location
source_locationt & add_source_location()
Definition
expr.h:241
index_exprt
Array index operator.
Definition
std_expr.h:1421
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
string_constantt
Definition
string_constant.h:15
symbol_exprt
Expression to hold a symbol (variable).
Definition
std_expr.h:132
cprover_prefix.h
CPROVER_PREFIX
#define CPROVER_PREFIX
Definition
cprover_prefix.h:14
havoc_slice_call
code_function_callt havoc_slice_call(const exprt &p, const exprt &size, const namespacet &ns)
Builds a code_function_callt to __CPROVER_havoc_slice(p, size).
Definition
goto_instruction_code.cpp:81
goto_instruction_code.h
namespace.h
std
STL namespace.
std_expr.h
API to expression classes.
string_constant.h
symbol.h
Symbol table entry.
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
validation_modet::INVARIANT
@ INVARIANT
Definition
validation_mode.h:14
irep_idt
dstringt irep_idt
Definition
verification_result.h:16
goto-programs
goto_instruction_code.cpp
Generated by
1.17.0