Skip to content

Commit fdfca41

Browse files
Replace class object_map_dt by std::map
Instead of defining a new class with the same interface as std::map and which use std::map internally, we use using and define outside the static field `blank` which is the only thing added to std::map. This simplifies a lot the code in the value_set class header.
1 parent e7bd309 commit fdfca41

File tree

2 files changed

+5
-68
lines changed

2 files changed

+5
-68
lines changed

src/pointer-analysis/value_set.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Author: Daniel Kroening, [email protected]
3333
// Due to a large number of functions defined inline, `value_sett` and
3434
// associated types are documented in its header file, `value_set.h`.
3535

36-
const value_sett::object_map_dt value_sett::object_map_dt::blank{};
36+
const value_sett::object_map_dt value_sett::empty_object_map{};
3737
object_numberingt value_sett::object_numbering;
3838

3939
bool value_sett::field_sensitive(const irep_idt &id, const typet &type)

src/pointer-analysis/value_set.h

Lines changed: 4 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -89,73 +89,10 @@ class value_sett
8989
/// offsets (`offsett` instances). This is the RHS set of a single row of
9090
/// the enclosing `value_sett`, such as `{ null, dynamic_object1 }`.
9191
/// The set is represented as a map from numbered `exprt`s to `offsett`
92-
/// instead of a set of pairs to make lookup by `exprt` easier. All
93-
/// methods matching the interface of `std::map` forward those methods
94-
/// to the internal map.
95-
class object_map_dt
96-
{
97-
typedef std::map<object_numberingt::number_type, offsett> data_typet;
98-
data_typet data;
99-
100-
public:
101-
// NOLINTNEXTLINE(readability/identifiers)
102-
typedef data_typet::iterator iterator;
103-
// NOLINTNEXTLINE(readability/identifiers)
104-
typedef data_typet::const_iterator const_iterator;
105-
// NOLINTNEXTLINE(readability/identifiers)
106-
typedef data_typet::value_type value_type;
107-
// NOLINTNEXTLINE(readability/identifiers)
108-
typedef data_typet::key_type key_type;
109-
110-
iterator begin() { return data.begin(); }
111-
const_iterator begin() const { return data.begin(); }
112-
const_iterator cbegin() const { return data.cbegin(); }
113-
114-
iterator end() { return data.end(); }
115-
const_iterator end() const { return data.end(); }
116-
const_iterator cend() const { return data.cend(); }
117-
118-
size_t size() const { return data.size(); }
119-
bool empty() const { return data.empty(); }
120-
121-
void erase(key_type i) { data.erase(i); }
122-
void erase(const_iterator it) { data.erase(it); }
123-
124-
offsett &operator[](key_type i)
125-
{
126-
return data[i];
127-
}
128-
offsett &at(key_type i)
129-
{
130-
return data.at(i);
131-
}
132-
const offsett &at(key_type i) const
133-
{
134-
return data.at(i);
135-
}
136-
137-
template <typename It>
138-
void insert(It b, It e) { data.insert(b, e); }
139-
140-
template <typename T>
141-
const_iterator find(T &&t) const { return data.find(std::forward<T>(t)); }
92+
/// instead of a set of pairs to make lookup by `exprt` easier.
93+
using object_map_dt = std::map<object_numberingt::number_type, offsett>;
14294

143-
static const object_map_dt blank;
144-
145-
object_map_dt()=default;
146-
147-
bool operator==(const object_map_dt &other) const
148-
{
149-
return data==other.data;
150-
}
151-
bool operator!=(const object_map_dt &other) const
152-
{
153-
return !(*this==other);
154-
}
155-
156-
protected:
157-
~object_map_dt()=default;
158-
};
95+
static const object_map_dt empty_object_map;
15996

16097
/// Converts an `object_map_dt` element `object_number -> offset` into an
16198
/// `object_descriptor_exprt` with
@@ -175,7 +112,7 @@ class value_sett
175112
///
176113
/// Then the set { dynamic_object1 }, represented by an `object_map_dt`, can
177114
/// be shared between the two `value_sett` instances.
178-
typedef reference_counting<object_map_dt> object_mapt;
115+
using object_mapt = reference_counting<object_map_dt, empty_object_map>;
179116

180117
/// Sets an element in object map `dest` to match an existing element `it`
181118
/// from a different map. Any existing element for the same `exprt` is

0 commit comments

Comments
 (0)