cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
dfcc_loop_tags.cpp
Go to the documentation of this file.
1
/*******************************************************************\
2
3
Module: Dynamic frame condition checking
4
5
Author: Qinheping Hu, qinhh@amazon.com
6
Author: Remi Delmas, delmasrd@amazon.com
7
8
\*******************************************************************/
9
10
#include "
dfcc_loop_tags.h
"
11
12
const
irep_idt
ID_loop_id
=
"loop-id"
;
13
const
irep_idt
ID_loop_head
=
"loop-head"
;
14
const
irep_idt
ID_loop_body
=
"loop-body"
;
15
const
irep_idt
ID_loop_latch
=
"loop-latch"
;
16
const
irep_idt
ID_loop_exiting
=
"loop-exiting"
;
17
const
irep_idt
ID_loop_top_level
=
"loop-top-level"
;
18
19
void
dfcc_set_loop_id
(
20
goto_programt::instructiont::targett
&target,
21
const
std::size_t loop_id)
22
{
23
target->source_location_nonconst().set(
ID_loop_id
, loop_id);
24
}
25
26
std::optional<std::size_t>
27
dfcc_get_loop_id
(
const
goto_programt::instructiont::const_targett
&target)
28
{
29
if
(target->source_location().get(
ID_loop_id
).empty())
30
return
{};
31
32
return
target->source_location().get_size_t(
ID_loop_id
);
33
}
34
35
bool
dfcc_has_loop_id
(
36
const
goto_programt::instructiont::const_targett
&target,
37
std::size_t loop_id)
38
{
39
auto
loop_id_opt =
dfcc_get_loop_id
(target);
40
return
loop_id_opt.has_value() && loop_id_opt.value() == loop_id;
41
}
42
43
static
void
dfcc_set_loop_tag
(
44
goto_programt::instructiont::targett
&target,
45
const
irep_idt
&tag)
46
{
47
target->source_location_nonconst().set(tag,
true
);
48
}
49
50
static
bool
has_loop_tag
(
51
const
goto_programt::instructiont::const_targett
&target,
52
const
irep_idt
&tag)
53
{
54
return
target->source_location().get_bool(tag);
55
}
56
57
void
dfcc_set_loop_head
(
goto_programt::instructiont::targett
&target)
58
{
59
dfcc_set_loop_tag
(target,
ID_loop_head
);
60
}
61
62
bool
dfcc_is_loop_head
(
const
goto_programt::instructiont::const_targett
&target)
63
{
64
return
has_loop_tag
(target,
ID_loop_head
);
65
}
66
67
void
dfcc_set_loop_body
(
goto_programt::instructiont::targett
&target)
68
{
69
dfcc_set_loop_tag
(target,
ID_loop_body
);
70
}
71
72
bool
dfcc_is_loop_body
(
const
goto_programt::instructiont::const_targett
&target)
73
{
74
return
has_loop_tag
(target,
ID_loop_body
);
75
}
76
77
void
dfcc_set_loop_exiting
(
goto_programt::instructiont::targett
&target)
78
{
79
dfcc_set_loop_tag
(target,
ID_loop_exiting
);
80
}
81
82
bool
dfcc_is_loop_exiting
(
83
const
goto_programt::instructiont::const_targett
&target)
84
{
85
return
has_loop_tag
(target,
ID_loop_exiting
);
86
}
87
88
void
dfcc_set_loop_latch
(
goto_programt::instructiont::targett
&target)
89
{
90
dfcc_set_loop_tag
(target,
ID_loop_latch
);
91
}
92
93
bool
dfcc_is_loop_latch
(
94
const
goto_programt::instructiont::const_targett
&target)
95
{
96
return
has_loop_tag
(target,
ID_loop_latch
);
97
}
98
99
void
dfcc_set_loop_top_level
(
goto_programt::instructiont::targett
&target)
100
{
101
dfcc_set_loop_tag
(target,
ID_loop_top_level
);
102
}
103
104
bool
dfcc_is_loop_top_level
(
105
const
goto_programt::instructiont::const_targett
&target)
106
{
107
return
has_loop_tag
(target,
ID_loop_top_level
);
108
}
109
110
void
dfcc_remove_loop_tags
(
source_locationt
&source_location)
111
{
112
source_location.
remove
(
ID_loop_id
);
113
source_location.
remove
(
ID_loop_head
);
114
source_location.
remove
(
ID_loop_body
);
115
source_location.
remove
(
ID_loop_exiting
);
116
source_location.
remove
(
ID_loop_latch
);
117
source_location.
remove
(
ID_loop_top_level
);
118
}
119
120
void
dfcc_remove_loop_tags
(
goto_programt::targett
&target)
121
{
122
dfcc_remove_loop_tags
(target->source_location_nonconst());
123
}
124
125
void
dfcc_remove_loop_tags
(
goto_programt
&goto_program)
126
{
127
for
(
auto
target = goto_program.
instructions
.begin();
128
target != goto_program.
instructions
.end();
129
target++)
130
{
131
dfcc_remove_loop_tags
(target);
132
}
133
}
goto_programt::instructiont::const_targett
std::list< instructiont >::const_iterator const_targett
Definition
goto_program.h:381
goto_programt::instructiont::targett
std::list< instructiont >::iterator targett
The target for gotos and for start_thread nodes.
Definition
goto_program.h:380
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
goto_programt::targett
instructionst::iterator targett
Definition
goto_program.h:613
irept::remove
void remove(const irep_idt &name)
Definition
irep.cpp:87
source_locationt
Definition
source_location.h:20
dfcc_has_loop_id
bool dfcc_has_loop_id(const goto_programt::instructiont::const_targett &target, std::size_t loop_id)
Definition
dfcc_loop_tags.cpp:35
ID_loop_top_level
const irep_idt ID_loop_top_level
Definition
dfcc_loop_tags.cpp:17
dfcc_set_loop_exiting
void dfcc_set_loop_exiting(goto_programt::instructiont::targett &target)
Definition
dfcc_loop_tags.cpp:77
dfcc_set_loop_latch
void dfcc_set_loop_latch(goto_programt::instructiont::targett &target)
Definition
dfcc_loop_tags.cpp:88
dfcc_is_loop_head
bool dfcc_is_loop_head(const goto_programt::instructiont::const_targett &target)
Definition
dfcc_loop_tags.cpp:62
dfcc_set_loop_tag
static void dfcc_set_loop_tag(goto_programt::instructiont::targett &target, const irep_idt &tag)
Definition
dfcc_loop_tags.cpp:43
ID_loop_id
const irep_idt ID_loop_id
Definition
dfcc_loop_tags.cpp:12
ID_loop_latch
const irep_idt ID_loop_latch
Definition
dfcc_loop_tags.cpp:15
dfcc_is_loop_latch
bool dfcc_is_loop_latch(const goto_programt::instructiont::const_targett &target)
Definition
dfcc_loop_tags.cpp:93
ID_loop_body
const irep_idt ID_loop_body
Definition
dfcc_loop_tags.cpp:14
dfcc_remove_loop_tags
void dfcc_remove_loop_tags(source_locationt &source_location)
Definition
dfcc_loop_tags.cpp:110
ID_loop_exiting
const irep_idt ID_loop_exiting
Definition
dfcc_loop_tags.cpp:16
dfcc_is_loop_top_level
bool dfcc_is_loop_top_level(const goto_programt::instructiont::const_targett &target)
Definition
dfcc_loop_tags.cpp:104
dfcc_set_loop_top_level
void dfcc_set_loop_top_level(goto_programt::instructiont::targett &target)
Definition
dfcc_loop_tags.cpp:99
has_loop_tag
static bool has_loop_tag(const goto_programt::instructiont::const_targett &target, const irep_idt &tag)
Definition
dfcc_loop_tags.cpp:50
dfcc_set_loop_body
void dfcc_set_loop_body(goto_programt::instructiont::targett &target)
Definition
dfcc_loop_tags.cpp:67
dfcc_set_loop_id
void dfcc_set_loop_id(goto_programt::instructiont::targett &target, const std::size_t loop_id)
Definition
dfcc_loop_tags.cpp:19
dfcc_get_loop_id
std::optional< std::size_t > dfcc_get_loop_id(const goto_programt::instructiont::const_targett &target)
Definition
dfcc_loop_tags.cpp:27
dfcc_is_loop_exiting
bool dfcc_is_loop_exiting(const goto_programt::instructiont::const_targett &target)
Definition
dfcc_loop_tags.cpp:82
ID_loop_head
const irep_idt ID_loop_head
Definition
dfcc_loop_tags.cpp:13
dfcc_is_loop_body
bool dfcc_is_loop_body(const goto_programt::instructiont::const_targett &target)
Definition
dfcc_loop_tags.cpp:72
dfcc_set_loop_head
void dfcc_set_loop_head(goto_programt::instructiont::targett &target)
Definition
dfcc_loop_tags.cpp:57
dfcc_loop_tags.h
Functions that allow to tag GOTO instructions with loop identifiers and loop instruction type: head,...
irep_idt
dstringt irep_idt
Definition
verification_result.h:16
goto-instrument
contracts
dynamic-frames
dfcc_loop_tags.cpp
Generated by
1.17.0