Skip to content

Commit d2f2c88

Browse files
Define a symex_value_sett class
This is meant to be used in symex as an interface to value_sett instead of accessing value_sett directly. This is to ensure it will be used in a consistent way, in particular regarding the renaming level.
1 parent 20ed184 commit d2f2c88

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed

src/goto-symex/symex_value_set.h

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*******************************************************************\
2+
3+
Module: Symbolic Execution
4+
5+
Author: Romain Brenguier, [email protected]
6+
7+
\*******************************************************************/
8+
9+
/// \file
10+
/// symex_value_sett class definition
11+
12+
#ifndef CPROVER_GOTO_SYMEX_SYMEX_VALUE_SET_H
13+
#define CPROVER_GOTO_SYMEX_SYMEX_VALUE_SET_H
14+
15+
#include <pointer-analysis/value_set.h>
16+
#include "renamed.h"
17+
18+
/// Wrapper for value_sett which ensures we access it in a consistent way.
19+
/// In particular level 1 names should be used.
20+
class symex_value_sett final
21+
{
22+
public:
23+
/// \copydoc value_sett::assign
24+
void assign(
25+
const renamedt<ssa_exprt, L1> &lhs,
26+
const renamedt<exprt, L1> &rhs,
27+
const namespacet &ns,
28+
bool is_simplified,
29+
bool add_to_sets)
30+
{
31+
value_set.assign(lhs.get(), rhs.get(), ns, is_simplified, add_to_sets);
32+
}
33+
34+
/// Remove the entry corresponding to \p lhs
35+
void erase_symbol(const renamedt<ssa_exprt, L1> &lhs, const namespacet &ns)
36+
{
37+
value_set.erase_symbol(lhs.get(), ns);
38+
}
39+
40+
/// Remove the entry corresponding to \p l1_identifier.
41+
/// Warning: which identifier is used to represent an expression is an
42+
/// implementation detail, it is thus preferred to use \ref erase_symbol.
43+
void erase_if_exists(const irep_idt &l1_identifier)
44+
{
45+
value_set.values.erase_if_exists(l1_identifier);
46+
}
47+
48+
/// Update the entry for \p symbol_expr by erasing any values listed in
49+
/// \p to_erase.
50+
void erase(
51+
const symbol_exprt &symbol_expr,
52+
const namespacet &ns,
53+
const std::unordered_set<exprt, irep_hash> &to_erase)
54+
{
55+
const auto entry_index = value_set.get_index_of_symbol(
56+
symbol_expr.get_identifier(), symbol_expr.type(), "", ns);
57+
value_set.erase_values_from_entry(*entry_index, to_erase);
58+
}
59+
60+
/// \copydoc value_sett::get_value_set(exprt, const namespacet &)
61+
std::vector<exprt>
62+
get_value_set(const renamedt<exprt, L1> &expr, const namespacet &ns) const
63+
{
64+
return value_set.get_value_set(expr.get(), ns);
65+
}
66+
67+
/// \copydoc value_sett::make_union(const value_sett &)
68+
bool make_union(const symex_value_sett &new_values)
69+
{
70+
return value_set.make_union(new_values.value_set);
71+
}
72+
73+
private:
74+
value_sett value_set;
75+
};
76+
77+
#endif // CPROVER_GOTO_SYMEX_SYMEX_VALUE_SET_H

0 commit comments

Comments
 (0)