cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
havoc_utils.h
Go to the documentation of this file.
1
/*******************************************************************\
2
3
Module: Utilities for building havoc code for expressions.
4
5
Author: Saswat Padhi, saspadhi@amazon.com
6
7
Date: July 2021
8
9
\*******************************************************************/
10
13
14
#ifndef CPROVER_GOTO_INSTRUMENT_HAVOC_UTILS_H
15
#define CPROVER_GOTO_INSTRUMENT_HAVOC_UTILS_H
16
17
#include <
util/expr.h
>
18
#include <
util/expr_util.h
>
19
20
#include <set>
21
22
class
goto_programt
;
23
24
typedef
std::set<exprt>
assignst
;
25
27
class
havoc_utils_can_forward_propagatet
:
public
can_forward_propagatet
28
{
29
public
:
30
explicit
havoc_utils_can_forward_propagatet
(
31
const
assignst
&mod,
32
const
namespacet
&
ns
)
33
:
can_forward_propagatet
(
ns
),
assigns
(mod)
34
{
35
}
36
37
bool
is_constant
(
const
exprt
&expr)
const override
38
{
39
// Besides the "usual" constants (checked in
40
// can_forward_propagatet::is_constant), we also treat unmodified symbols as
41
// constants
42
if
(expr.
id
() == ID_symbol &&
assigns
.find(expr) ==
assigns
.end())
43
return
true
;
44
45
return
can_forward_propagatet::is_constant
(expr);
46
}
47
48
protected
:
49
const
assignst
&
assigns
;
50
};
51
52
class
havoc_utilst
53
{
54
public
:
55
explicit
havoc_utilst
(
const
assignst
&mod,
const
namespacet
&ns)
56
:
assigns
(mod),
is_constant
(mod, ns)
57
{
58
}
59
67
void
68
append_full_havoc_code
(
const
source_locationt
location,
goto_programt
&dest);
69
81
virtual
void
append_havoc_code_for_expr
(
82
const
source_locationt
location,
83
const
exprt
&expr,
84
goto_programt
&dest);
85
91
virtual
void
append_object_havoc_code_for_expr
(
92
const
source_locationt
location,
93
const
exprt
&expr,
94
goto_programt
&dest)
const
;
95
101
virtual
void
append_scalar_havoc_code_for_expr
(
102
const
source_locationt
location,
103
const
exprt
&expr,
104
goto_programt
&dest)
const
;
105
106
protected
:
107
const
assignst
&
assigns
;
108
const
havoc_utils_can_forward_propagatet
is_constant
;
109
};
110
111
#endif
// CPROVER_GOTO_INSTRUMENT_HAVOC_UTILS_H
can_forward_propagatet::is_constant
virtual bool is_constant(const exprt &) const
This function determines what expressions are to be propagated as "constants".
Definition
expr_util.cpp:198
can_forward_propagatet::ns
const namespacet & ns
Definition
expr_util.h:100
can_forward_propagatet::can_forward_propagatet
can_forward_propagatet(const namespacet &ns)
Definition
expr_util.h:89
exprt
Base class for all expressions.
Definition
expr.h:57
goto_programt
A generic container class for the GOTO intermediate representation of one function.
Definition
goto_program.h:72
havoc_utils_can_forward_propagatet
A class containing utility functions for havocing expressions.
Definition
havoc_utils.h:28
havoc_utils_can_forward_propagatet::is_constant
bool is_constant(const exprt &expr) const override
This function determines what expressions are to be propagated as "constants".
Definition
havoc_utils.h:37
havoc_utils_can_forward_propagatet::assigns
const assignst & assigns
Definition
havoc_utils.h:49
havoc_utils_can_forward_propagatet::havoc_utils_can_forward_propagatet
havoc_utils_can_forward_propagatet(const assignst &mod, const namespacet &ns)
Definition
havoc_utils.h:30
havoc_utilst::append_havoc_code_for_expr
virtual void append_havoc_code_for_expr(const source_locationt location, const exprt &expr, goto_programt &dest)
Append goto instructions to havoc a single expression expr.
Definition
havoc_utils.cpp:29
havoc_utilst::is_constant
const havoc_utils_can_forward_propagatet is_constant
Definition
havoc_utils.h:108
havoc_utilst::append_object_havoc_code_for_expr
virtual void append_object_havoc_code_for_expr(const source_locationt location, const exprt &expr, goto_programt &dest) const
Append goto instructions to havoc the underlying object of expr.
Definition
havoc_utils.cpp:46
havoc_utilst::assigns
const assignst & assigns
Definition
havoc_utils.h:107
havoc_utilst::havoc_utilst
havoc_utilst(const assignst &mod, const namespacet &ns)
Definition
havoc_utils.h:55
havoc_utilst::append_full_havoc_code
void append_full_havoc_code(const source_locationt location, goto_programt &dest)
Append goto instructions to havoc the full assigns set.
Definition
havoc_utils.cpp:21
havoc_utilst::append_scalar_havoc_code_for_expr
virtual void append_scalar_havoc_code_for_expr(const source_locationt location, const exprt &expr, goto_programt &dest) const
Append goto instructions to havoc the value of expr.
Definition
havoc_utils.cpp:57
irept::id
const irep_idt & id() const
Definition
irep.h:388
namespacet
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition
namespace.h:91
source_locationt
Definition
source_location.h:20
expr.h
expr_util.h
Deprecated expression utility functions.
assignst
std::set< exprt > assignst
Definition
havoc_utils.h:24
goto-instrument
havoc_utils.h
Generated by
1.17.0