41 if(type.
id() == ID_struct_tag)
43 else if(type.
id() == ID_struct)
54 const typet &type,
const std::string &tag)
64 if(type.
id()==ID_pointer)
95 if(type.
id()==ID_pointer)
118 if(type.
id()==ID_pointer)
141 if(type.
id()==ID_pointer)
164 if(type.
id()==ID_pointer)
183 std::vector<irep_idt>
190 std::vector<irep_idt> bases;
196 class_name ==
"java.lang.StringBuilder" ||
197 class_name ==
"java.lang.StringBuffer")
198 bases.push_back(
"java.lang.AbstractStringBuilder");
200 bases.push_back(
"java.lang.Object");
203 if(class_name !=
"java.lang.CharSequence")
205 bases.push_back(
"java.io.Serializable");
206 bases.push_back(
"java.lang.CharSequence");
208 if(class_name ==
"java.lang.String")
209 bases.push_back(
"java.lang.Comparable");
222 tmp_string_symbol.
name = class_symbol_name;
223 symbolt *string_symbol =
nullptr;
224 bool already_exists = symbol_table.
move(tmp_string_symbol, string_symbol);
238 new_string_type.
set_tag(class_name);
239 new_string_type.
set_name(class_symbol_name);
243 for(
const irep_idt &base_name : bases)
249 string_symbol->
type = new_string_type;
251 string_symbol->
mode = ID_java;
256 string_type.components().resize(3);
260 string_type.components()[0].set_name(supertype_component_name);
261 string_type.components()[0].set_pretty_name(supertype_component_name);
262 string_type.components()[0].type() = supertype;
263 string_type.components()[1].set_name(
"length");
264 string_type.components()[1].set_pretty_name(
"length");
266 string_type.components()[2].set_name(
"data");
267 string_type.components()[2].set_pretty_name(
"data");
287 for(
const auto &p : params)
288 ops.emplace_back(
symbol_exprt(p.get_identifier(), p.type()));
309 const exprt &expr_to_process,
319 string_expr, expr_to_process, loc, symbol_table, init_code);
344 for(
const auto &p : operands)
351 p, loc, symbol_table, function_id, init_code));
370 if(type.
id() == ID_struct_tag)
390 if(type.
id() == ID_struct_tag)
430 const exprt &array_pointer,
441 array_data.
type(),
"char_array", loc, function_id, symbol_table);
454 string_expr.
content(), inf_array, symbol_table, loc, function_id, code);
492 index_type,
"cprover_string_length", loc, function_id, symbol_table);
496 array_type,
"cprover_string_content", loc, function_id, symbol_table);
523 const exprt nondet_array_expr =
530 array_pointer, nondet_array_expr, symbol_table, loc, function_id, code);
533 nondet_array_expr, str.
length(), symbol_table, loc, function_id, code);
584 function_id, arguments, lhs.
type(), symbol_table));
622 "nondet_infinite_array_pointer",
633 return std::move(
data);
645 const exprt &pointer,
655 java_int_type(),
"return_array", loc, function_id, symbol_table);
661 ID_cprover_associate_array_to_pointer_func,
684 java_int_type(),
"return_array", loc, function_id, symbol_table);
690 ID_cprover_associate_length_to_array_func,
708 const exprt &pointer,
718 java_int_type(),
"cnstr_added", loc, function_id, symbol_table);
725 ID_cprover_string_constrain_characters_func,
726 {length, pointer, char_set_expr},
757 std::string(
"return_code_") + function_id.
c_str(),
761 const auto return_code = return_code_sym.
symbol_expr();
769 args.push_back(string_expr.
length());
770 args.push_back(string_expr.
content());
771 args.insert(args.end(), arguments.begin(), arguments.end());
776 return_code, function_id, args, symbol_table),
796 const exprt &rhs_array,
797 const exprt &rhs_length,
814 {zero_base_object, rhs_length, rhs_array}, deref.
type());
873 rhs_length.set(ID_mode, ID_java);
893 const std::string &s,
899 ID_cprover_string_literal_func,
920 (void)message_handler;
933 type.
return_type(), loc, function_id, symbol_table, code);
942 std::vector<exprt> condition_list;
943 std::vector<refined_string_exprt> string_expr_list;
948 ID_cprover_string_of_float_scientific_notation_func,
953 string_expr_list.push_back(sci_notation);
960 ID_cprover_string_concat_func,
961 {minus_sign, sci_notation},
965 string_expr_list.push_back(neg_sci_notation);
971 string_expr_list.push_back(nan);
978 string_expr_list.push_back(infinity);
984 string_expr_list.push_back(minus_infinity);
992 string_expr_list.push_back(zero_string);
1000 string_expr_list.push_back(minus_zero_string);
1014 condition_list.push_back(is_simple_float);
1017 ID_cprover_string_of_float_func, {arg}, loc, symbol_table, code);
1018 string_expr_list.push_back(simple_notation);
1024 condition_list.push_back(is_neg_simple_float);
1027 ID_cprover_string_concat_func,
1028 {minus_sign, simple_notation},
1032 string_expr_list.push_back(neg_simple_notation);
1036 string_expr_list.size()==condition_list.size(),
1037 "number of created strings should correspond to number of conditions");
1042 str, string_expr_list[0], symbol_table,
true);
1043 for(std::size_t i=1; i<condition_list.size(); i++)
1048 str, string_expr_list[i], symbol_table,
true),
1051 code.
add(tmp_code, loc);
1087 params.erase(params.begin());
1151 function_id, type, loc, symbol_table,
false);
1187 ID_cprover_string_literal_func,
1196 ID_cprover_string_substring_func,
1205 string_ptr_type, loc, function_id, symbol_table, code);
1208 string1, string_expr1, symbol_table,
true),
1237 function_id, args, type.
return_type(), symbol_table),
1275 type.
return_type(), loc, function_id, symbol_table, code);
1278 str, string_expr, symbol_table,
true),
1308 (void)message_handler;
1322 string_expr, arg0, loc, symbol_table, code);
1326 type.
return_type(), loc, function_id, symbol_table, code);
1329 str, string_expr, symbol_table,
true),
1358 (void)message_handler;
1372 string_expr, arg1, loc, symbol_table, copy_constructor_body);
1376 copy_constructor_body.
add(
1378 arg_this, string_expr, symbol_table,
true),
1381 return copy_constructor_body;
1404 (void)message_handler;
1421 if(map->count(function_id) != 0)
1427 template <
typename TMap,
typename TContainer>
1431 std::is_same<
typename TMap::key_type,
1432 typename TContainer::value_type>::value,
1433 "TContainer value_type doesn't match TMap key_type");
1437 std::inserter(container, container.begin()),
1438 [](
const typename TMap::value_type &pair) { return pair.first; });
1442 std::unordered_set<irep_idt> &methods)
const
1472 it_id->second, type, loc, symbol_table);
1477 it_id->second, type, loc, symbol_table);
1482 it_id->second, type, loc, symbol_table);
1487 it_id->second, type, loc, symbol_table);
1493 return it->second(type, loc, function_id, symbol_table, message_handler);
1508 string_types = std::unordered_set<irep_idt>{
"java.lang.String",
1509 "java.lang.StringBuilder",
1510 "java.lang.CharSequence",
1511 "java.lang.StringBuffer"};
1526 [
"java::org.cprover.CProverString.append:(Ljava/lang/StringBuilder;Ljava/"
1527 "lang/CharSequence;II)"
1528 "Ljava/lang/StringBuilder;"] = ID_cprover_string_concat_func;
1532 [
"java::org.cprover.CProverString.charAt:(Ljava/lang/String;I)C"] =
1533 ID_cprover_string_char_at_func;
1535 [
"java::org.cprover.CProverString.charAt:(Ljava/lang/StringBuffer;I)C"] =
1536 ID_cprover_string_char_at_func;
1538 [
"java::org.cprover.CProverString.codePointAt:(Ljava/lang/String;I)I"] =
1539 ID_cprover_string_code_point_at_func;
1541 [
"java::org.cprover.CProverString.codePointBefore:(Ljava/lang/String;I)I"] =
1542 ID_cprover_string_code_point_before_func;
1544 [
"java::org.cprover.CProverString.codePointCount:(Ljava/lang/String;II)I"] =
1545 ID_cprover_string_code_point_count_func;
1547 [
"java::org.cprover.CProverString.delete:(Ljava/lang/StringBuffer;II)Ljava/"
1548 "lang/StringBuffer;"] = ID_cprover_string_delete_func;
1550 [
"java::org.cprover.CProverString.delete:(Ljava/lang/"
1551 "StringBuilder;II)Ljava/lang/StringBuilder;"] =
1552 ID_cprover_string_delete_func;
1554 [
"java::org.cprover.CProverString.deleteCharAt:(Ljava/lang/"
1555 "StringBuffer;I)Ljava/lang/StringBuffer;"] =
1556 ID_cprover_string_delete_char_at_func;
1558 [
"java::org.cprover.CProverString.deleteCharAt:(Ljava/lang/"
1559 "StringBuilder;I)Ljava/lang/StringBuilder;"] =
1560 ID_cprover_string_delete_char_at_func;
1562 std::string format_signature =
"java::org.cprover.CProverString.format:(";
1564 format_signature +=
"Ljava/lang/String;";
1565 format_signature +=
")Ljava/lang/String;";
1567 ID_cprover_string_format_func;
1570 [
"java::org.cprover.CProverString.insert:(Ljava/lang/StringBuilder;ILjava/"
1571 "lang/String;)Ljava/lang/StringBuilder;"] = ID_cprover_string_insert_func;
1573 [
"java::org.cprover.CProverString.offsetByCodePoints:(Ljava/lang/"
1574 "String;II)I"] = ID_cprover_string_offset_by_code_point_func;
1576 [
"java::org.cprover.CProverString.setCharAt:(Ljava/lang/"
1577 "StringBuffer;IC)V"] = ID_cprover_string_char_set_func;
1579 [
"java::org.cprover.CProverString.setCharAt:(Ljava/lang/"
1580 "StringBuilder;IC)V"] = ID_cprover_string_char_set_func;
1582 [
"java::org.cprover.CProverString.setLength:(Ljava/lang/StringBuffer;I)V"] =
1583 ID_cprover_string_set_length_func;
1585 [
"java::org.cprover.CProverString.setLength:(Ljava/lang/"
1586 "StringBuilder;I)V"] = ID_cprover_string_set_length_func;
1588 [
"java::org.cprover.CProverString.subSequence:(Ljava/lang/String;II)Ljava/"
1589 "lang/CharSequence;"] = ID_cprover_string_substring_func;
1593 [
"java::org.cprover.CProverString.substring:(Ljava/lang/String;I)"
1594 "Ljava/lang/String;"] = ID_cprover_string_substring_func;
1596 [
"java::org.cprover.CProverString.substring:(Ljava/lang/String;II)"
1597 "Ljava/lang/String;"] = ID_cprover_string_substring_func;
1599 [
"java::org.cprover.CProverString.substring:(Ljava/Lang/"
1600 "StringBuffer;II)Ljava/lang/String;"] = ID_cprover_string_substring_func;
1602 [
"java::org.cprover.CProverString.toString:(I)Ljava/lang/String;"] =
1603 ID_cprover_string_of_int_func;
1605 [
"java::org.cprover.CProverString.toString:(II)Ljava/lang/String;"] =
1606 ID_cprover_string_of_int_func;
1608 [
"java::org.cprover.CProverString.toString:(J)Ljava/lang/String;"] =
1609 ID_cprover_string_of_long_func;
1611 [
"java::org.cprover.CProverString.toString:(JI)Ljava/lang/String;"] =
1612 ID_cprover_string_of_long_func;
1614 [
"java::org.cprover.CProverString.toString:(F)Ljava/lang/String;"] =
1618 std::placeholders::_1,
1619 std::placeholders::_2,
1620 std::placeholders::_3,
1621 std::placeholders::_4,
1622 std::placeholders::_5);
1624 [
"java::org.cprover.CProverString.parseInt:(Ljava/lang/String;I)I"] =
1625 ID_cprover_string_parse_int_func;
1627 [
"java::org.cprover.CProverString.parseLong:(Ljava/lang/String;I)J"] =
1628 ID_cprover_string_parse_int_func;
1630 [
"java::org.cprover.CProverString.isValidInt:(Ljava/lang/String;I)Z"] =
1631 ID_cprover_string_is_valid_int_func;
1633 [
"java::org.cprover.CProverString.isValidLong:(Ljava/lang/String;I)Z"] =
1634 ID_cprover_string_is_valid_long_func;
1641 std::placeholders::_1,
1642 std::placeholders::_2,
1643 std::placeholders::_3,
1644 std::placeholders::_4,
1645 std::placeholders::_5);
1647 [
"java::java.lang.String.<init>:(Ljava/lang/StringBuilder;)V"] = std::bind(
1650 std::placeholders::_1,
1651 std::placeholders::_2,
1652 std::placeholders::_3,
1653 std::placeholders::_4,
1654 std::placeholders::_5);
1656 [
"java::java.lang.String.<init>:()V"]=
1657 ID_cprover_string_empty_string_func;
1660 [
"java::java.lang.String.compareTo:(Ljava/lang/String;)I"]=
1661 ID_cprover_string_compare_to_func;
1663 [
"java::java.lang.String.concat:(Ljava/lang/String;)Ljava/lang/String;"]=
1664 ID_cprover_string_concat_func;
1666 [
"java::java.lang.String.contains:(Ljava/lang/CharSequence;)Z"]=
1667 ID_cprover_string_contains_func;
1669 [
"java::java.lang.String.endsWith:(Ljava/lang/String;)Z"]=
1670 ID_cprover_string_endswith_func;
1672 [
"java::java.lang.String.equalsIgnoreCase:(Ljava/lang/String;)Z"]=
1673 ID_cprover_string_equals_ignore_case_func;
1676 [
"java::java.lang.String.indexOf:(I)I"]=
1677 ID_cprover_string_index_of_func;
1679 [
"java::java.lang.String.indexOf:(II)I"]=
1680 ID_cprover_string_index_of_func;
1682 [
"java::java.lang.String.indexOf:(Ljava/lang/String;)I"]=
1683 ID_cprover_string_index_of_func;
1685 [
"java::java.lang.String.indexOf:(Ljava/lang/String;I)I"]=
1686 ID_cprover_string_index_of_func;
1688 [
"java::java.lang.String.isEmpty:()Z"]=
1689 ID_cprover_string_is_empty_func;
1691 [
"java::java.lang.String.lastIndexOf:(I)I"]=
1692 ID_cprover_string_last_index_of_func;
1694 [
"java::java.lang.String.lastIndexOf:(II)I"]=
1695 ID_cprover_string_last_index_of_func;
1697 [
"java::java.lang.String.lastIndexOf:(Ljava/lang/String;)I"]=
1698 ID_cprover_string_last_index_of_func;
1700 [
"java::java.lang.String.lastIndexOf:(Ljava/lang/String;I)I"]=
1701 ID_cprover_string_last_index_of_func;
1705 std::placeholders::_1,
1706 std::placeholders::_2,
1707 std::placeholders::_3,
1708 std::placeholders::_4,
1709 std::placeholders::_5);
1711 [
"java::java.lang.String.replace:(CC)Ljava/lang/String;"]=
1712 ID_cprover_string_replace_func;
1714 [
"java::java.lang.String.replace:(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String;"]=
1715 ID_cprover_string_replace_func;
1717 [
"java::java.lang.String.startsWith:(Ljava/lang/String;)Z"]=
1718 ID_cprover_string_startswith_func;
1720 [
"java::java.lang.String.startsWith:(Ljava/lang/String;I)Z"]=
1721 ID_cprover_string_startswith_func;
1723 [
"java::java.lang.String.toLowerCase:()Ljava/lang/String;"]=
1724 ID_cprover_string_to_lower_case_func;
1729 std::placeholders::_1,
1730 std::placeholders::_2,
1731 std::placeholders::_3,
1732 std::placeholders::_4,
1733 std::placeholders::_5);
1735 [
"java::java.lang.String.toUpperCase:()Ljava/lang/String;"]=
1736 ID_cprover_string_to_upper_case_func;
1738 [
"java::java.lang.String.trim:()Ljava/lang/String;"]=
1739 ID_cprover_string_trim_func;
1743 [
"java::java.lang.StringBuilder.<init>:(Ljava/lang/String;)V"] = std::bind(
1746 std::placeholders::_1,
1747 std::placeholders::_2,
1748 std::placeholders::_3,
1749 std::placeholders::_4,
1750 std::placeholders::_5);
1752 [
"java::java.lang.StringBuilder.<init>:(Ljava/lang/CharSequence;)V"] =
1756 std::placeholders::_1,
1757 std::placeholders::_2,
1758 std::placeholders::_3,
1759 std::placeholders::_4,
1760 std::placeholders::_5);
1762 [
"java::java.lang.StringBuilder.<init>:()V"]=
1763 ID_cprover_string_empty_string_func;
1765 [
"java::java.lang.StringBuilder.<init>:(I)V"] =
1766 ID_cprover_string_empty_string_func;
1769 [
"java::java.lang.StringBuilder.append:(C)Ljava/lang/StringBuilder;"]=
1770 ID_cprover_string_concat_char_func;
1772 [
"java::java.lang.StringBuilder.append:(Ljava/lang/CharSequence;)"
1773 "Ljava/lang/StringBuilder;"] = ID_cprover_string_concat_func;
1775 [
"java::java.lang.StringBuilder.append:(Ljava/lang/String;)"
1776 "Ljava/lang/StringBuilder;"] = ID_cprover_string_concat_func;
1778 [
"java::java.lang.StringBuilder.append:(Ljava/lang/StringBuffer;)"
1779 "Ljava/lang/StringBuilder;"] = ID_cprover_string_concat_func;
1781 [
"java::java.lang.StringBuilder.appendCodePoint:(I)"
1782 "Ljava/lang/StringBuilder;"]=
1783 ID_cprover_string_concat_code_point_func;
1785 [
"java::java.lang.StringBuilder.charAt:(I)C"]=
1786 ID_cprover_string_char_at_func;
1788 [
"java::java.lang.StringBuilder.codePointAt:(I)I"]=
1789 ID_cprover_string_code_point_at_func;
1791 [
"java::java.lang.StringBuilder.codePointBefore:(I)I"]=
1792 ID_cprover_string_code_point_before_func;
1794 [
"java::java.lang.StringBuilder.codePointCount:(II)I"]=
1795 ID_cprover_string_code_point_count_func;
1799 std::placeholders::_1,
1800 std::placeholders::_2,
1801 std::placeholders::_3,
1802 std::placeholders::_4,
1803 std::placeholders::_5);
1805 [
"java::java.lang.StringBuilder.substring:(II)Ljava/lang/String;"]=
1806 ID_cprover_string_substring_func;
1808 [
"java::java.lang.StringBuilder.substring:(I)Ljava/lang/String;"]=
1809 ID_cprover_string_substring_func;
1811 [
"java::java.lang.StringBuilder.toString:()Ljava/lang/String;"] = std::bind(
1814 std::placeholders::_1,
1815 std::placeholders::_2,
1816 std::placeholders::_3,
1817 std::placeholders::_4,
1818 std::placeholders::_5);
1822 [
"java::java.lang.StringBuffer.<init>:(Ljava/lang/String;)V"] = std::bind(
1825 std::placeholders::_1,
1826 std::placeholders::_2,
1827 std::placeholders::_3,
1828 std::placeholders::_4,
1829 std::placeholders::_5);
1831 [
"java::java.lang.StringBuffer.<init>:()V"]=
1832 ID_cprover_string_empty_string_func;
1835 [
"java::java.lang.StringBuffer.append:(C)Ljava/lang/StringBuffer;"]=
1836 ID_cprover_string_concat_char_func;
1838 [
"java::java.lang.StringBuffer.append:(Ljava/lang/String;)"
1839 "Ljava/lang/StringBuffer;"]=
1840 ID_cprover_string_concat_func;
1842 [
"java::java.lang.StringBuffer.append:(Ljava/lang/StringBuffer;)"
1843 "Ljava/lang/StringBuffer;"] = ID_cprover_string_concat_func;
1845 [
"java::java.lang.StringBuffer.appendCodePoint:(I)"
1846 "Ljava/lang/StringBuffer;"]=
1847 ID_cprover_string_concat_code_point_func;
1849 [
"java::java.lang.StringBuffer.codePointAt:(I)I"]=
1850 ID_cprover_string_code_point_at_func;
1852 [
"java::java.lang.StringBuffer.codePointBefore:(I)I"]=
1853 ID_cprover_string_code_point_before_func;
1855 [
"java::java.lang.StringBuffer.codePointCount:(II)I"]=
1856 ID_cprover_string_code_point_count_func;
1858 [
"java::java.lang.StringBuffer.length:()I"]=
1861 [
"java::java.lang.StringBuffer.substring:(I)Ljava/lang/String;"]=
1862 ID_cprover_string_substring_func;
1864 [
"java::java.lang.StringBuffer.toString:()Ljava/lang/String;"] = std::bind(
1867 std::placeholders::_1,
1868 std::placeholders::_2,
1869 std::placeholders::_3,
1870 std::placeholders::_4,
1871 std::placeholders::_5);
1875 [
"java::java.lang.CharSequence.charAt:(I)C"]=
1876 ID_cprover_string_char_at_func;
1878 [
"java::java.lang.CharSequence.toString:()Ljava/lang/String;"] = std::bind(
1881 std::placeholders::_1,
1882 std::placeholders::_2,
1883 std::placeholders::_3,
1884 std::placeholders::_4,
1885 std::placeholders::_5);
1887 [
"java::java.lang.CharSequence.length:()I"]=
1892 [
"java::java.lang.Integer.toHexString:(I)Ljava/lang/String;"]=
1893 ID_cprover_string_of_int_hex_func;
1895 [
"java::org.cprover.CProver.classIdentifier:("
1896 "Ljava/lang/Object;)Ljava/lang/String;"] =
1900 std::placeholders::_1,
1901 std::placeholders::_2,
1902 std::placeholders::_3,
1903 std::placeholders::_4,
1904 std::placeholders::_5);
static abstract_object_pointert transform(const exprt &expr, const std::vector< abstract_object_pointert > &operands, const abstract_environmentt &environment, const namespacet &ns)
code_frontend_assignt make_allocate_code(const symbol_exprt &lhs, const exprt &size)
Create code allocating an object of size size and assigning it to lhs
void base_type(typet &type, const namespacet &ns)
API to expression classes for bitvectors.
const floatbv_typet & to_floatbv_type(const typet &type)
Cast a typet to a floatbv_typet.
pointer_typet pointer_type(const typet &subtype)
void set_class_identifier(struct_exprt &expr, const namespacet &ns, const struct_tag_typet &class_type)
If expr has its components filled in then sets the @class_identifier member of the struct.
Extract class identifier.
#define JAVA_CLASS_IDENTIFIER_FIELD_NAME
Operator to return the address of an object.
exprt allocate_dynamic_object(code_blockt &output_code, const exprt &target_expr, const typet &allocate_type)
Generate the same code as allocate_dynamic_object_symbol, but return a dereference_exprt that derefer...
void declare_created_symbols(code_blockt &init_code)
Adds declarations for all non-static symbols created.
const exprt & size() const
A base class for relations, i.e., binary predicates whose two operands have the same type.
void initialize_conversion_table()
fill maps with correspondance from java method names to conversion functions
A codet representing an assignment in the program.
An assumption, which must hold in subsequent code.
A codet representing sequential composition of program statements.
void append(const code_blockt &extra_block)
Add all the codets from extra_block to the current code_blockt.
void add(const codet &code)
A codet representing the declaration of a local variable.
codet representation of an if-then-else statement.
codet representation of a "return from a function" statement.
const irep_idt & get_identifier() const
std::vector< parametert > parameterst
const typet & return_type() const
const parameterst & parameters() const
Data structure for representing an arbitrary statement in a program.
A constant literal expression.
Operator to dereference a pointer.
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
const char * c_str() const
Base class for all expressions.
std::vector< exprt > operandst
source_locationt & add_source_location()
typet & type()
Return the type of the expression.
constant_exprt to_expr() const
void from_float(const float f)
void change_spec(const ieee_float_spect &dest_spec)
The trinary if-then-else operator.
An expression denoting infinity.
const irep_idt & id() const
Evaluates to true if the operand is infinite.
Evaluates to true if the operand is NaN.
void set_name(const irep_idt &name)
Set the name of the struct, which can be used to look up its symbol in the symbol table.
void set_access(const irep_idt &access)
const componentst & components() const
code_blockt make_float_to_string_code(const java_method_typet &type, const source_locationt &loc, const irep_idt &function_id, symbol_table_baset &symbol_table, message_handlert &message_handler)
Provide code for the String.valueOf(F) function.
std::unordered_map< irep_idt, irep_idt > id_mapt
code_blockt make_string_returning_function_from_call(const irep_idt &function_id, const java_method_typet &type, const source_locationt &loc, symbol_table_baset &symbol_table)
Provide code for a function that calls a function from the solver and return the string_expr result a...
code_returnt make_string_length_code(const java_method_typet &type, const source_locationt &loc, const irep_idt &function_id, symbol_table_baset &symbol_table, message_handlert &message_handler)
Generates code for the String.length method.
const refined_string_typet refined_string_type
refined_string_exprt string_literal_to_string_expr(const std::string &s, const source_locationt &loc, symbol_table_baset &symbol_table, code_blockt &code)
Create a string expression whose value is given by a literal.
codet code_assign_components_to_java_string(const exprt &lhs, const exprt &rhs_array, const exprt &rhs_length, const symbol_table_baset &symbol_table, bool is_constructor)
Produce code for an assignment of a string expr to a Java string.
refined_string_exprt convert_exprt_to_string_exprt(const exprt &deref, const source_locationt &loc, symbol_table_baset &symbol_table, const irep_idt &function_name, code_blockt &init_code)
Creates a string_exprt from the input exprt representing a char sequence.
id_mapt cprover_equivalent_to_java_string_returning_function
void add_string_type(const irep_idt &class_name, symbol_tablet &symbol_table)
Add to the symbol table type declaration for a String-like Java class.
code_blockt make_assign_and_return_function_from_call(const irep_idt &function_id, const java_method_typet &type, const source_locationt &loc, symbol_table_baset &symbol_table)
Call a cprover internal function, assign the result to object this and return it.
void get_all_function_names(std::unordered_set< irep_idt > &methods) const
static bool implements_java_char_sequence_pointer(const typet &type)
id_mapt cprover_equivalent_to_java_assign_and_return_function
std::unordered_map< irep_idt, conversion_functiont > conversion_table
refined_string_exprt string_expr_of_function(const irep_idt &function_id, const exprt::operandst &arguments, const source_locationt &loc, symbol_table_baset &symbol_table, code_blockt &code)
Create a refined_string_exprt str whose content and length are fresh symbols, calls the string primit...
code_blockt make_class_identifier_code(const java_method_typet &type, const source_locationt &loc, const irep_idt &function_id, symbol_table_baset &symbol_table, message_handlert &message_handler)
Used to provide our own implementation of the CProver.classIdentifier() function.
static bool is_java_char_sequence_type(const typet &type)
static bool is_java_string_buffer_type(const typet &type)
bool implements_function(const irep_idt &function_id) const
code_blockt make_copy_string_code(const java_method_typet &type, const source_locationt &loc, const irep_idt &function_id, symbol_table_baset &symbol_table, message_handlert &message_handler)
Generates code for a function which copies a string object to a new string object.
std::vector< irep_idt > get_string_type_base_classes(const irep_idt &class_name)
Gets the base classes for known String and String-related types, or returns an empty list for other t...
static bool is_java_char_array_pointer_type(const typet &type)
id_mapt cprover_equivalent_to_java_function
refined_string_exprt make_nondet_string_expr(const source_locationt &loc, const irep_idt &function_id, symbol_table_baset &symbol_table, code_blockt &code)
add symbols with prefix cprover_string_length and cprover_string_data and construct a string_expr fro...
code_blockt make_assign_function_from_call(const irep_idt &function_id, const java_method_typet &type, const source_locationt &loc, symbol_table_baset &symbol_table)
Call a cprover internal function and assign the result to object this.
exprt allocate_fresh_string(const typet &type, const source_locationt &loc, const irep_idt &function_id, symbol_table_baset &symbol_table, code_blockt &code)
declare a new String and allocate it
static bool is_java_string_pointer_type(const typet &type)
refined_string_exprt replace_char_array(const exprt &array_pointer, const source_locationt &loc, const irep_idt &function_name, symbol_table_baset &symbol_table, code_blockt &code)
we declare a new cprover_string whose contents is deduced from the char array.
static bool is_java_string_builder_pointer_type(const typet &type)
exprt::operandst process_parameters(const java_method_typet::parameterst ¶ms, const source_locationt &loc, const irep_idt &function_name, symbol_table_baset &symbol_table, code_blockt &init_code)
calls string_refine_preprocesst::process_operands with a list of parameters.
static bool is_java_char_sequence_pointer_type(const typet &type)
id_mapt cprover_equivalent_to_java_constructor
static bool is_java_char_array_type(const typet &type)
code_blockt make_init_function_from_call(const irep_idt &function_id, const java_method_typet &type, const source_locationt &loc, symbol_table_baset &symbol_table, bool is_constructor=true)
Generate the goto code for string initialization.
character_refine_preprocesst character_preprocess
static bool is_java_string_builder_type(const typet &type)
code_blockt make_function_from_call(const irep_idt &function_id, const java_method_typet &type, const source_locationt &loc, symbol_table_baset &symbol_table)
Provide code for a function that calls a function from the solver and simply returns it.
bool is_known_string_type(irep_idt class_name)
Check whether a class name is known as a string type.
std::unordered_set< irep_idt > string_types
codet code_assign_string_expr_to_java_string(const exprt &lhs, const refined_string_exprt &rhs, const symbol_table_baset &symbol_table, bool is_constructor)
Produce code for an assignemnt of a string expr to a Java string.
static bool is_java_string_buffer_pointer_type(const typet &type)
codet code_return_function_application(const irep_idt &function_id, const exprt::operandst &arguments, const typet &type, symbol_table_baset &symbol_table)
return the result of a function call
symbol_exprt fresh_string(const typet &type, const source_locationt &loc, const irep_idt &function_id, symbol_table_baset &symbol_table)
add a symbol with static lifetime and name containing cprover_string and given type
code_blockt make_copy_constructor_code(const java_method_typet &type, const source_locationt &loc, const irep_idt &function_id, symbol_table_baset &symbol_table, message_handlert &message_handler)
Generates code for a constructor of a string object from another string object.
id_mapt cprover_equivalent_to_java_assign_function
void initialize_conversion_table()
fill maps with correspondence from java method names to conversion functions
exprt::operandst process_operands(const exprt::operandst &operands, const source_locationt &loc, const irep_idt &function_name, symbol_table_baset &symbol_table, code_blockt &init_code)
for each expression that is of a type implementing strings, we declare a new cprover_string whose con...
static bool is_java_string_type(const typet &type)
const std::array< id_mapt *, 5 > id_maps
codet code_for_function(const symbolt &symbol, symbol_table_baset &symbol_table, message_handlert &message_handler)
Should be called to provide code for string functions that are used in the code but for which no impl...
static bool java_type_matches_tag(const typet &type, const std::string &tag)
void initialize_known_type_table()
refined_string_exprt decl_string_expr(const source_locationt &loc, const irep_idt &function_id, symbol_table_baset &symbol_table, code_blockt &code)
Add declaration of a refined string expr whose content and length are fresh symbols.
void code_assign_java_string_to_string_expr(const refined_string_exprt &lhs, const exprt &rhs, const source_locationt &loc, const symbol_table_baset &symbol_table, code_blockt &code)
Extract member of struct or union.
const typet & follow(const typet &) const
Resolve type symbol to the type it points to.
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
The null pointer constant.
The pointer type These are both 'bitvector_typet' (they have a width) and 'type_with_subtypet' (they ...
const typet & base_type() const
The type of the data what we point to.
const exprt & length() const
const exprt & content() const
A side_effect_exprt that returns a non-deterministically chosen value.
Struct constructor from list of elements.
A struct tag type, i.e., struct_typet with an identifier.
Structure type, corresponds to C style structs.
void add_base(const struct_tag_typet &base)
Add a base class/struct.
const typet & component_type(const irep_idt &component_name) const
void set_tag(const irep_idt &tag)
const componentst & components() const
Expression to hold a symbol (variable)
const irep_idt & get_identifier() const
The symbol table base class interface.
const symbolt & lookup_ref(const irep_idt &name) const
Find a symbol in the symbol table for read-only access.
virtual bool move(symbolt &symbol, symbolt *&new_symbol) override
Move a symbol into the symbol table.
irep_idt base_name
Base (non-scoped) name.
source_locationt location
Source code location of definition of symbol.
class symbol_exprt symbol_expr() const
Produces a symbol_exprt for a symbol.
typet type
Type of symbol.
irep_idt name
The unique identifier.
irep_idt pretty_name
Language-specific display name.
irep_idt mode
Language mode.
const irep_idt & get_identifier() const
The type of an expression, extends irept.
const typet & subtype() const
The unary minus expression.
optionalt< exprt > zero_initializer(const typet &type, const source_locationt &source_location, const namespacet &ns)
Create the equivalent of zero for type type.
Expression Initialization.
API to expression classes for floating-point arithmetic.
const std::string & id2string(const irep_idt &d)
static bool is_constructor(const irep_idt &method_name)
static irep_idt get_tag(const typet &type)
static const typet & get_length_type(const typet &type, const symbol_tablet &symbol_table)
Finds the type of the length component.
static const typet & get_data_type(const typet &type, const symbol_tablet &symbol_table)
Finds the type of the data component.
static typet string_length_type()
void add_keys_to_container(const TMap &map, TContainer &container)
void add_character_set_constraint(const exprt &pointer, const exprt &length, const irep_idt &char_range, symbol_table_baset &symbol_table, const source_locationt &loc, const irep_idt &function_id, code_blockt &code)
Add a call to a primitive of the string solver which ensures all characters belong to the character s...
static codet code_assign_function_application(const exprt &lhs, const irep_idt &function_id, const exprt::operandst &arguments, symbol_table_baset &symbol_table)
assign the result of a function call
void add_array_to_length_association(const exprt &array, const exprt &length, symbol_table_baset &symbol_table, const source_locationt &loc, const irep_idt &function_id, code_blockt &code)
Add a call to a primitive of the string solver, letting it know that the actual length of array is le...
exprt make_nondet_infinite_char_array(symbol_table_baset &symbol_table, const source_locationt &loc, const irep_idt &function_id, code_blockt &code)
Declare a fresh symbol of type array of character with infinite size.
static exprt get_length(const exprt &expr, const symbol_tablet &symbol_table)
access length member
static exprt get_data(const exprt &expr, const symbol_tablet &symbol_table)
access data member
void add_pointer_to_array_association(const exprt &pointer, const exprt &array, symbol_table_baset &symbol_table, const source_locationt &loc, const irep_idt &function_id, code_blockt &code)
Add a call to a primitive of the string solver, letting it know that pointer points to the first char...
Produce code for simple implementation of String Java libraries.
signedbv_typet java_int_type()
unsignedbv_typet java_char_type()
const java_class_typet & to_java_class_type(const typet &type)
const java_method_typet & to_java_method_type(const typet &type)
symbolt & fresh_java_symbol(const typet &type, const std::string &basename_prefix, const source_locationt &source_location, const irep_idt &function_name, symbol_table_baset &symbol_table)
dereference_exprt checked_dereference(const exprt &expr)
Dereference an expression and flag it for a null-pointer check.
exprt make_function_application(const irep_idt &function_name, const exprt::operandst &arguments, const typet &range, symbol_table_baset &symbol_table)
Create a (mathematical) function application expression.
const pointer_typet & to_pointer_type(const typet &type)
Cast a typet to a pointer_typet.
Type for string expressions used by the string solver.
static optionalt< smt_termt > get_identifier(const exprt &expr, const std::unordered_map< exprt, smt_identifier_termt, irep_hash > &expression_handle_identifiers, const std::unordered_map< exprt, smt_identifier_termt, irep_hash > &expression_identifiers)
#define CHECK_RETURN(CONDITION)
#define PRECONDITION(CONDITION)
const struct_exprt & to_struct_expr(const exprt &expr)
Cast an exprt to a struct_exprt.
const struct_typet & to_struct_type(const typet &type)
Cast a typet to a struct_typet.
const struct_tag_typet & to_struct_tag_type(const typet &type)
Cast a typet to a struct_tag_typet.
String expressions for the string solver.