1/*******************************************************************\
3 Module: analyses variable-sensitivity write_location_context
7\*******************************************************************/
38 const std::stack<exprt> &stack,
46 // Only perform an update if the write to the child has in fact changed it...
50 // Need to ensure the result of the write is still wrapped in a dependency
53 std::dynamic_pointer_cast<write_location_contextt>(
mutable_clone());
55 // Update the child and record the updated write locations
58 std::dynamic_pointer_cast<const write_location_contextt>(value);
62 result->set_last_written_locations(
84 std::dynamic_pointer_cast<const write_location_contextt>(other);
99// need wrapper function here to disambiguate meet overload
111 std::dynamic_pointer_cast<const write_location_contextt>(other);
126 // If the union is larger than the initial set, then update.
133 std::dynamic_pointer_cast<write_location_contextt>(
mutable_clone());
167 std::dynamic_pointer_cast<const write_location_contextt>(other);
174 // If the union is larger than the initial set, then update.
178 std::dynamic_pointer_cast<write_location_contextt>(
mutable_clone());
190 std::dynamic_pointer_cast<write_location_contextt>(
mutable_clone());
191 result->set_last_written_locations(
locations);
221 // Output last written locations immediately following the child output
256 if(
this == before.get())
258 // copy-on-write means pointer equality implies no modifications
263 std::dynamic_pointer_cast<const write_location_contextt>(before);
267 // The other context is not something we understand, so must assume
268 // that the abstract_object has been modified
272 // Even if the pointers are different, it maybe that it has changed only
273 // because of a merge operation, rather than an actual write. Given that
274 // this class has knowledge of where writes have occured, use that
275 // information to determine if any writes have happened and use that as the
276 // proxy for whether the value has changed or not.
278 // For two sets of last written locations to match,
279 // each location in one set must be equal to precisely one location
280 // in the other, since a set can assume at most one match
285 class location_ordert
296 typedef std::set<goto_programt::const_targett, location_ordert>
312 std::set_intersection(
348 out << location_number;
353 out <<
", " << location_number;
sharing_ptrt< class abstract_objectt > abstract_object_pointert
static combine_result merge(const abstract_object_pointert &op1, const abstract_object_pointert &op2, const locationt &merge_location, const widen_modet &widen_mode)
static combine_result meet(const abstract_object_pointert &op1, const abstract_object_pointert &op2)
Interface method for the meet operation.
This is the basic interface of the abstract interpreter with default implementations of the core func...
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
std::shared_ptr< context_abstract_objectt > context_abstract_object_ptrt
void output(std::ostream &out, const class ai_baset &ai, const namespacet &ns) const override
Output a representation of the value of this abstract object.
abstract_object_pointert child_abstract_object
std::set< locationt, goto_programt::target_less_than > locationst
Base class for all expressions.
instructionst::const_iterator const_targett
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
abstract_object_pointert merge(const abstract_object_pointert &other, const widen_modet &widen_mode) const override
Create a new abstract object that is the result of merging this abstract object with a given abstract...
std::function< abstract_objectt::combine_result(const abstract_object_pointert &op1, const abstract_object_pointert &op2)> combine_fn
internal_abstract_object_pointert mutable_clone() const override
virtual locationst get_last_written_locations() const
abstract_object_pointert abstract_object_merge_internal(const abstract_object_pointert &other) const override
Helper function for abstract_objectt::abstract_object_merge to perform any additional actions after t...
void output(std::ostream &out, const class ai_baset &ai, const namespacet &ns) const override
Output a representation of the value of this abstract object.
locationst last_written_locations
abstract_object_pointert meet(const abstract_object_pointert &other) const override
Base implementation of the meet operation: only used if no more precise abstraction can be used,...
abstract_object_pointert write(abstract_environmentt &environment, const namespacet &ns, const std::stack< exprt > &stack, const exprt &specifier, const abstract_object_pointert &value, bool merging_write) const override
A helper function to evaluate writing to a component of an abstract object.
static void output_last_written_locations(std::ostream &out, const locationst &locations)
Internal helper function to format and output a given set of locations.
bool has_been_modified(const abstract_object_pointert &before) const override
Determine whether 'this' abstract_object has been modified in comparison to a previous 'before' state...
locationst get_location_union(const locationst &locations) const
Construct the union of the location set of the current object, and a the provided location set.
void set_last_written_locations(const locationst &locations)
Sets the last written locations for this context.
std::shared_ptr< const write_location_contextt > write_location_context_ptrt
context_abstract_object_ptrt update_location_context_internal(const locationst &locations) const override
abstract_object_pointert combine(const write_location_context_ptrt &other, combine_fn fn) const
void intersection(const typename graph_nodet< E >::edgest &a, const typename graph_nodet< E >::edgest &b, typename graph_nodet< E >::edgest &dest)
Compute intersection of two edge sets, in linear time.
Clones the first parameter and merges it with the second.
static abstract_objectt::combine_result object_meet(const abstract_object_pointert &op1, const abstract_object_pointert &op2)
Maintain a context in the variable sensitvity domain that records write locations for a given abstrac...