-
Notifications
You must be signed in to change notification settings - Fork 273
/
Copy pathgoto_check.cpp
98 lines (81 loc) · 2.51 KB
/
goto_check.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
89
90
91
92
93
94
95
96
97
98
/*******************************************************************\
Module: GOTO Programs
Author: Daniel Kroening, [email protected]
\*******************************************************************/
/// \file
/// GOTO Programs
#include "goto_check.h"
#include <util/options.h>
#include "goto_model.h"
#include "remove_skip.h"
static void transform_assertions_assumptions(
goto_programt &goto_program,
bool enable_assertions,
bool enable_built_in_assertions,
bool enable_assumptions)
{
bool did_something = false;
for(auto &instruction : goto_program.instructions)
{
if(instruction.is_assert())
{
bool is_user_provided =
instruction.source_location().get_bool("user-provided");
if(
(is_user_provided && !enable_assertions &&
instruction.source_location().get_property_class() != "error label") ||
(!is_user_provided && !enable_built_in_assertions))
{
instruction.turn_into_skip();
did_something = true;
}
}
else if(instruction.is_assume())
{
if(!enable_assumptions)
{
instruction.turn_into_skip();
did_something = true;
}
}
}
if(did_something)
remove_skip(goto_program);
}
void transform_assertions_assumptions(
const optionst &options,
goto_modelt &goto_model)
{
const bool enable_assertions = options.get_bool_option("assertions");
const bool enable_built_in_assertions =
options.get_bool_option("built-in-assertions");
const bool enable_assumptions = options.get_bool_option("assumptions");
// check whether there could possibly be anything to do
if(enable_assertions && enable_built_in_assertions && enable_assumptions)
return;
for(auto &entry : goto_model.goto_functions.function_map)
{
transform_assertions_assumptions(
entry.second.body,
enable_assertions,
enable_built_in_assertions,
enable_assumptions);
}
}
void transform_assertions_assumptions(
const optionst &options,
goto_programt &goto_program)
{
const bool enable_assertions = options.get_bool_option("assertions");
const bool enable_built_in_assertions =
options.get_bool_option("built-in-assertions");
const bool enable_assumptions = options.get_bool_option("assumptions");
// check whether there could possibly be anything to do
if(enable_assertions && enable_built_in_assertions && enable_assumptions)
return;
transform_assertions_assumptions(
goto_program,
enable_assertions,
enable_built_in_assertions,
enable_assumptions);
}