ObjectSet and PointsToMap: Add overloads that accept pointers.
This will make it easier to transition these classes to storing pointers.
PiperOrigin-RevId: 458419317
diff --git a/lifetime_analysis/object_set.h b/lifetime_analysis/object_set.h
index befe985..74fb27c 100644
--- a/lifetime_analysis/object_set.h
+++ b/lifetime_analysis/object_set.h
@@ -35,6 +35,11 @@
objects_.insert(object);
}
}
+ ObjectSet(std::initializer_list<const Object*> objects) {
+ for (const Object* object : objects) {
+ objects_.insert(*object);
+ }
+ }
// Returns a human-readable string representation of the object set.
std::string DebugString() const;
@@ -49,6 +54,7 @@
// Returns whether this set contains `object`.
bool Contains(Object object) const { return objects_.contains(object); }
+ bool Contains(const Object* object) const { return Contains(*object); }
// Returns whether this set contains all objects in `other`, i.e. whether
// this set is a superset of `other`.
@@ -71,6 +77,7 @@
// Adds `object` to this object set.
void Add(Object object) { objects_.insert(object); }
+ void Add(const Object* object) { Add(*object); }
// Adds the `other` objects to this object set.
void Add(const ObjectSet& other) {
diff --git a/lifetime_analysis/points_to_map.h b/lifetime_analysis/points_to_map.h
index 28e1922..3f97f66 100644
--- a/lifetime_analysis/points_to_map.h
+++ b/lifetime_analysis/points_to_map.h
@@ -63,9 +63,15 @@
// Returns the points-to set associated with `pointer`, or an empty set if
// `pointer` is not associated with a points-to set.
ObjectSet GetPointerPointsToSet(Object pointer) const;
+ ObjectSet GetPointerPointsToSet(const Object* pointer) const {
+ return GetPointerPointsToSet(*pointer);
+ }
// Associates `pointer` with the given points-to set.
void SetPointerPointsToSet(Object pointer, ObjectSet points_to);
+ void SetPointerPointsToSet(const Object* pointer, ObjectSet points_to) {
+ SetPointerPointsToSet(*pointer, points_to);
+ }
// Associates all `pointers` with the given points-to set.
void SetPointerPointsToSet(const ObjectSet& pointers,
@@ -73,6 +79,10 @@
// Extends a single `pointer`'s points-to set with the given points-to set.
void ExtendPointerPointsToSet(Object pointer, const ObjectSet& points_to);
+ void ExtendPointerPointsToSet(const Object* pointer,
+ const ObjectSet& points_to) {
+ ExtendPointerPointsToSet(*pointer, points_to);
+ }
// Returns the union of the points-to sets associated with the given pointers,
// or an empty set if none of the pointers is associated with a points-to set.