Skip to content

Commit 4b0e665

Browse files
committed
Java string preprocessing: use and document parameter function_id
1 parent 9c10f38 commit 4b0e665

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

jbmc/src/java_bytecode/java_string_library_preprocess.cpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,7 @@ refined_string_exprt java_string_library_preprocesst::decl_string_expr(
535535
/// add symbols with prefix cprover_string_length and cprover_string_data and
536536
/// construct a string_expr from them.
537537
/// \param loc: a location in the program
538+
/// \param function_id: name of the function containing the string
538539
/// \param symbol_table: symbol table
539540
/// \param code: code block to which allocation instruction will be added
540541
/// \return a new string_expr
@@ -648,6 +649,7 @@ codet java_string_library_preprocesst::code_return_function_application(
648649
/// Declare a fresh symbol of type array of character with infinite size.
649650
/// \param symbol_table: the symbol table
650651
/// \param loc: source location
652+
/// \param function_id: name of the function containing the array
651653
/// \param code [out] : code block where the declaration gets added
652654
/// \return created symbol expression
653655
exprt make_nondet_infinite_char_array(
@@ -660,7 +662,7 @@ exprt make_nondet_infinite_char_array(
660662
java_char_type(), infinity_exprt(java_int_type()));
661663
const symbolt data_sym = get_fresh_aux_symbol(
662664
array_type,
663-
"nondet_infinite_array",
665+
function_id,
664666
"nondet_infinite_array",
665667
loc,
666668
ID_java,
@@ -941,6 +943,7 @@ java_string_library_preprocesst::string_literal_to_string_expr(
941943
/// \param type: type of the function call
942944
/// \param loc: location in the program_invocation_name
943945
/// \param symbol_table: symbol table
946+
/// \param function_id: unused
944947
/// \return Code corresponding to:
945948
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
946949
/// IF arg->@class_identifier == "java.lang.String"
@@ -981,7 +984,7 @@ codet java_string_library_preprocesst::make_equals_function_code(
981984
code_blockt instance_case;
982985
// Check content equality
983986
const symbolt string_equals_sym = get_fresh_aux_symbol(
984-
return_type, "string_equals", "str_eq", loc, ID_java, symbol_table);
987+
return_type, function_id, "str_eq", loc, ID_java, symbol_table);
985988
const symbol_exprt string_equals = string_equals_sym.symbol_expr();
986989
instance_case.add(code_declt(string_equals), loc);
987990
const exprt::operandst args =
@@ -1736,6 +1739,7 @@ codet java_string_library_preprocesst::make_copy_string_code(
17361739
/// object.
17371740
/// \param type: type of the function
17381741
/// \param loc: location in the source
1742+
/// \param function_id: unused
17391743
/// \param symbol_table: symbol table
17401744
/// \return Code corresponding to:
17411745
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -1749,6 +1753,8 @@ codet java_string_library_preprocesst::make_copy_constructor_code(
17491753
const irep_idt &function_id,
17501754
symbol_table_baset &symbol_table)
17511755
{
1756+
(void)function_id;
1757+
17521758
// Code for the output
17531759
code_blockt code;
17541760

@@ -1775,6 +1781,7 @@ codet java_string_library_preprocesst::make_copy_constructor_code(
17751781
/// count instead of end index
17761782
/// \param type: type of the function call
17771783
/// \param loc: location in the program_invocation_name
1784+
/// \param function_id: unused
17781785
/// \param symbol_table: symbol table
17791786
/// \return code implementing String intitialization from a char array and
17801787
/// arguments offset and end.
@@ -1784,6 +1791,8 @@ codet java_string_library_preprocesst::make_init_from_array_code(
17841791
const irep_idt &function_id,
17851792
symbol_table_baset &symbol_table)
17861793
{
1794+
(void)function_id;
1795+
17871796
// Code for the output
17881797
code_blockt code;
17891798

@@ -1819,6 +1828,7 @@ codet java_string_library_preprocesst::make_init_from_array_code(
18191828
/// Generates code for the String.length method
18201829
/// \param type: type of the function
18211830
/// \param loc: location in the source
1831+
/// \param function_id: unused
18221832
/// \param symbol_table: symbol table
18231833
/// \return Code corresponding to:
18241834
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -1832,11 +1842,17 @@ codet java_string_library_preprocesst::make_string_length_code(
18321842
const irep_idt &function_id,
18331843
symbol_table_baset &symbol_table)
18341844
{
1845+
(void)function_id;
1846+
18351847
code_typet::parameterst params=type.parameters();
18361848
symbol_exprt arg_this(params[0].get_identifier(), params[0].type());
18371849
dereference_exprt deref=
18381850
checked_dereference(arg_this, arg_this.type().subtype());
1839-
return code_returnt(get_length(deref, symbol_table));
1851+
1852+
code_returnt ret(get_length(deref, symbol_table));
1853+
ret.add_source_location(loc);
1854+
1855+
return ret;
18401856
}
18411857

18421858
bool java_string_library_preprocesst::implements_function(

0 commit comments

Comments
 (0)