Skip to content

Commit c6a220c

Browse files
Merge pull request #2374 from romainbrenguier/clean-up/preprocessing
Cleanup in string preprocessing
2 parents 8b5b51d + f6c3023 commit c6a220c

File tree

3 files changed

+1
-118
lines changed

3 files changed

+1
-118
lines changed

jbmc/src/java_bytecode/java_string_library_preprocess.cpp

Lines changed: 0 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -168,18 +168,6 @@ bool java_string_library_preprocesst::is_java_char_array_pointer_type(
168168
return false;
169169
}
170170

171-
/// \param symbol_table: a symbol_table containing an entry for java Strings
172-
/// \return the type of data fields in java Strings.
173-
typet string_data_type(const symbol_tablet &symbol_table)
174-
{
175-
symbolt sym=*symbol_table.lookup("java::java.lang.String");
176-
typet concrete_type=sym.type;
177-
struct_typet struct_type=to_struct_type(concrete_type);
178-
std::size_t index=struct_type.component_number("data");
179-
typet data_type=struct_type.components()[index].type();
180-
return data_type;
181-
}
182-
183171
/// \return the type of the length field in java Strings.
184172
typet string_length_type()
185173
{
@@ -589,26 +577,6 @@ exprt java_string_library_preprocesst::allocate_fresh_string(
589577
return str;
590578
}
591579

592-
/// declare a new character array and allocate it
593-
/// \param type: a type for string
594-
/// \param loc: a location in the program
595-
/// \param symbol_table: symbol table
596-
/// \param code: code block to which allocation instruction will be added
597-
/// \return a new array
598-
exprt java_string_library_preprocesst::allocate_fresh_array(
599-
const typet &type,
600-
const source_locationt &loc,
601-
const irep_idt &function_id,
602-
symbol_tablet &symbol_table,
603-
code_blockt &code)
604-
{
605-
exprt array=fresh_array(type, loc, symbol_table);
606-
code.add(code_declt(array), loc);
607-
allocate_dynamic_object_with_decl(
608-
array, symbol_table, loc, function_id, code);
609-
return array;
610-
}
611-
612580
/// assign the result of a function call
613581
/// \param lhs: an expression
614582
/// \param function_name: the name of the function
@@ -1719,55 +1687,6 @@ codet java_string_library_preprocesst::make_copy_constructor_code(
17191687
return code;
17201688
}
17211689

1722-
/// Used to provide code for constructor from a char array.
1723-
/// The implementation is similar to substring except the 3rd argument is a
1724-
/// count instead of end index
1725-
/// \param type: type of the function call
1726-
/// \param loc: location in the program_invocation_name
1727-
/// \param function_id: unused
1728-
/// \param symbol_table: symbol table
1729-
/// \return code implementing String intitialization from a char array and
1730-
/// arguments offset and end.
1731-
codet java_string_library_preprocesst::make_init_from_array_code(
1732-
const java_method_typet &type,
1733-
const source_locationt &loc,
1734-
const irep_idt &function_id,
1735-
symbol_table_baset &symbol_table)
1736-
{
1737-
(void)function_id;
1738-
1739-
// Code for the output
1740-
code_blockt code;
1741-
1742-
java_method_typet::parameterst params = type.parameters();
1743-
PRECONDITION(params.size() == 4);
1744-
exprt::operandst args =
1745-
process_parameters(type.parameters(), loc, symbol_table, code);
1746-
INVARIANT(
1747-
args.size() == 4, "process_parameters preserves number of arguments");
1748-
1749-
/// \todo this assumes the array to be constant between all calls to
1750-
/// string primitives, which may not be true in general.
1751-
refined_string_exprt string_arg = to_string_expr(args[1]);
1752-
1753-
// The third argument is `count`, whereas the third argument of substring
1754-
// is `end` which corresponds to `offset+count`
1755-
refined_string_exprt string_expr = string_expr_of_function(
1756-
ID_cprover_string_substring_func,
1757-
{args[1], args[2], plus_exprt(args[2], args[3])},
1758-
loc,
1759-
symbol_table,
1760-
code);
1761-
1762-
// Assign string_expr to `this` object
1763-
symbol_exprt arg_this(params[0].get_identifier(), params[0].type());
1764-
code.add(
1765-
code_assign_string_expr_to_java_string(arg_this, string_expr, symbol_table),
1766-
loc);
1767-
1768-
return code;
1769-
}
1770-
17711690
/// Generates code for the String.length method
17721691
/// \param type: type of the function
17731692
/// \param loc: location in the source
@@ -1922,13 +1841,6 @@ void java_string_library_preprocesst::initialize_conversion_table()
19221841
std::placeholders::_2,
19231842
std::placeholders::_3,
19241843
std::placeholders::_4);
1925-
conversion_table["java::java.lang.String.<init>:([CII)V"] = std::bind(
1926-
&java_string_library_preprocesst::make_init_from_array_code,
1927-
this,
1928-
std::placeholders::_1,
1929-
std::placeholders::_2,
1930-
std::placeholders::_3,
1931-
std::placeholders::_4);
19321844
cprover_equivalent_to_java_constructor
19331845
["java::java.lang.String.<init>:()V"]=
19341846
ID_cprover_string_empty_string_func;
@@ -1956,12 +1868,6 @@ void java_string_library_preprocesst::initialize_conversion_table()
19561868
cprover_equivalent_to_java_function
19571869
["java::java.lang.String.contains:(Ljava/lang/CharSequence;)Z"]=
19581870
ID_cprover_string_contains_func;
1959-
cprover_equivalent_to_java_string_returning_function
1960-
["java::java.lang.String.copyValueOf:([CII)Ljava/lang/String;"]=
1961-
ID_cprover_string_copy_func;
1962-
cprover_equivalent_to_java_string_returning_function
1963-
["java::java.lang.String.copyValueOf:([C)Ljava/lang/String;"]=
1964-
ID_cprover_string_copy_func;
19651871
cprover_equivalent_to_java_function
19661872
["java::java.lang.String.endsWith:(Ljava/lang/String;)Z"]=
19671873
ID_cprover_string_endswith_func;
@@ -2108,9 +2014,6 @@ void java_string_library_preprocesst::initialize_conversion_table()
21082014
cprover_equivalent_to_java_assign_and_return_function
21092015
["java::java.lang.StringBuilder.append:(C)Ljava/lang/StringBuilder;"]=
21102016
ID_cprover_string_concat_char_func;
2111-
cprover_equivalent_to_java_assign_and_return_function
2112-
["java::java.lang.StringBuilder.append:([C)Ljava/lang/StringBuilder;"] =
2113-
ID_cprover_string_concat_func;
21142017
cprover_equivalent_to_java_assign_and_return_function
21152018
["java::java.lang.StringBuilder.append:(D)Ljava/lang/StringBuilder;"] =
21162019
ID_cprover_string_concat_double_func;

