-
Notifications
You must be signed in to change notification settings - Fork 273
/
Copy pathgoto_instruction_code.cpp
88 lines (75 loc) · 2.43 KB
/
goto_instruction_code.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*******************************************************************\
Module: Data structures representing instructions in a GOTO program
Author: Daniel Kroening, [email protected]
\*******************************************************************/
/// \file
/// Data structures representing instructions in a GOTO program
#include "goto_instruction_code.h"
#include <util/arith_tools.h>
#include <util/c_types.h>
#include <util/cprover_prefix.h>
#include <util/namespace.h>
#include <util/std_expr.h>
#include <util/string_constant.h>
#include <util/symbol.h>
code_inputt::code_inputt(
std::vector<exprt> arguments,
std::optional<source_locationt> location)
: codet{ID_input, std::move(arguments)}
{
if(location)
add_source_location() = std::move(*location);
check(*this, validation_modet::INVARIANT);
}
code_inputt::code_inputt(
const irep_idt &description,
exprt expression,
std::optional<source_locationt> location)
: code_inputt{
{address_of_exprt(index_exprt(
string_constantt(description),
from_integer(0, c_index_type()))),
std::move(expression)},
std::move(location)}
{
}
void code_inputt::check(const codet &code, const validation_modet vm)
{
DATA_CHECK(
vm, code.operands().size() >= 2, "input must have at least two operands");
}
code_outputt::code_outputt(
std::vector<exprt> arguments,
std::optional<source_locationt> location)
: codet{ID_output, std::move(arguments)}
{
if(location)
add_source_location() = std::move(*location);
check(*this, validation_modet::INVARIANT);
}
code_outputt::code_outputt(
const irep_idt &description,
exprt expression,
std::optional<source_locationt> location)
: code_outputt{
{address_of_exprt(index_exprt(
string_constantt(description),
from_integer(0, c_index_type()))),
std::move(expression)},
std::move(location)}
{
}
void code_outputt::check(const codet &code, const validation_modet vm)
{
DATA_CHECK(
vm, code.operands().size() >= 2, "output must have at least two operands");
}
inline code_function_callt
havoc_slice_call(const exprt &p, const exprt &size, const namespacet &ns)
{
irep_idt identifier = CPROVER_PREFIX "havoc_slice";
symbol_exprt havoc_slice_function = ns.lookup(identifier).symbol_expr();
code_function_callt::argumentst arguments = {p, size};
return code_function_callt{std::move(havoc_slice_function),
std::move(arguments)};
}