@@ -326,8 +326,7 @@ void string_refine_preprocesst::get_data_and_length_type_of_string(
326
326
{
327
327
assert (is_java_string_type (expr.type ()) ||
328
328
is_java_string_builder_type (expr.type ()) ||
329
- is_java_char_sequence_type (expr.type ())
330
- );
329
+ is_java_char_sequence_type (expr.type ()));
331
330
typet object_type=ns.follow (expr.type ());
332
331
assert (object_type.id ()==ID_struct);
333
332
const struct_typet &struct_type=to_struct_type (object_type);
@@ -361,56 +360,42 @@ exprt string_refine_preprocesst::make_cprover_string_assign(
361
360
{
362
361
if (implements_java_char_sequence (rhs.type ()))
363
362
{
364
- #if 0
365
- auto pair=java_to_cprover_strings.insert(
366
- std::make_pair(rhs, nil_exprt()));
363
+ // We do the following assignments:
364
+ // 1 cprover_string_length= *(rhs->length)
365
+ // 2 cprover_string_array = *(rhs->data)
366
+ // 3 cprover_string = { cprover_string_length; cprover_string_array }
367
+
368
+ dereference_exprt deref (rhs, rhs.type ().subtype ());
369
+ typet data_type, length_type;
370
+ get_data_and_length_type_of_string (deref, data_type, length_type);
371
+ std::list<code_assignt> assignments;
367
372
368
- if(pair.second)
369
- {
370
- #endif
371
- // We do the following assignments:
372
- // 1 cprover_string_length= *(rhs->length)
373
- // 2 cprover_string_array = *(rhs->data)
374
- // 3 cprover_string = { cprover_string_length; cprover_string_array }
375
-
376
- dereference_exprt deref (rhs, rhs.type ().subtype ());
377
- typet data_type, length_type;
378
- get_data_and_length_type_of_string (deref, data_type, length_type);
379
- std::list<code_assignt> assignments;
380
-
381
- // 1) cprover_string_length= *(rhs->length)
382
- symbol_exprt length_lhs=new_symbol (
383
- " cprover_string_length" , length_type);
384
-
385
- member_exprt deref_length (deref, " length" , length_type);
386
- assignments.emplace_back (length_lhs, deref_length);
387
-
388
- // 2) cprover_string_array = *(rhs->data)
389
- symbol_exprt array_lhs=new_symbol (
390
- " cprover_string_array" , data_type.subtype ());
391
- member_exprt data (deref, " data" , data_type);
392
- dereference_exprt deref_data (data, data_type.subtype ());
393
- assignments.emplace_back (array_lhs, deref_data);
394
-
395
- // 3) cprover_string = { cprover_string_length; cprover_string_array }
396
- // This assignment is useful for finding witnessing strings for counter
397
- // examples
398
- refined_string_typet ref_type (length_type, java_char_type ());
399
- string_exprt new_rhs (length_lhs, array_lhs, ref_type);
400
-
401
- symbol_exprt lhs=new_symbol (" cprover_string" , new_rhs.type ());
402
- assignments.emplace_back (lhs, new_rhs);
403
-
404
- insert_assignments (goto_program, i_it, assignments);
405
- i_it=goto_program.insert_after (i_it);
406
- return new_rhs;
407
-
408
- #if 0
409
- //pair.first->second=lhs;
410
- pair.first->second=new_rhs;
411
- }
412
- return pair.first->second;
413
- #endif
373
+ // 1) cprover_string_length= *(rhs->length)
374
+ symbol_exprt length_lhs=new_symbol (
375
+ " cprover_string_length" , length_type);
376
+
377
+ member_exprt deref_length (deref, " length" , length_type);
378
+ assignments.emplace_back (length_lhs, deref_length);
379
+
380
+ // 2) cprover_string_array = *(rhs->data)
381
+ symbol_exprt array_lhs=new_symbol (
382
+ " cprover_string_array" , data_type.subtype ());
383
+ member_exprt data (deref, " data" , data_type);
384
+ dereference_exprt deref_data (data, data_type.subtype ());
385
+ assignments.emplace_back (array_lhs, deref_data);
386
+
387
+ // 3) cprover_string = { cprover_string_length; cprover_string_array }
388
+ // This assignment is useful for finding witnessing strings for counter
389
+ // examples
390
+ refined_string_typet ref_type (length_type, java_char_type ());
391
+ string_exprt new_rhs (length_lhs, array_lhs, ref_type);
392
+
393
+ symbol_exprt lhs=new_symbol (" cprover_string" , new_rhs.type ());
394
+ assignments.emplace_back (lhs, new_rhs);
395
+
396
+ insert_assignments (goto_program, i_it, assignments);
397
+ i_it=goto_program.insert_after (i_it);
398
+ return new_rhs;
414
399
}
415
400
else if (rhs.id ()==ID_typecast &&
416
401
implements_java_char_sequence (rhs.op0 ().type ()))
@@ -560,10 +545,8 @@ void string_refine_preprocesst::make_string_assign(
560
545
// Adding a string expr in the map
561
546
refined_string_typet ref_type (length_type, data_type.subtype ().subtype ());
562
547
string_exprt str (tmp_length, tmp_array, ref_type);
563
- symbol_exprt cprover_string_sym=new_tmp_symbol (" tmp_cprover_string" , ref_type);
564
- #if 0
565
- java_to_cprover_strings[lhs]=cprover_string_sym;
566
- #endif
548
+ symbol_exprt cprover_string_sym=new_tmp_symbol (" tmp_cprover_string" ,
549
+ ref_type);
567
550
568
551
std::list<code_assignt> assigns;
569
552
assigns.emplace_back (lhs, malloc_expr);
@@ -838,7 +821,7 @@ void string_refine_preprocesst::make_string_function_side_effect(
838
821
const std::string &signature)
839
822
{
840
823
const code_function_callt &function_call=to_code_function_call (i_it->code );
841
- code_assignt assign (function_call.lhs (),function_call.arguments ()[0 ]);
824
+ code_assignt assign (function_call.lhs (), function_call.arguments ()[0 ]);
842
825
make_string_function (
843
826
goto_program, i_it, function_name, signature, true , false );
844
827
if (assign.lhs ().is_not_nil ())
@@ -944,7 +927,7 @@ exprt string_refine_preprocesst::make_cprover_char_array_assign(
944
927
const source_locationt &location)
945
928
{
946
929
typet type=ns.follow (rhs.type ());
947
- assert (type.id ()==ID_struct &&
930
+ assert (type.id ()==ID_struct &&
948
931
to_struct_type (type).get_tag ()==" java::array[char]" );
949
932
950
933
// We do the following assignments:
@@ -1029,7 +1012,8 @@ void string_refine_preprocesst::make_char_array_function(
1029
1012
if (function_name==ID_cprover_string_copy_func)
1030
1013
{
1031
1014
assert (is_java_char_array_pointer_type (args[start_index].type ()));
1032
- dereference_exprt char_array (args[start_index], args[start_index].type ().subtype ());
1015
+ dereference_exprt char_array (args[start_index],
1016
+ args[start_index].type ().subtype ());
1033
1017
exprt string=make_cprover_char_array_assign (
1034
1018
goto_program, i_it, char_array, location);
1035
1019
@@ -1259,15 +1243,6 @@ void string_refine_preprocesst::replace_string_calls(
1259
1243
if (uncasted.id ()==ID_typecast)
1260
1244
uncasted=to_typecast_expr (uncasted).op0 ();
1261
1245
1262
- #if 0
1263
- if(implements_java_char_sequence(uncasted.type()))
1264
- {
1265
- auto it=java_to_cprover_strings.find(uncasted);
1266
- if(it!=java_to_cprover_strings.end())
1267
- java_to_cprover_strings.insert(std::make_pair(assignment.lhs(), it->second));
1268
- }
1269
- #endif
1270
-
1271
1246
if (new_rhs.id ()==ID_function_application)
1272
1247
{
1273
1248
function_application_exprt f=to_function_application_expr (new_rhs);
@@ -1554,7 +1529,6 @@ void string_refine_preprocesst::initialize_string_function_table()
1554
1529
signatures[" java::java.lang.StringBuilder.insert:(ILjava/lang/String;)"
1555
1530
" Ljava/lang/StringBuilder;" ]=" SISS" ;
1556
1531
signatures[" java::java.lang.String.intern:()Ljava/lang/String;" ]=" SV" ;
1557
-
1558
1532
}
1559
1533
1560
1534
/* ******************************************************************\
0 commit comments