jbmc/src/java_bytecode/java_string_library_preprocess.h

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ class java_string_library_preprocesst:public messaget
4343

4444
void initialize_known_type_table();
4545
void initialize_conversion_table();
46-
void initialize_refined_string_type();
4746

4847
bool implements_function(const irep_idt &function_id) const;
4948
void get_all_function_names(std::unordered_set<irep_idt> &methods) const;
@@ -151,12 +150,6 @@ class java_string_library_preprocesst:public messaget
151150
const irep_idt &function_id,
152151
symbol_table_baset &symbol_table);
153152

154-
codet make_string_to_char_array_code(
155-
const java_method_typet &type,
156-
const source_locationt &loc,
157-
const irep_idt &function_id,
158-
symbol_tablet &symbol_table);
159-
160153
codet make_string_format_code(
161154
const java_method_typet &type,
162155
const source_locationt &loc,
@@ -254,13 +247,6 @@ class java_string_library_preprocesst:public messaget
254247
symbol_table_baset &symbol_table,
255248
code_blockt &code);
256249

257-
exprt allocate_fresh_array(
258-
const typet &type,
259-
const source_locationt &loc,
260-
const irep_idt &function_id,
261-
symbol_tablet &symbol_table,
262-
code_blockt &code);
263-
264250
codet code_return_function_application(
265251
const irep_idt &function_name,
266252
const exprt::operandst &arguments,
@@ -346,12 +332,6 @@ class java_string_library_preprocesst:public messaget
346332
code_blockt &code);
347333

348334
exprt get_object_at_index(const exprt &argv, std::size_t index);
349-
350-
codet make_init_from_array_code(
351-
const java_method_typet &type,
352-
const source_locationt &loc,
353-
const irep_idt &function_id,
354-
symbol_table_baset &symbol_table);
355335
};
356336

357337
exprt make_nondet_infinite_char_array(

0 commit comments

Comments
 (0)