CBMC
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ref_expr_set.h
Go to the documentation of this file.
1/*******************************************************************\
2
3Module: Value Set
4
5Author: Daniel Kroening, kroening@kroening.com
6
7\*******************************************************************/
8
11
12#ifndef CPROVER_UTIL_REF_EXPR_SET_H
13#define CPROVER_UTIL_REF_EXPR_SET_H
14
15#include <unordered_set>
16
17#include "expr.h"
18#include "reference_counting.h"
19
20extern const std::unordered_set<exprt, irep_hash> empty_expr_set;
21
23{
25 typedef std::unordered_set<exprt, irep_hash> expr_sett;
27
28 static const ref_expr_set_dt blank;
29};
30
31class ref_expr_sett:public reference_counting<ref_expr_set_dt>
32{
33public:
35
36 bool empty() const
37 {
38 if(d==nullptr)
39 return true;
40 return d->expr_set.empty();
41 }
42
43 const expr_sett &expr_set() const
44 {
45 return read().expr_set;
46 }
47
49 {
50 return write().expr_set;
51 }
52
54 {
55 if(s2.d==nullptr)
56 return false;
57
58 if(s2.d==d)
59 return false;
60
61 if(d==nullptr)
62 {
64 return true;
65 }
66
67 return make_union(s2.d->expr_set);
68 }
69
70 bool make_union(const expr_sett &s2)
71 {
73 size_t old_size=tmp.size();
74 tmp.insert(s2.begin(), s2.end());
75
76 // anything new?
77 if(tmp.size()==old_size)
78 return false;
79 move(tmp);
80 return true;
81 }
82
84 {
85 clear();
86 write().expr_set.swap(s2);
87 }
88};
89
90#endif // CPROVER_UTIL_REF_EXPR_SET_H
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:562
ref_expr_set_dt::expr_sett expr_sett
const expr_sett & expr_set() const
bool make_union(const ref_expr_sett &s2)
void move(expr_sett &s2)
bool empty() const
expr_sett & expr_set_write()
bool make_union(const expr_sett &s2)
void copy_from(const reference_counting &other)
const ref_expr_set_dt & read() const
const std::unordered_set< exprt, irep_hash > empty_expr_set
Reference Counting.
std::unordered_set< exprt, irep_hash > expr_sett
static const ref_expr_set_dt blank
expr_sett expr_set