ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
rw_set.h
Go to the documentation of this file.
1#ifndef CPROVER_GOTO_PROGRAMS_RW_SET
2#define CPROVER_GOTO_PROGRAMS_RW_SET
3
6#include <irep2/irep2_guard.h>
9#include <unordered_set>
10
12{
13public:
14 struct entryt
15 {
17 bool r, w, deref;
20
22 {
23 }
24
25 const guard2tc &get_guard() const
26 {
27 return guard;
28 }
29
30 std::string get_comment() const
31 {
32 std::string result;
33 if (w)
34 result = "W/W";
35 else
36 result = "R/W";
37
38 result += " data race on " + id2string(object);
39
40 return result;
41 }
42 };
43
44 typedef std::unordered_map<irep_idt, entryt, irep_id_hash> entriest;
46
47 // Set of non-static local symbols whose address is taken somewhere in the
48 // program. Such locals may alias a pointer handed to another thread, so they
49 // remain race-eligible even when accessed directly by name (issue #4424).
50 // When null, no local is treated as shared (legacy behaviour).
51 typedef std::unordered_set<irep_idt, irep_id_hash> shared_localst;
52
53 void compute(const expr2tc &expr);
54
56 const namespacet &_ns,
58 const shared_localst *_shared_locals = nullptr)
59 : ns(_ns), target(_target), shared_locals(_shared_locals)
60 {
61 }
62
64 const namespacet &_ns,
66 const expr2tc &expr,
67 const shared_localst *_shared_locals = nullptr)
68 : ns(_ns), target(_target), shared_locals(_shared_locals)
69 {
70 compute(expr);
71 }
72
73 void read_rec(const expr2tc &expr)
74 {
75 read_write_rec(expr, true, false, "", guard2tc(), expr2tc());
76 }
77
79 const expr2tc &expr,
80 const guard2tc &guard,
81 const expr2tc &original_expr)
82 {
83 read_write_rec(expr, true, false, "", guard, original_expr);
84 }
85
86protected:
87 const namespacet &ns;
90
91 void assign(const expr2tc &lhs, const expr2tc &rhs);
92
93 void read_write_rec(
94 const expr2tc &expr,
95 bool r,
96 bool w,
97 const std::string &suffix,
98 const guard2tc &guard,
99 const expr2tc &original_expr,
100 bool dereferenced = false);
101};
102
103#define forall_rw_set_entries(it, rw_set) \
104 for (rw_sett::entriest::const_iterator it = (rw_set).entries.begin(); \
105 it != (rw_set).entries.end(); \
106 it++)
107
108#endif
instructionst::const_iterator const_targett
Definition goto_program.h:591
Path-condition guard container.
Definition irep2_guard.h:32
Definition irep_idt.h:12
Definition namespace.h:10
const shared_localst * shared_locals
Definition rw_set.h:89
void compute(const expr2tc &expr)
Definition rw_set.cpp:89
void read_rec(const expr2tc &expr)
Definition rw_set.h:73
entriest entries
Definition rw_set.h:45
rw_sett(const namespacet &_ns, goto_programt::const_targett _target, const expr2tc &expr, const shared_localst *_shared_locals=nullptr)
Definition rw_set.h:63
const namespacet & ns
Definition rw_set.h:87
void read_write_rec(const expr2tc &expr, bool r, bool w, const std::string &suffix, const guard2tc &guard, const expr2tc &original_expr, bool dereferenced=false)
Definition rw_set.cpp:195
void assign(const expr2tc &lhs, const expr2tc &rhs)
Definition rw_set.cpp:163
std::unordered_set< irep_idt, irep_id_hash > shared_localst
Definition rw_set.h:51
rw_sett(const namespacet &_ns, goto_programt::const_targett _target, const shared_localst *_shared_locals=nullptr)
Definition rw_set.h:55
void read_rec(const expr2tc &expr, const guard2tc &guard, const expr2tc &original_expr)
Definition rw_set.h:78
const goto_programt::const_targett target
Definition rw_set.h:88
std::unordered_map< irep_idt, entryt, irep_id_hash > entriest
Definition rw_set.h:44
irep_container< expr2t > expr2tc
Definition irep2.h:431
const std::string & id2string(const irep_idt &d)
Definition irep.h:1405
#define false
Definition stdbool.h:10
bool w
Definition rw_set.h:17
entryt()
Definition rw_set.h:21
const guard2tc & get_guard() const
Definition rw_set.h:25
std::string get_comment() const
Definition rw_set.h:30
guard2tc guard
Definition rw_set.h:18
irep_idt object
Definition rw_set.h:16
bool r
Definition rw_set.h:17
expr2tc original_expr
Definition rw_set.h:19
bool deref
Definition rw_set.h:17