cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
goto_check.cpp
Go to the documentation of this file.
1
/*******************************************************************\
2
3
Module: GOTO Programs
4
5
Author: Daniel Kroening, kroening@kroening.com
6
7
\*******************************************************************/
8
11
12
#include "
goto_check.h
"
13
14
#include <
util/options.h
>
15
16
#include "
goto_model.h
"
17
#include "
remove_skip.h
"
18
19
static
void
transform_assertions_assumptions
(
20
goto_programt
&goto_program,
21
bool
enable_assertions,
22
bool
enable_built_in_assertions,
23
bool
enable_assumptions)
24
{
25
bool
did_something =
false
;
26
27
for
(
auto
&instruction : goto_program.
instructions
)
28
{
29
if
(instruction.is_assert())
30
{
31
bool
is_user_provided =
32
instruction.source_location().get_bool(
"user-provided"
);
33
34
if
(
35
(is_user_provided && !enable_assertions &&
36
instruction.source_location().get_property_class() !=
"error label"
) ||
37
(!is_user_provided && !enable_built_in_assertions))
38
{
39
instruction.turn_into_skip();
40
did_something =
true
;
41
}
42
}
43
else
if
(instruction.is_assume())
44
{
45
if
(!enable_assumptions)
46
{
47
instruction.turn_into_skip();
48
did_something =
true
;
49
}
50
}
51
}
52
53
if
(did_something)
54
remove_skip
(goto_program);
55
}
56
57
void
transform_assertions_assumptions
(
58
const
optionst
&options,
59
goto_modelt
&goto_model)
60
{
61
const
bool
enable_assertions = options.
get_bool_option
(
"assertions"
);
62
const
bool
enable_built_in_assertions =
63
options.
get_bool_option
(
"built-in-assertions"
);
64
const
bool
enable_assumptions = options.
get_bool_option
(
"assumptions"
);
65
66
// check whether there could possibly be anything to do
67
if
(enable_assertions && enable_built_in_assertions && enable_assumptions)
68
return
;
69
70
for
(
auto
&entry : goto_model.
goto_functions
.
function_map
)
71
{
72
transform_assertions_assumptions
(
73
entry.second.body,
74
enable_assertions,
75
enable_built_in_assertions,
76
enable_assumptions);
77
}
78
}
79
80
void
transform_assertions_assumptions
(
81
const
optionst
&options,
82
goto_programt
&goto_program)
83
{
84
const
bool
enable_assertions = options.
get_bool_option
(
"assertions"
);
85
const
bool
enable_built_in_assertions =
86
options.
get_bool_option
(
"built-in-assertions"
);
87
const
bool
enable_assumptions = options.
get_bool_option
(
"assumptions"
);
88
89
// check whether there could possibly be anything to do
90
if
(enable_assertions && enable_built_in_assertions && enable_assumptions)
91
return
;
92
93
transform_assertions_assumptions
(
94
goto_program,
95
enable_assertions,
96
enable_built_in_assertions,
97
enable_assumptions);
98
}
goto_functionst::function_map
function_mapt function_map
Definition
goto_functions.h:29
goto_modelt
Definition
goto_model.h:27
goto_modelt::goto_functions
goto_functionst goto_functions
GOTO functions.
Definition
goto_model.h:34
goto_programt
A generic container class for the GOTO intermediate representation of one function.
Definition
goto_program.h:72
goto_programt::instructions
instructionst instructions
The list of instructions in the goto program.
Definition
goto_program.h:621
optionst
Definition
options.h:23
optionst::get_bool_option
bool get_bool_option(const std::string &option) const
Definition
options.cpp:44
transform_assertions_assumptions
static void transform_assertions_assumptions(goto_programt &goto_program, bool enable_assertions, bool enable_built_in_assertions, bool enable_assumptions)
Definition
goto_check.cpp:19
goto_check.h
Checks for Errors in C and Java Programs.
goto_model.h
Symbol Table + CFG.
options.h
Options.
remove_skip
void remove_skip(goto_programt &goto_program, goto_programt::targett begin, goto_programt::targett end)
remove unnecessary skip statements
Definition
remove_skip.cpp:87
remove_skip.h
Program Transformation.
goto-programs
goto_check.cpp
Generated by
1.17.0