52 bool did_initialize_values =
false;
53 auto struct_type_it = struct_type_def.
components().begin();
55 ++param_it, ++struct_type_it)
58 struct_type_it->get_name(),
60 did_initialize_values =
true;
63 if(did_initialize_values)
101 member_expr.
type(), ns,
true,
false);
109 const std::stack<exprt> &stack,
112 bool merging_write)
const
121 return std::make_shared<full_struct_abstract_objectt>(
126 std::dynamic_pointer_cast<full_struct_abstract_objectt>(
mutable_clone());
132 auto const old_value =
map.
find(c);
133 if(!old_value.has_value())
136 member_expr.
type(), ns,
true,
false);
138 c, environment.
write(starting_value, value, stack, ns, merging_write));
144 environment.
write(old_value.value(), value, stack, ns, merging_write));
147 result->set_not_top();
148 DATA_INVARIANT(result->verify(),
"Structural invariants maintained");
154 std::cout <<
"Setting component" << std::endl;
158 auto const old_value = result->map.find(c);
164 DATA_INVARIANT(result->verify(),
"Structural invariants maintained");
168 INVARIANT(!result->map.empty(),
"If not top, map cannot be empty");
170 if(!old_value.has_value())
172 DATA_INVARIANT(result->verify(),
"Structural invariants maintained");
183 if(old_value.has_value())
185 result->map.replace(c, value);
189 result->map.insert(c, value);
191 result->set_not_top();
192 INVARIANT(!result->is_bottom(),
"top != bottom");
195 DATA_INVARIANT(result->verify(),
"Structural invariants maintained");
210 (
type().
id() == ID_struct_tag ||
type().
id() == ID_union_tag)
217 for(
const auto &field : type_decl.
components())
219 auto value =
map.
find(field.get_name());
220 if(value.has_value())
226 out <<
'.' << field.get_name() <<
'=';
247 std::dynamic_pointer_cast<const full_struct_abstract_objectt>(other);
259 return std::make_shared<full_struct_abstract_objectt>(*other);
262 std::dynamic_pointer_cast<full_struct_abstract_objectt>(
mutable_clone());
269 return shared_from_this();
273 INVARIANT(!result->is_top(),
"Merge of maps will not generate top");
274 INVARIANT(!result->is_bottom(),
"Merge of maps will not generate bottom");
275 DATA_INVARIANT(result->verify(),
"Structural invariants maintained");
296 std::dynamic_pointer_cast<full_struct_abstract_objectt>(
mutable_clone());
298 bool is_modified =
visit_map(result->map, visitor);
300 return is_modified ? result : shared_from_this();
304 const exprt &name)
const
312 member_exprt(name, compound_type.get_component(field.first));
313 auto field_expr = field.second->to_predicate(field_name);
315 if(!field_expr.is_true())
316 all_predicates.push_back(field_expr);
319 if(all_predicates.empty())
321 if(all_predicates.size() == 1)
322 return all_predicates.front();
334 for(
auto const &
object : view)
336 if(visited.find(
object.second) == visited.end())
338 object.second->get_statistics(
statistics, visited, env, ns);
An abstract version of a program environment.
std::set< abstract_object_pointert > abstract_object_visitedt
sharing_ptrt< class abstract_objectt > abstract_object_pointert
static bool merge_shared_maps(const sharing_mapt< keyt, abstract_object_pointert, false, hash > &map1, const sharing_mapt< keyt, abstract_object_pointert, false, hash > &map2, sharing_mapt< keyt, abstract_object_pointert, false, hash > &out_map, const widen_modet &widen_mode)
virtual abstract_object_pointert write(const abstract_object_pointert &lhs, const abstract_object_pointert &rhs, std::stack< exprt > remaining_stack, const namespacet &ns, bool merge_write)
Used within assign to do the actual dispatch.
virtual abstract_object_pointert abstract_object_factory(const typet &type, const namespacet &ns, bool top, bool bottom) const
Look at the configuration for the sensitivity and create an appropriate abstract_object.
virtual bool is_top() const
Find out if the abstract object is top.
virtual bool is_bottom() const
Find out if the abstract object is bottom.
goto_programt::const_targett locationt
static combine_result merge(const abstract_object_pointert &op1, const abstract_object_pointert &op2, const locationt &merge_location, const widen_modet &widen_mode)
typet t
To enforce copy-on-write these are private and have read-only accessors.
virtual const typet & type() const
Get the real type of the variable this abstract object is representing.
This is the basic interface of the abstract interpreter with default implementations of the core func...
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Base class for all expressions.
std::vector< exprt > operandst
typet & type()
Return the type of the expression.
void output(std::ostream &out, const class ai_baset &ai, const class namespacet &ns) const override
To provide a human readable string to the out representing the current known value about this object.
abstract_object_pointert write_component(abstract_environmentt &environment, const namespacet &ns, const std::stack< exprt > &stack, const exprt &expr, const abstract_object_pointert &value, bool merging_write) const override
A helper function to evaluate writing to a component of a struct.
internal_abstract_object_pointert mutable_clone() const override
bool verify() const override
Function: full_struct_abstract_objectt::verify.
void statistics(abstract_object_statisticst &statistics, abstract_object_visitedt &visited, const abstract_environmentt &env, const namespacet &ns) const override
abstract_object_pointert write_location_context(const locationt &location) const override
Update the location context for an abstract object.
abstract_object_pointert visit_sub_elements(const abstract_object_visitort &visitor) const override
Apply a visitor operation to all sub elements of this abstract_object.
abstract_object_pointert merge_constant_structs(constant_struct_pointert other, const widen_modet &widen_mode) const
Performs an element wise merge of the map for each struct.
abstract_object_pointert merge_location_context(const locationt &location) const override
Update the merge location context for an abstract object.
sharing_ptrt< full_struct_abstract_objectt > constant_struct_pointert
abstract_object_pointert read_component(const abstract_environmentt &environment, const exprt &expr, const namespacet &ns) const override
A helper function to evaluate the abstract object contained within a struct.
full_struct_abstract_objectt(const full_struct_abstract_objectt &ao)
Explicit copy-constructor to make it clear that the shared_map used to store the values of fields is ...
abstract_object_pointert merge(const abstract_object_pointert &other, const widen_modet &widen_mode) const override
To merge an abstract object into this abstract object.
exprt to_predicate_internal(const exprt &name) const override
to_predicate implementation - derived classes will override
const irep_idt & id() const
Extract member of struct or union.
const exprt & compound() const
irep_idt get_component_name() const
static memory_sizet from_bytes(std::size_t bytes)
const union_typet & follow_tag(const union_tag_typet &) const
Follow type tag of union type.
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
std::vector< view_itemt > viewt
View of the key-value pairs in the map.
bool empty() const
Check if map is empty.
sorted_viewt get_sorted_view() const
Convenience function to get a sorted view of the map elements.
std::optional< std::reference_wrapper< const mapped_type > > find(const key_type &k) const
Find element.
void insert_or_replace(const key_type &k, valueU &&m)
void get_view(V &view) const
Get a view of the elements in the map A view is a list of pairs with the components being const refer...
Structure type, corresponds to C style structs.
Base type for structs and unions.
const componentst & components() const
The Boolean constant true.
The type of an expression, extends irept.
An abstraction of a structure that stores one abstract object per field.
bool visit_map(mapt &map, const visitort &visitor)
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
#define PRECONDITION(CONDITION)
API to expression classes.
const member_exprt & to_member_expr(const exprt &expr)
Cast an exprt to a member_exprt.
const struct_typet & to_struct_type(const typet &type)
Cast a typet to a struct_typet.
const struct_union_typet & to_struct_union_type(const typet &type)
Cast a typet to a struct_union_typet.
const struct_tag_typet & to_struct_tag_type(const typet &type)
Cast a typet to a struct_tag_typet.
const struct_or_union_tag_typet & to_struct_or_union_tag_type(const typet &type)
Cast a typet to a struct_or_union_tag_typet.
Pure virtual interface required of a client that can apply a copy-on-write operation to a given abstr...
abstract_object_pointert object