Skip to content

Commit a11ccc4

Browse files
Add function_name parameter to convert_exprt_to_string_exprt
This is in preparation to giving the function_name to the function generating fresh java symbols.
1 parent 0f93784 commit a11ccc4

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

jbmc/src/java_bytecode/java_string_library_preprocess.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ exprt::operandst java_string_library_preprocesst::process_parameters(
289289
/// sequence
290290
/// \param loc: location in the source
291291
/// \param symbol_table: symbol table
292+
/// \param function_name: name of the function in which the code will be added
292293
/// \param init_code: code block, in which declaration will be added:
293294
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
294295
/// char *cprover_string_content;
@@ -303,11 +304,12 @@ java_string_library_preprocesst::convert_exprt_to_string_exprt(
303304
const exprt &expr_to_process,
304305
const source_locationt &loc,
305306
symbol_table_baset &symbol_table,
307+
const irep_idt &function_name,
306308
code_blockt &init_code)
307309
{
308310
PRECONDITION(implements_java_char_sequence_pointer(expr_to_process.type()));
309311
const refined_string_exprt string_expr =
310-
decl_string_expr(loc, loc.get_function(), symbol_table, init_code);
312+
decl_string_expr(loc, function_name, symbol_table, init_code);
311313
code_assign_java_string_to_string_expr(
312314
string_expr, expr_to_process, loc, symbol_table, init_code);
313315
return string_expr;
@@ -335,7 +337,8 @@ exprt::operandst java_string_library_preprocesst::process_operands(
335337
{
336338
if(implements_java_char_sequence_pointer(p.type()))
337339
ops.push_back(
338-
convert_exprt_to_string_exprt(p, loc, symbol_table, init_code));
340+
convert_exprt_to_string_exprt(
341+
p, loc, symbol_table, loc.get_function(), init_code));
339342
else if(is_java_char_array_pointer_type(p.type()))
340343
ops.push_back(replace_char_array(p, loc, symbol_table, init_code));
341344
else
@@ -367,14 +370,16 @@ java_string_library_preprocesst::process_equals_function_operands(
367370
PRECONDITION(implements_java_char_sequence_pointer(op0.type()));
368371

369372
ops.push_back(
370-
convert_exprt_to_string_exprt(op0, loc, symbol_table, init_code));
373+
convert_exprt_to_string_exprt(
374+
op0, loc, symbol_table, loc.get_function(), init_code));
371375

372376
// TODO: Manage the case where we have a non-String Object (this should
373377
// probably be handled upstream. At any rate, the following code should be
374378
// protected with assertions on the type of op1.
375379
const typecast_exprt tcast(op1, to_pointer_type(op0.type()));
376380
ops.push_back(
377-
convert_exprt_to_string_exprt(tcast, loc, symbol_table, init_code));
381+
convert_exprt_to_string_exprt(
382+
tcast, loc, symbol_table, loc.get_function(), init_code));
378383
return ops;
379384
}
380385

jbmc/src/java_bytecode/java_string_library_preprocess.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ class java_string_library_preprocesst:public messaget
200200
const exprt &deref,
201201
const source_locationt &loc,
202202
symbol_table_baset &symbol_table,
203+
const irep_idt &function_name,
203204
code_blockt &init_code);
204205

205206
exprt::operandst process_operands(

jbmc/unit/java_bytecode/java_string_library_preprocess/convert_exprt_to_string_exprt.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@ refined_string_exprt convert_exprt_to_string_exprt_unit_test(
2525
code_blockt &init_code)
2626
{
2727
return preprocess.convert_exprt_to_string_exprt(
28-
deref, loc, symbol_table, init_code);
28+
deref, loc, symbol_table, loc.get_function(), init_code);
2929
}
3030

3131
TEST_CASE("Convert exprt to string exprt")
3232
{
3333
GIVEN("A location, a string expression, and a symbol table")
3434
{
3535
source_locationt loc;
36+
loc.set_function("function_name");
3637
symbol_tablet symbol_table;
3738
namespacet ns(symbol_table);
3839
code_blockt code;

0 commit comments

Comments
 (0)