51 id.starts_with(
"value_set::dynamic_object") ||
52 id ==
"value_set::return_value" ||
id ==
"value_set::memory")
56 return type.
id() == ID_struct || type.
id() == ID_struct_tag;
62 return !found.has_value() ? nullptr : &(found->get());
79 if(existing_entry.has_value())
109 auto entry=dest.
read().find(n);
111 if(entry==dest.
read().end())
116 else if(!entry->second)
118 else if(offset && *entry->second == *offset)
133 auto &new_offset = dest.
write()[n];
149 display_name = id2string(e.identifier) + e.suffix;
152 else if(e.
identifier ==
"value_set::return_value")
154 display_name =
"RETURN_VALUE" + e.suffix;
160 const symbolt &symbol=ns.lookup(e.identifier);
161 display_name=id2string(symbol.display_name())+e.suffix;
162 identifier=symbol.name;
164 identifier = id2string(e.identifier);
165 display_name = id2string(identifier) + e.suffix;
169 out << indent << display_name <<
" = { ";
173 std::size_t width = 0;
175 for(object_map_dt::const_iterator o_it = object_map.begin();
176 o_it != object_map.end();
179 const exprt &o = object_numbering[o_it->first];
181 std::ostringstream stream;
183 if(o.id() == ID_invalid || o.id() == ID_unknown)
187 stream <<
"<" << format(o) <<
", ";
190 stream << *o_it->second;
194 if(o.type().is_nil())
197 stream <<
", " << format(o.type());
202 const std::string result = stream.str();
204 width += result.size();
206 object_map_dt::const_iterator next(o_it);
209 if(next != object_map.end())
213 out <<
"\n" << std::string(indent.size(),
' ') <<
" ";
228 for(
const auto &values_entry : view)
235 value_entries.expr_set();
237 for(value_sett::expr_sett::const_iterator
238 e_it=expr_set.begin();
239 e_it!=expr_set.end();
242 std::string value_str=
258 if(
object.
id()==ID_invalid ||
259 object.
id()==ID_unknown)
271 return std::move(od);
282 for(
const auto &delta_entry : delta_view)
284 if(delta_entry.is_in_both_maps())
287 delta_entry.get_other_map_value().object_map,
288 delta_entry.m.object_map))
291 make_union(existing_entry.object_map, delta_entry.m.object_map);
310 for(
const auto &number_and_offset : src.
read())
314 dest, number_and_offset.first, number_and_offset.second) !=
328 for(object_map_dt::const_iterator it=src.
read().begin();
329 it!=src.
read().end();
345 if(expr.
id()==ID_pointer_offset)
354 for(object_map_dt::const_iterator
355 it=object_map.begin();
356 it!=object_map.end();
365 if(!ptr_offset.has_value())
368 *ptr_offset += *it->second;
370 if(mod && *ptr_offset != previous_offset)
374 previous_offset = *ptr_offset;
395 .map([&](
const object_map_dt::value_type &pair) {
return to_expr(pair); });
401 bool is_simplified)
const
407 bool includes_nondet_pointer =
false;
410 if(includes_nondet_pointer && expr.
type().
id() == ID_pointer)
432 const std::string &suffix,
const std::string &field)
437 suffix.compare(1, field.length(), field) == 0 &&
438 (suffix.length() == field.length() + 1 ||
439 suffix[field.length() + 1] ==
'.' ||
440 suffix[field.length() + 1] ==
'[');
444 const std::string &suffix,
const std::string &field)
448 "suffix should start with " + field);
449 return suffix.substr(field.length() + 1);
455 const std::string &suffix,
459 type.
id() != ID_pointer && type.
id() != ID_signedbv &&
460 type.
id() != ID_unsignedbv && type.
id() != ID_array &&
461 type.
id() != ID_struct && type.
id() != ID_struct_tag &&
462 type.
id() != ID_union && type.
id() != ID_union_tag)
471 return std::move(index);
473 const typet &followed_type = type.
id() == ID_struct_tag
475 : type.
id() == ID_union_tag
480 if(followed_type.
id() == ID_struct || followed_type.
id() == ID_union)
487 const irep_idt &first_component_name =
488 struct_union_type.
components().front().get_name();
494 return std::move(index);
501 return std::move(identifier);
509 bool &includes_nondet_pointer,
510 const std::string &suffix,
511 const typet &original_type,
515 std::cout <<
"GET_VALUE_SET_REC EXPR: " <<
format(expr) <<
"\n";
516 std::cout <<
"GET_VALUE_SET_REC SUFFIX: " << suffix <<
'\n';
519 if(expr.
id()==ID_unknown || expr.
id()==ID_invalid)
523 else if(expr.
id()==ID_index)
528 type.
id() == ID_array,
"operand 0 of index expression must be an array");
533 includes_nondet_pointer,
538 else if(expr.
id()==ID_member)
543 compound.
type().
id() == ID_struct ||
544 compound.
type().
id() == ID_struct_tag ||
545 compound.
type().
id() == ID_union ||
546 compound.
type().
id() == ID_union_tag,
547 "compound of member expression must be struct or union");
549 const std::string &component_name=
555 includes_nondet_pointer,
556 "." + component_name + suffix,
560 else if(expr.
id()==ID_symbol)
565 if(entry_index.has_value())
570 else if(expr.
id() == ID_nondet_symbol)
572 if(expr.
type().
id() == ID_pointer)
573 includes_nondet_pointer =
true;
577 else if(expr.
id()==ID_if)
582 includes_nondet_pointer,
589 includes_nondet_pointer,
594 else if(expr.
id()==ID_address_of)
598 else if(expr.
id()==ID_dereference)
604 if(object_map.begin()==object_map.end())
608 for(object_map_dt::const_iterator
609 it1=object_map.begin();
610 it1!=object_map.end();
617 object, dest, includes_nondet_pointer, suffix, original_type, ns);
632 expr.
type().
id() == ID_unsignedbv || expr.
type().
id() == ID_signedbv)
640 else if(expr.
id()==ID_typecast)
645 const typet &op_type = op.type();
647 if(op_type.
id()==ID_pointer)
651 op, dest, includes_nondet_pointer, suffix, original_type, ns);
654 op_type.
id() == ID_unsignedbv || op_type.
id() == ID_signedbv ||
655 op_type.
id() == ID_bv)
669 op, tmp, includes_nondet_pointer, suffix, original_type, ns);
671 if(tmp.
read().empty())
676 else if(tmp.
read().size()==1 &&
693 expr.
id() == ID_plus || expr.
id() == ID_minus || expr.
id() == ID_bitor ||
694 expr.
id() == ID_bitand || expr.
id() == ID_bitxor ||
695 expr.
id() == ID_bitnand || expr.
id() == ID_bitnor ||
696 expr.
id() == ID_bitxnor)
699 throw expr.
id_string()+
" expected to have at least two operands";
702 std::optional<mp_integer> i;
705 std::optional<exprt> ptr_operand;
707 expr.
type().
id() == ID_pointer &&
708 (expr.
id() == ID_plus || expr.
id() == ID_minus))
710 bool non_const_offset =
false;
711 for(
const auto &op : expr.
operands())
713 if(op.type().id() == ID_pointer)
715 if(ptr_operand.has_value())
723 else if(!non_const_offset)
725 auto offset = numeric_cast<mp_integer>(op);
726 if(!offset.has_value())
729 non_const_offset =
true;
740 if(ptr_operand.has_value() && i.has_value())
742 typet pointer_base_type =
744 if(pointer_base_type.
id() == ID_empty)
749 if(!size.has_value() || (*size) == 0)
757 if(expr.
id()==ID_minus)
761 "unexpected subtraction of pointer from integer");
768 if(ptr_operand.has_value())
773 includes_nondet_pointer,
781 for(
const auto &op : expr.
operands())
784 op, pointer_expr_set, includes_nondet_pointer,
"", op.type(), ns);
788 for(object_map_dt::const_iterator
789 it=pointer_expr_set.
read().begin();
790 it!=pointer_expr_set.
read().end();
796 if(offset && i.has_value())
801 insert(dest, it->first, offset);
804 else if(expr.
id()==ID_mult)
810 throw expr.
id_string()+
" expected to have at least two operands";
815 for(
const auto &op : expr.
operands())
818 op, pointer_expr_set, includes_nondet_pointer,
"", op.type(), ns);
821 for(object_map_dt::const_iterator
822 it=pointer_expr_set.
read().begin();
823 it!=pointer_expr_set.
read().end();
831 insert(dest, it->first, offset);
834 else if(expr.
id() == ID_lshr || expr.
id() == ID_ashr || expr.
id() == ID_shl)
842 includes_nondet_pointer,
847 for(
const auto &object_map_entry : pointer_expr_set.
read())
849 offsett offset = object_map_entry.second;
854 insert(dest, object_map_entry.first, offset);
857 else if(expr.
id()==ID_side_effect)
861 if(statement==ID_function_call)
864 throw "unexpected function_call sideeffect";
866 else if(statement==ID_allocate)
870 const typet &dynamic_type=
871 static_cast<const typet &
>(expr.
find(ID_C_cxx_alloc_type));
879 else if(statement==ID_cpp_new ||
880 statement==ID_cpp_new_array)
895 else if(expr.
id()==ID_struct)
897 const auto &struct_components =
898 expr.
type().
id() == ID_struct_tag
902 struct_components.size() == expr.
operands().size(),
903 "struct expression should have an operand per component");
904 auto component_iter = struct_components.begin();
905 bool found_component =
false;
909 for(
const auto &op : expr.
operands())
911 const std::string &component_name =
915 std::string remaining_suffix =
920 includes_nondet_pointer,
924 found_component =
true;
934 for(
const auto &op : expr.
operands())
937 op, dest, includes_nondet_pointer, suffix, original_type, ns);
941 else if(expr.
id() == ID_union)
946 includes_nondet_pointer,
951 else if(expr.
id()==ID_with)
958 (expr.
type().
id() == ID_struct_tag || expr.
type().
id() == ID_struct) &&
965 std::string remaining_suffix =
970 includes_nondet_pointer,
976 (expr.
type().
id() == ID_struct &&
978 (expr.
type().
id() == ID_struct_tag &&
986 includes_nondet_pointer,
999 includes_nondet_pointer,
1006 includes_nondet_pointer,
1012 else if(expr.
type().
id() == ID_array && !suffix.
empty())
1014 std::string new_value_suffix;
1016 new_value_suffix = suffix.substr(2);
1024 includes_nondet_pointer,
1031 includes_nondet_pointer,
1043 includes_nondet_pointer,
1050 includes_nondet_pointer,
1056 else if(expr.
id()==ID_array)
1059 std::string new_suffix = suffix;
1061 new_suffix = suffix.substr(2);
1065 for(
const auto &op : expr.
operands())
1068 op, dest, includes_nondet_pointer, new_suffix, original_type, ns);
1071 else if(expr.
id()==ID_array_of)
1074 std::string new_suffix = suffix;
1076 new_suffix = suffix.substr(2);
1083 includes_nondet_pointer,
1088 else if(expr.
id()==ID_dynamic_object)
1093 const std::string prefix=
1094 "value_set::dynamic_object"+
1098 const std::string full_name=prefix+suffix;
1112 else if(expr.
id()==ID_byte_extract_little_endian ||
1113 expr.
id()==ID_byte_extract_big_endian)
1120 byte_extract_expr.op().type().id() == ID_struct ||
1121 byte_extract_expr.op().type().id() == ID_struct_tag)
1123 exprt offset = byte_extract_expr.offset();
1127 const auto offset_int = numeric_cast<mp_integer>(offset);
1131 byte_extract_expr.op().type().
id() == ID_struct_tag
1135 for(
const auto &c : struct_type.
components())
1137 const irep_idt &name = c.get_name();
1139 if(offset_int.has_value())
1142 if(comp_offset.has_value())
1145 type_size.has_value() && *offset_int + *type_size <= *comp_offset)
1152 member_size.has_value() &&
1153 *offset_int >= *comp_offset + *member_size)
1164 member, dest, includes_nondet_pointer, suffix, original_type, ns);
1169 byte_extract_expr.op().type().id() == ID_union ||
1170 byte_extract_expr.op().type().id() == ID_union_tag)
1173 const auto &components =
1174 byte_extract_expr.op().type().id() == ID_union_tag
1178 for(
const auto &c : components)
1180 const irep_idt &name = c.get_name();
1181 member_exprt member(byte_extract_expr.op(), name, c.type());
1183 member, dest, includes_nondet_pointer, suffix, original_type, ns);
1190 byte_extract_expr.op(),
1192 includes_nondet_pointer,
1197 else if(expr.
id()==ID_byte_update_little_endian ||
1198 expr.
id()==ID_byte_update_big_endian)
1204 byte_update_expr.op(),
1206 includes_nondet_pointer,
1211 byte_update_expr.value(),
1213 includes_nondet_pointer,
1220 else if(expr.
id() == ID_let)
1225 value_sett value_set_with_local_definition = *
this;
1226 value_set_with_local_definition.
assign(
1227 let_expr.symbol(), let_expr.value(), ns,
false,
false);
1232 includes_nondet_pointer,
1237 else if(
auto eb = expr_try_dynamic_cast<extractbits_exprt>(expr))
1243 includes_nondet_pointer,
1248 for(
const auto &object_map_entry : pointer_expr_set.
read())
1250 offsett offset = object_map_entry.second;
1255 insert(dest, object_map_entry.first, offset);
1261 for(
const auto &op : expr.
operands())
1264 op, pointer_expr_set, includes_nondet_pointer,
"", original_type, ns);
1267 for(
const auto &object_map_entry : pointer_expr_set.
read())
1269 offsett offset = object_map_entry.second;
1274 insert(dest, object_map_entry.first, offset);
1277 if(pointer_expr_set.
read().empty())
1282 std::cout <<
"GET_VALUE_SET_REC RESULT:\n";
1283 for(
const auto &obj : dest.
read())
1286 std::cout <<
" " <<
format(e) <<
"\n";
1297 if(src.
id()==ID_typecast)
1315 for(object_map_dt::const_iterator
1316 it=object_map.
read().begin();
1317 it!=object_map.
read().end();
1328 std::cout <<
"GET_REFERENCE_SET_REC EXPR: " <<
format(expr)
1332 if(expr.
id()==ID_symbol ||
1333 expr.
id()==ID_dynamic_object ||
1334 expr.
id()==ID_string_constant ||
1335 expr.
id()==ID_array)
1338 expr.
type().
id() == ID_array &&
1346 else if(expr.
id()==ID_dereference)
1350 bool includes_nondet_pointer =
false;
1352 pointer, dest, includes_nondet_pointer,
"", pointer.type(), ns);
1355 for(
const auto &map_entry : dest.
read())
1364 else if(expr.
id()==ID_index)
1367 throw "index expected to have two operands";
1374 array.
type().
id() == ID_array,
"index takes array-typed operand");
1383 for(object_map_dt::const_iterator
1384 a_it=object_map.begin();
1385 a_it!=object_map.end();
1390 if(
object.
id()==ID_unknown)
1399 const auto i = numeric_cast<mp_integer>(offset);
1404 else if(i.has_value() && o)
1408 if(!size.has_value() || *size == 0)
1416 insert(dest, deref_index_expr, o);
1422 else if(expr.
id()==ID_member)
1424 const irep_idt &component_name=expr.
get(ID_component_name);
1433 for(object_map_dt::const_iterator
1434 it=object_map.begin();
1435 it!=object_map.end();
1440 if(
object.
id()==ID_unknown)
1443 object.type().
id() == ID_struct ||
1444 object.type().
id() == ID_struct_tag ||
object.type().
id() == ID_union ||
1445 object.type().
id() == ID_union_tag)
1455 object.type().
id() == ID_struct ||
1456 object.type().
id() == ID_struct_tag ||
1457 object.type().
id() == ID_union ||
object.type().
id() == ID_union_tag)
1460 if(struct_op.
type() !=
object.type())
1466 insert(dest, member_expr, o);
1477 else if(expr.
id()==ID_if)
1495 std::cout <<
"ASSIGN LHS: " <<
format(lhs) <<
" : "
1497 std::cout <<
"ASSIGN RHS: " <<
format(rhs) <<
" : "
1499 std::cout <<
"--------------------------------------------\n";
1503 if(lhs.
type().
id() == ID_struct || lhs.
type().
id() == ID_struct_tag)
1505 const auto &components =
1506 lhs.
type().
id() == ID_struct_tag
1510 for(
const auto &c : components)
1512 const typet &subtype = c.type();
1513 const irep_idt &name = c.get_name();
1517 subtype.
id() != ID_code,
"struct member must not be of code type");
1518 if(c.get_is_padding())
1525 if(rhs.
id()==ID_unknown ||
1526 rhs.
id()==ID_invalid)
1531 rhs_member=
exprt(rhs.
id(), subtype);
1537 "value_sett::assign types should match, got: "
1541 if(rhs.
type().
id() == ID_struct_tag || rhs.
type().
id() == ID_union_tag)
1549 assign(lhs_member, rhs_member, ns,
true, add_to_sets);
1551 else if(rhs.
type().
id() == ID_struct || rhs.
type().
id() == ID_union)
1559 assign(lhs_member, rhs_member, ns,
true, add_to_sets);
1564 else if(lhs.
type().
id() == ID_array)
1571 if(rhs.
id()==ID_unknown ||
1572 rhs.
id()==ID_invalid)
1585 "value_sett::assign types should match, got: "
1589 if(rhs.
id()==ID_array_of)
1600 for(
const auto &op : rhs.
operands())
1602 assign(lhs_index, op, ns, is_simplified, add_to_sets);
1606 else if(rhs.
id()==ID_with)
1613 assign(lhs_index, op0_index, ns, is_simplified, add_to_sets);
1615 lhs_index,
to_with_expr(rhs).new_value(), ns, is_simplified,
true);
1623 assign(lhs_index, rhs_index, ns, is_simplified,
true);
1638 assign_rec(lhs, values_rhs,
"", ns, add_to_sets);
1645 const std::string &suffix,
1650 std::cout <<
"ASSIGN_REC LHS: " <<
format(lhs) <<
'\n';
1651 std::cout <<
"ASSIGN_REC LHS ID: " << lhs.
id() <<
'\n';
1652 std::cout <<
"ASSIGN_REC SUFFIX: " << suffix <<
'\n';
1654 for(object_map_dt::const_iterator it=values_rhs.
read().begin();
1655 it!=values_rhs.
read().end();
1657 std::cout <<
"ASSIGN_REC RHS: " <<
1662 if(lhs.
id()==ID_symbol)
1667 entryt{identifier, suffix}, lhs.
type(), values_rhs, add_to_sets);
1669 else if(lhs.
id()==ID_dynamic_object)
1674 const std::string name=
1675 "value_set::dynamic_object"+
1680 else if(lhs.
id()==ID_dereference)
1683 throw lhs.
id_string()+
" expected to have one operand";
1688 if(reference_set.
read().size()!=1)
1691 for(object_map_dt::const_iterator
1692 it=reference_set.
read().begin();
1693 it!=reference_set.
read().end();
1700 if(
object.
id()!=ID_unknown)
1701 assign_rec(
object, values_rhs, suffix, ns, add_to_sets);
1704 else if(lhs.
id()==ID_index)
1708 const typet &type = array.type();
1711 type.
id() == ID_array,
"operand 0 of index expression must be an array");
1713 assign_rec(array, values_rhs,
"[]" + suffix, ns,
true);
1715 else if(lhs.
id()==ID_member)
1718 const auto &component_name = lhs_member_expr.get_component_name();
1719 const exprt &compound = lhs_member_expr.compound();
1722 compound.
type().
id() == ID_struct ||
1723 compound.
type().
id() == ID_struct_tag ||
1724 compound.
type().
id() == ID_union ||
1725 compound.
type().
id() == ID_union_tag,
1726 "operand 0 of member expression must be struct or union");
1731 "." +
id2string(component_name) + suffix,
1735 else if(lhs.
id()==
"valid_object" ||
1736 lhs.
id()==
"dynamic_type" ||
1737 lhs.
id()==
"is_zero_string" ||
1738 lhs.
id()==
"zero_string" ||
1739 lhs.
id()==
"zero_string_length")
1743 else if(lhs.
id()==ID_string_constant)
1748 else if(lhs.
id() == ID_null_object)
1752 else if(lhs.
id()==ID_typecast)
1756 assign_rec(typecast_expr.
op(), values_rhs, suffix, ns, add_to_sets);
1758 else if(lhs.
id()==ID_byte_extract_little_endian ||
1759 lhs.
id()==ID_byte_extract_big_endian)
1763 else if(lhs.
id()==ID_integer_address)
1769 throw "assign NYI: '" + lhs.
id_string() +
"'";
1787 for(std::size_t i=0; i<arguments.size(); i++)
1789 const std::string identifier=
"value_set::dummy_arg_"+
std::to_string(i);
1790 const symbol_exprt dummy_lhs(identifier, arguments[i].type());
1791 assign(dummy_lhs, arguments[i], ns,
false,
false);
1798 for(code_typet::parameterst::const_iterator
1799 it=parameter_types.begin();
1800 it!=parameter_types.end();
1803 const irep_idt &identifier=it->get_identifier();
1804 if(identifier.
empty())
1811 assign(actual_lhs, v_expr, ns,
true,
true);
1827 assign(lhs, rhs, ns,
false,
false);
1836 if(statement==ID_block)
1838 for(
const auto &op : code.
operands())
1841 else if(statement==ID_function_call)
1846 else if(statement==ID_assign)
1849 throw "assignment expected to have two operands";
1853 else if(statement==ID_decl)
1856 throw "decl expected to have one operand";
1860 if(lhs.
id()!=ID_symbol)
1861 throw "decl expected to have symbol on lhs";
1866 lhs_type.
id() == ID_pointer ||
1867 (lhs_type.
id() == ID_array &&
1874 assign(lhs, address_of_expr, ns,
false,
false);
1880 else if(statement==ID_expression)
1884 else if(statement == ID_cpp_delete || statement == ID_cpp_delete_array)
1888 else if(statement==
"lock" || statement==
"unlock")
1892 else if(statement==ID_asm)
1896 else if(statement==ID_nondet)
1900 else if(statement==ID_printf)
1904 else if(statement==ID_return)
1912 else if(statement==ID_array_set)
1915 else if(statement==ID_array_copy)
1918 else if(statement==ID_array_replace)
1921 else if(statement == ID_array_equal)
1924 else if(statement==ID_assume)
1928 else if(statement==ID_user_specified_predicate ||
1929 statement==ID_user_specified_parameter_predicates ||
1930 statement==ID_user_specified_return_predicates)
1934 else if(statement==ID_fence)
1941 else if(statement==ID_dead)
1945 else if(statement == ID_havoc_object)
1951 throw "value_sett: unexpected statement: "+
id2string(statement);
1959 if(expr.
id()==ID_and)
1961 for(
const auto &op : expr.
operands())
1964 else if(expr.
id()==ID_equal)
1967 else if(expr.
id()==ID_notequal)
1970 else if(expr.
id()==ID_not)
1973 else if(expr.
id()==ID_dynamic_object)
1989 const std::unordered_set<exprt, irep_hash> &values_to_erase)
1991 if(values_to_erase.empty())
1998 std::vector<object_map_dt::key_type> keys_to_erase;
2000 for(
auto &key_value : entry->object_map.read())
2002 const auto &rhs_object =
to_expr(key_value);
2003 if(values_to_erase.count(rhs_object))
2005 keys_to_erase.emplace_back(key_value.first);
2010 keys_to_erase.size() == values_to_erase.size(),
2011 "value_sett::erase_value_from_entry() should erase exactly one value for "
2012 "each element in the set it is given");
2014 entryt replacement = *entry;
2015 for(
const auto &key_to_erase : keys_to_erase)
2024 const std::string &erase_prefix,
2027 for(
const auto &c : struct_union_type.
components())
2029 const typet &subtype = c.type();
2030 const irep_idt &name = c.get_name();
2034 subtype.
id() != ID_code,
"struct/union member must not be of code type");
2035 if(c.get_is_padding())
2044 const std::string &erase_prefix,
2047 if(type.
id() == ID_struct_tag)
2050 else if(type.
id() == ID_union_tag)
2053 else if(type.
id() == ID_array)
2055 to_array_type(type).element_type(), erase_prefix +
"[]", ns);
std::optional< symbol_exprt > get_failed_symbol(const symbol_exprt &expr, const namespacet &ns)
Get the failed-dereference symbol for the given symbol.
API to expression classes for bitvectors.
Expression classes for byte-level operators.
const byte_update_exprt & to_byte_update_expr(const exprt &expr)
const byte_extract_exprt & to_byte_extract_expr(const exprt &expr)
unsignedbv_typet unsigned_char_type()
bitvector_typet char_type()
bitvector_typet c_index_type()
const union_tag_typet & to_union_tag_type(const typet &type)
Cast a typet to a union_tag_typet.
const union_typet & to_union_type(const typet &type)
Cast a typet to a union_typet.
Operator to return the address of an object.
const typet & element_type() const
The type of the elements of the array.
A base class for binary expressions.
goto_instruction_codet representation of a "return from a function" statement.
const exprt & return_value() const
std::vector< parametert > parameterst
const parameterst & parameters() const
Data structure for representing an arbitrary statement in a program.
const irep_idt & get_statement() const
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
bool starts_with(const char *s) const
equivalent of as_string().starts_with(s)
Representation of heap-allocated objects.
unsigned int get_instance() const
void set_instance(unsigned int instance)
Base class for all expressions.
std::vector< exprt > operandst
bool is_zero() const
Return whether the expression is a constant representing 0.
typet & type()
Return the type of the expression.
bool is_constant() const
Return whether the expression is a constant.
std::string pretty(unsigned indent=0, unsigned max_indent=0) const
const irept & find(const irep_idt &name) const
const irep_idt & get(const irep_idt &name) const
const std::string & id_string() const
const irep_idt & id() const
const std::string & get_string(const irep_idt &name) const
Extract member of struct or union.
const exprt & compound() const
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...
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See documentation for namespace_baset::lookup().
Split an expression into a base object and a (byte) offset.
const typet & base_type() const
The type of the data what we point to.
std::vector< view_itemt > viewt
View of the key-value pairs in the map.
void insert(const key_type &k, valueU &&m)
Insert element, element must not exist in map.
void iterate(std::function< void(const key_type &k, const mapped_type &m)> f) const
Call a function for every key-value pair in the map.
void erase(const key_type &k)
Erase element, element must exist in map.
bool has_key(const key_type &k) const
Check if key is in map.
void replace(const key_type &k, valueU &&m)
Replace element, element must exist in map.
std::vector< delta_view_itemt > delta_viewt
Delta view of the key-value pairs in two maps.
std::optional< std::reference_wrapper< const mapped_type > > find(const key_type &k) const
Find element.
void get_delta_view(const sharing_mapt &other, delta_viewt &delta_view, const bool only_common=true) const
Get a delta view of the elements in the map.
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...
void update(const key_type &k, std::function< void(mapped_type &)> mutator)
Update an element in place; element must exist in map.
const irep_idt & get_statement() const
Structure type, corresponds to C style structs.
Base type for structs and unions.
const typet & component_type(const irep_idt &component_name) const
bool has_component(const irep_idt &component_name) const
const componentst & components() const
Expression to hold a symbol (variable)
const irep_idt & get_identifier() const
typet type
Type of symbol.
The Boolean constant true.
Semantic type conversion.
static exprt conditional_cast(const exprt &expr, const typet &type)
The type of an expression, extends irept.
std::list< exprt > valuest
State type in value_set_domaint, used in value-set analysis and goto-symex.
virtual void apply_code_rec(const codet &code, const namespacet &ns)
Subclass customisation point for applying code to this domain:
bool eval_pointer_offset(exprt &expr, const namespacet &ns) const
Tries to resolve any pointer_offset_exprt expressions in expr to constant integers using this value-s...
const entryt * find_entry(const irep_idt &id) const
Finds an entry in this value-set.
std::vector< exprt > get_value_set(exprt expr, const namespacet &ns) const
Gets values pointed to by expr, including following dereference operators (i.e.
virtual void get_value_set_rec(const exprt &expr, object_mapt &dest, bool &includes_nondet_pointer, const std::string &suffix, const typet &original_type, const namespacet &ns) const
Subclass customisation point for recursion over RHS expression.
xmlt output_xml(void) const
Output the value set formatted as XML.
void output(std::ostream &out, const std::string &indent="") const
Pretty-print this value-set.
void dereference_rec(const exprt &src, exprt &dest) const
Sets dest to src with any wrapping typecasts removed.
void erase_symbol(const symbol_exprt &symbol_expr, const namespacet &ns)
valuest values
Stores the LHS ID -> RHS expression set map.
unsigned location_number
Matches the location_number field of the instruction that corresponds to this value_sett instance in ...
static object_numberingt object_numbering
Global shared object numbering, used to abbreviate expressions stored in value sets.
bool insert(object_mapt &dest, const object_map_dt::value_type &it) const
Merges an existing element into an object map.
void erase_struct_union_symbol(const struct_union_typet &struct_union_type, const std::string &erase_prefix, const namespacet &ns)
std::optional< mp_integer > offsett
Represents the offset into an object: either a unique integer offset, or an unknown value,...
void get_reference_set_rec(const exprt &expr, object_mapt &dest, const namespacet &ns) const
See get_reference_set.
exprt to_expr(const object_map_dt::value_type &it) const
Converts an object_map_dt element object_number -> offset into an object_descriptor_exprt with ....
void erase_values_from_entry(const irep_idt &index, const std::unordered_set< exprt, irep_hash > &values_to_erase)
Update the entry stored at index by erasing any values listed in values_to_erase.
void update_entry(const entryt &e, const typet &type, const object_mapt &new_values, bool add_to_sets)
Adds or replaces an entry in this value-set.
void assign(const exprt &lhs, const exprt &rhs, const namespacet &ns, bool is_simplified, bool add_to_sets)
Transforms this value-set by executing executing the assignment lhs := rhs against it.
virtual void assign_rec(const exprt &lhs, const object_mapt &values_rhs, const std::string &suffix, const namespacet &ns, bool add_to_sets)
Subclass customisation point for recursion over LHS expression:
insert_actiont get_insert_action(const object_mapt &dest, object_numberingt::number_type n, const offsett &offset) const
Determines what would happen if object number n was inserted into map dest with offset offset – the p...
bool make_union(object_mapt &dest, const object_mapt &src) const
Merges two RHS expression sets.
virtual bool field_sensitive(const irep_idt &id, const typet &type)
Determines whether an identifier of a given type should have its fields distinguished.
void guard(const exprt &expr, const namespacet &ns)
Transforms this value-set by assuming an expression holds.
bool make_union_would_change(const object_mapt &dest, const object_mapt &src) const
Determines whether merging two RHS expression sets would cause any change.
void do_end_function(const exprt &lhs, const namespacet &ns)
Transforms this value-set by assigning this function's return value to a given LHS expression.
static const object_map_dt empty_object_map
void do_function_call(const irep_idt &function, const exprt::operandst &arguments, const namespacet &ns)
Transforms this value-set by executing the actual -> formal parameter assignments for a particular ca...
void get_reference_set(const exprt &expr, value_setst::valuest &dest, const namespacet &ns) const
Gets the set of expressions that expr may refer to, according to this value set.
virtual void apply_assign_side_effects(const exprt &lhs, const exprt &rhs, const namespacet &)
Subclass customisation point to apply global side-effects to this domain, after RHS values are read b...
std::map< object_numberingt::number_type, offsett > object_map_dt
Represents a set of expressions (exprt instances) with corresponding offsets (offsett instances).
virtual void adjust_assign_rhs_values(const exprt &rhs, const namespacet &, object_mapt &rhs_values) const
Subclass customisation point to filter or otherwise alter the value-set returned from get_value_set b...
std::optional< irep_idt > get_index_of_symbol(irep_idt identifier, const typet &type, const std::string &suffix, const namespacet &ns) const
Get the index of the symbol and suffix.
void erase_symbol_rec(const typet &type, const std::string &erase_prefix, const namespacet &ns)
Operator to update elements in structs and arrays.
xmlt & new_element(const std::string &key)
static void escape(const std::string &s, std::ostream &out)
escaping for XML elements
std::unordered_set< exprt, irep_hash > expr_sett
bool has_prefix(const std::string &s, const std::string &prefix)
#define Forall_operands(it, expr)
bool is_null_pointer(const constant_exprt &expr)
Returns true if expr has a pointer type and a value NULL; it also returns true when expr has value ze...
Deprecated expression utility functions.
const code_returnt & to_code_return(const goto_instruction_codet &code)
bool can_cast_expr< code_inputt >(const exprt &base)
bool can_cast_expr< code_outputt >(const exprt &base)
const std::string & id2string(const irep_idt &d)
std::string from_expr(const namespacet &ns, const irep_idt &identifier, const exprt &expr)
API to expression classes for Pointers.
const pointer_offset_exprt & to_pointer_offset_expr(const exprt &expr)
Cast an exprt to a pointer_offset_exprt.
const dereference_exprt & to_dereference_expr(const exprt &expr)
Cast an exprt to a dereference_exprt.
const pointer_typet & to_pointer_type(const typet &type)
Cast a typet to a pointer_typet.
const dynamic_object_exprt & to_dynamic_object_expr(const exprt &expr)
Cast an exprt to a dynamic_object_exprt.
const address_of_exprt & to_address_of_expr(const exprt &expr)
Cast an exprt to an address_of_exprt.
std::optional< mp_integer > compute_pointer_offset(const exprt &expr, const namespacet &ns)
std::optional< mp_integer > member_offset(const struct_typet &type, const irep_idt &member, const namespacet &ns)
std::optional< mp_integer > pointer_offset_size(const typet &type, const namespacet &ns)
Compute the size of a type in bytes, rounding up to full bytes.
Ranges: pair of begin and end iterators, which can be initialized from containers,...
ranget< iteratort > make_range(iteratort begin, iteratort end)
bool simplify(exprt &expr, const namespacet &ns)
exprt simplify_expr(exprt src, const namespacet &ns)
#define UNREACHABLE
This should be used to mark dead code.
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
#define PRECONDITION(CONDITION)
#define INVARIANT(CONDITION, REASON)
This macro uses the wrapper function 'invariant_violated_string'.
side_effect_exprt & to_side_effect_expr(exprt &expr)
const code_assumet & to_code_assume(const codet &code)
const codet & to_code(const exprt &expr)
const if_exprt & to_if_expr(const exprt &expr)
Cast an exprt to an if_exprt.
const let_exprt & to_let_expr(const exprt &expr)
Cast an exprt to a let_exprt.
const constant_exprt & to_constant_expr(const exprt &expr)
Cast an exprt to a constant_exprt.
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
const typecast_exprt & to_typecast_expr(const exprt &expr)
Cast an exprt to a typecast_exprt.
const union_exprt & to_union_expr(const exprt &expr)
Cast an exprt to a union_exprt.
const minus_exprt & to_minus_expr(const exprt &expr)
Cast an exprt to a minus_exprt.
const with_exprt & to_with_expr(const exprt &expr)
Cast an exprt to a with_exprt.
const binary_exprt & to_binary_expr(const exprt &expr)
Cast an exprt to a binary_exprt.
const array_of_exprt & to_array_of_expr(const exprt &expr)
Cast an exprt to an array_of_exprt.
const member_exprt & to_member_expr(const exprt &expr)
Cast an exprt to a member_exprt.
const index_exprt & to_index_expr(const exprt &expr)
Cast an exprt to an index_exprt.
const struct_typet & to_struct_type(const typet &type)
Cast a typet to a struct_typet.
const code_typet & to_code_type(const typet &type)
Cast a typet to a code_typet.
const array_typet & to_array_type(const typet &type)
Cast a typet to an array_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.
std::string to_string(const string_not_contains_constraintt &expr)
Used for debug printing.
Represents a row of a value_sett.
static bool failed(bool error_indicator)
static std::string strip_first_field_from_suffix(const std::string &suffix, const std::string &field)
static bool suffix_starts_with_field(const std::string &suffix, const std::string &field)
Check if 'suffix' starts with 'field'.