@@ -464,7 +464,7 @@ refined_string_exprt java_string_library_preprocesst::replace_char_array(
464
464
array_data.type (), " char_array" , " char_array" , loc, ID_java, symbol_table);
465
465
symbol_exprt char_array=sym_char_array.symbol_expr ();
466
466
// char_array = array_pointer->data
467
- code.add (code_assignt (char_array, array_data));
467
+ code.add (code_assignt (char_array, array_data), loc );
468
468
469
469
// string_expr is `{ rhs->length; string_array }`
470
470
refined_string_exprt string_expr (
@@ -524,9 +524,9 @@ refined_string_exprt java_string_library_preprocesst::decl_string_expr(
524
524
ID_java,
525
525
symbol_table);
526
526
symbol_exprt content_field = sym_content.symbol_expr ();
527
- code.add (code_declt (content_field));
527
+ code.add (code_declt (content_field), loc );
528
528
refined_string_exprt str (length_field, content_field, refined_string_type);
529
- code.add (code_declt (length_field));
529
+ code.add (code_declt (length_field), loc );
530
530
return str;
531
531
}
532
532
@@ -545,7 +545,7 @@ refined_string_exprt java_string_library_preprocesst::make_nondet_string_expr(
545
545
const refined_string_exprt str = decl_string_expr (loc, symbol_table, code);
546
546
547
547
side_effect_expr_nondett nondet_length (str.length ().type ());
548
- code.add (code_assignt (str.length (), nondet_length));
548
+ code.add (code_assignt (str.length (), nondet_length), loc );
549
549
550
550
exprt nondet_array_expr =
551
551
make_nondet_infinite_char_array (symbol_table, loc, code);
@@ -559,7 +559,7 @@ refined_string_exprt java_string_library_preprocesst::make_nondet_string_expr(
559
559
add_array_to_length_association (
560
560
nondet_array_expr, str.length (), symbol_table, loc, code);
561
561
562
- code.add (code_assignt (str.content (), array_pointer));
562
+ code.add (code_assignt (str.content (), array_pointer), loc );
563
563
564
564
return refined_string_exprt (str.length (), str.content ());
565
565
}
@@ -594,7 +594,7 @@ exprt java_string_library_preprocesst::allocate_fresh_array(
594
594
code_blockt &code)
595
595
{
596
596
exprt array=fresh_array (type, loc, symbol_table);
597
- code.add (code_declt (array));
597
+ code.add (code_declt (array), loc );
598
598
allocate_dynamic_object_with_decl (array, symbol_table, loc, code);
599
599
return array;
600
600
}
@@ -659,9 +659,9 @@ exprt make_nondet_infinite_char_array(
659
659
ID_java,
660
660
symbol_table);
661
661
const symbol_exprt data_expr = data_sym.symbol_expr ();
662
- code.add (code_declt (data_expr));
662
+ code.add (code_declt (data_expr), loc );
663
663
side_effect_expr_nondett nondet_data (data_expr.type ());
664
- code.add (code_assignt (data_expr, nondet_data));
664
+ code.add (code_assignt (data_expr, nondet_data), loc );
665
665
return data_expr;
666
666
}
667
667
@@ -689,13 +689,14 @@ void add_pointer_to_array_association(
689
689
ID_java,
690
690
symbol_table);
691
691
exprt return_expr = return_sym.symbol_expr ();
692
- code.add (code_declt (return_expr));
692
+ code.add (code_declt (return_expr), loc );
693
693
code.add (
694
694
code_assign_function_application (
695
695
return_expr,
696
696
ID_cprover_associate_array_to_pointer_func,
697
697
{array, pointer},
698
- symbol_table));
698
+ symbol_table),
699
+ loc);
699
700
}
700
701
701
702
// / Add a call to a primitive of the string solver, letting it know that
@@ -720,13 +721,14 @@ void add_array_to_length_association(
720
721
ID_java,
721
722
symbol_table);
722
723
const exprt return_expr = return_sym.symbol_expr ();
723
- code.add (code_declt (return_expr));
724
+ code.add (code_declt (return_expr), loc );
724
725
code.add (
725
726
code_assign_function_application (
726
727
return_expr,
727
728
ID_cprover_associate_length_to_array_func,
728
729
{array, length},
729
- symbol_table));
730
+ symbol_table),
731
+ loc);
730
732
}
731
733
732
734
// / Add a call to a primitive of the string solver which ensures all characters
@@ -751,14 +753,15 @@ void add_character_set_constraint(
751
753
symbolt &return_sym = get_fresh_aux_symbol (
752
754
java_int_type (), " cnstr_added" , " cnstr_added" , loc, ID_java, symbol_table);
753
755
const exprt return_expr = return_sym.symbol_expr ();
754
- code.add (code_declt (return_expr));
756
+ code.add (code_declt (return_expr), loc );
755
757
const constant_exprt char_set_expr (char_set, string_typet ());
756
758
code.add (
757
759
code_assign_function_application (
758
760
return_expr,
759
761
ID_cprover_string_constrain_characters_func,
760
762
{length, pointer, char_set_expr},
761
- symbol_table));
763
+ symbol_table),
764
+ loc);
762
765
}
763
766
764
767
// / Create a refined_string_exprt `str` whose content and length are fresh
@@ -793,7 +796,7 @@ refined_string_exprt java_string_library_preprocesst::string_expr_of_function(
793
796
ID_java,
794
797
symbol_table);
795
798
const exprt return_code = return_code_sym.symbol_expr ();
796
- code.add (code_declt (return_code));
799
+ code.add (code_declt (return_code), loc );
797
800
798
801
const refined_string_exprt string_expr =
799
802
make_nondet_string_expr (loc, symbol_table, code);
@@ -807,7 +810,8 @@ refined_string_exprt java_string_library_preprocesst::string_expr_of_function(
807
810
// return_code = <function_name>_data(args)
808
811
code.add (
809
812
code_assign_function_application (
810
- return_code, function_name, args, symbol_table));
813
+ return_code, function_name, args, symbol_table),
814
+ loc);
811
815
812
816
return string_expr;
813
817
}
@@ -893,9 +897,9 @@ void java_string_library_preprocesst::code_assign_java_string_to_string_expr(
893
897
const exprt rhs_length = get_length (deref, symbol_table);
894
898
895
899
// Assignments
896
- code.add (code_assignt (lhs.length (), rhs_length));
900
+ code.add (code_assignt (lhs.length (), rhs_length), loc );
897
901
const exprt data_as_array = get_data (deref, symbol_table);
898
- code.add (code_assignt (lhs.content (), data_as_array));
902
+ code.add (code_assignt (lhs.content (), data_as_array), loc );
899
903
}
900
904
901
905
// / Create a string expression whose value is given by a literal
@@ -958,16 +962,21 @@ codet java_string_library_preprocesst::make_equals_function_code(
958
962
const symbolt string_equals_sym = get_fresh_aux_symbol (
959
963
java_boolean_type (), " string_equals" , " str_eq" , loc, ID_java, symbol_table);
960
964
const symbol_exprt string_equals = string_equals_sym.symbol_expr ();
961
- code.add (code_declt (string_equals));
962
- code.add (code_assignt (
963
- string_equals,
964
- make_function_application (
965
- ID_cprover_string_equal_func, args, type.return_type (), symbol_table)));
966
-
967
- code.add (code_returnt (if_exprt (
968
- arg_is_string,
969
- string_equals,
970
- from_integer (false , java_boolean_type ()))));
965
+ code.add (code_declt (string_equals), loc);
966
+ code.add (
967
+ code_assignt (
968
+ string_equals,
969
+ make_function_application (
970
+ ID_cprover_string_equal_func, args, type.return_type (), symbol_table)),
971
+ loc);
972
+
973
+ code.add (
974
+ code_returnt (
975
+ if_exprt (
976
+ arg_is_string,
977
+ string_equals,
978
+ from_integer (false , java_boolean_type ()))),
979
+ loc);
971
980
return code;
972
981
}
973
982
@@ -1094,10 +1103,10 @@ codet java_string_library_preprocesst::make_float_to_string_code(
1094
1103
ife.else_case ()=tmp_code;
1095
1104
tmp_code=ife;
1096
1105
}
1097
- code.add (tmp_code);
1106
+ code.add (tmp_code, loc );
1098
1107
1099
1108
// Return str
1100
- code.add (code_returnt (str));
1109
+ code.add (code_returnt (str), loc );
1101
1110
return code;
1102
1111
}
1103
1112
@@ -1144,8 +1153,8 @@ codet java_string_library_preprocesst::make_init_function_from_call(
1144
1153
1145
1154
// arg_this <- string_expr
1146
1155
code.add (
1147
- code_assign_string_expr_to_java_string (
1148
- arg_this, string_expr, symbol_table) );
1156
+ code_assign_string_expr_to_java_string (arg_this, string_expr, symbol_table),
1157
+ loc );
1149
1158
1150
1159
return code;
1151
1160
}
@@ -1168,10 +1177,11 @@ codet java_string_library_preprocesst::
1168
1177
code_typet::parameterst params=type.parameters ();
1169
1178
PRECONDITION (!params.empty ());
1170
1179
code_blockt code;
1171
- code.add (make_assign_function_from_call (
1172
- function_name, type, loc, symbol_table));
1180
+ code.add (
1181
+ make_assign_function_from_call (function_name, type, loc, symbol_table),
1182
+ loc);
1173
1183
exprt arg_this=symbol_exprt (params[0 ].get_identifier (), params[0 ].type ());
1174
- code.add (code_returnt (arg_this));
1184
+ code.add (code_returnt (arg_this), loc );
1175
1185
return code;
1176
1186
}
1177
1187
@@ -1288,14 +1298,14 @@ exprt java_string_library_preprocesst::get_primitive_value_of_object(
1288
1298
dereference_exprt deref (
1289
1299
typecast_exprt (object, pointer_type), pointer_type.subtype ());
1290
1300
member_exprt deref_value (deref, value_comp.get_name (), value_comp.type ());
1291
- code.add (code_assignt (value, deref_value));
1301
+ code.add (code_assignt (value, deref_value), loc );
1292
1302
return value;
1293
1303
}
1294
1304
}
1295
1305
1296
1306
warning () << object_type.get_identifier ()
1297
1307
<< " not available to format function" << eom;
1298
- code.add (code_declt (value));
1308
+ code.add (code_declt (value), loc );
1299
1309
return value;
1300
1310
}
1301
1311
@@ -1378,7 +1388,7 @@ exprt java_string_library_preprocesst::make_argument_for_format(
1378
1388
symbolt field_symbol=get_fresh_aux_symbol (
1379
1389
type, tmp_name, tmp_name, loc, ID_java, symbol_table);
1380
1390
field_expr=field_symbol.symbol_expr ();
1381
- code.add (code_declt (field_expr));
1391
+ code.add (code_declt (field_expr), loc );
1382
1392
}
1383
1393
else
1384
1394
field_expr = make_nondet_string_expr (loc, symbol_table, code);
@@ -1393,9 +1403,12 @@ exprt java_string_library_preprocesst::make_argument_for_format(
1393
1403
obj.type (), " tmp_format_obj" , " tmp_format_obj" , loc, ID_java, symbol_table);
1394
1404
symbol_exprt arg_i=object_symbol.symbol_expr ();
1395
1405
allocate_dynamic_object_with_decl (arg_i, symbol_table, loc, code);
1396
- code.add (code_assignt (arg_i, obj));
1397
- code.add (code_assumet (not_exprt (equal_exprt (
1398
- arg_i, null_pointer_exprt (to_pointer_type (arg_i.type ()))))));
1406
+ code.add (code_assignt (arg_i, obj), loc);
1407
+ code.add (
1408
+ code_assumet (
1409
+ not_exprt (
1410
+ equal_exprt (arg_i, null_pointer_exprt (to_pointer_type (arg_i.type ()))))),
1411
+ loc);
1399
1412
1400
1413
// if arg_i != null then [code_not_null]
1401
1414
code_ifthenelset code_avoid_null_arg;
@@ -1426,15 +1439,15 @@ exprt java_string_library_preprocesst::make_argument_for_format(
1426
1439
{
1427
1440
exprt value=get_primitive_value_of_object (
1428
1441
arg_i, name, loc, symbol_table, code_not_null);
1429
- code_not_null.add (code_assignt (field_expr, value));
1442
+ code_not_null.add (code_assignt (field_expr, value), loc );
1430
1443
}
1431
1444
else
1432
1445
{
1433
1446
// TODO: date_time and hash_code not implemented
1434
1447
}
1435
1448
}
1436
1449
1437
- code.add (code_not_null);
1450
+ code.add (code_not_null, loc );
1438
1451
return arg_i_struct;
1439
1452
}
1440
1453
@@ -1488,8 +1501,9 @@ codet java_string_library_preprocesst::make_string_format_code(
1488
1501
type.return_type (), loc, symbol_table, code);
1489
1502
code.add (
1490
1503
code_assign_string_expr_to_java_string (
1491
- java_string, string_expr, symbol_table));
1492
- code.add (code_returnt (java_string));
1504
+ java_string, string_expr, symbol_table),
1505
+ loc);
1506
+ code.add (code_returnt (java_string), loc);
1493
1507
return code;
1494
1508
}
1495
1509
@@ -1523,7 +1537,7 @@ codet java_string_library_preprocesst::make_object_get_class_code(
1523
1537
symbolt class1_sym=get_fresh_aux_symbol (
1524
1538
class_type, " class_symbol" , " class_symbol" , loc, ID_java, symbol_table);
1525
1539
symbol_exprt class1=class1_sym.symbol_expr ();
1526
- code.add (code_declt (class1));
1540
+ code.add (code_declt (class1), loc );
1527
1541
1528
1542
// class_identifier is this->@class_identifier
1529
1543
member_exprt class_identifier (
@@ -1553,8 +1567,8 @@ codet java_string_library_preprocesst::make_object_get_class_code(
1553
1567
symbol_table.lookup_ref (" java::java.lang.String" ).type );
1554
1568
exprt string1=allocate_fresh_string (string_ptr_type, loc, symbol_table, code);
1555
1569
code.add (
1556
- code_assign_string_expr_to_java_string (
1557
- string1, string_expr1, symbol_table) );
1570
+ code_assign_string_expr_to_java_string (string1, string_expr1, symbol_table),
1571
+ loc );
1558
1572
1559
1573
// > class1 = Class.forName(string1)
1560
1574
code_function_callt fun_call;
@@ -1565,10 +1579,10 @@ codet java_string_library_preprocesst::make_object_get_class_code(
1565
1579
code_typet fun_type;
1566
1580
fun_type.return_type ()=string1.type ();
1567
1581
fun_call.function ().type ()=fun_type;
1568
- code.add (fun_call);
1582
+ code.add (fun_call, loc );
1569
1583
1570
1584
// > return class1;
1571
- code.add (code_returnt (class1));
1585
+ code.add (code_returnt (class1), loc );
1572
1586
return code;
1573
1587
}
1574
1588
@@ -1591,8 +1605,10 @@ codet java_string_library_preprocesst::make_function_from_call(
1591
1605
code_blockt code;
1592
1606
exprt::operandst args=process_parameters (
1593
1607
type.parameters (), loc, symbol_table, code);
1594
- code.add (code_return_function_application (
1595
- function_name, args, type.return_type (), symbol_table));
1608
+ code.add (
1609
+ code_return_function_application (
1610
+ function_name, args, type.return_type (), symbol_table),
1611
+ loc);
1596
1612
return code;
1597
1613
}
1598
1614
@@ -1629,10 +1645,11 @@ codet java_string_library_preprocesst::make_string_returning_function_from_call(
1629
1645
// Assign to string
1630
1646
exprt str=allocate_fresh_string (type.return_type (), loc, symbol_table, code);
1631
1647
code.add (
1632
- code_assign_string_expr_to_java_string (str, string_expr, symbol_table));
1648
+ code_assign_string_expr_to_java_string (str, string_expr, symbol_table),
1649
+ loc);
1633
1650
1634
1651
// Return value
1635
- code.add (code_returnt (str));
1652
+ code.add (code_returnt (str), loc );
1636
1653
return code;
1637
1654
}
1638
1655
@@ -1669,10 +1686,11 @@ codet java_string_library_preprocesst::make_copy_string_code(
1669
1686
// Allocate and assign the string
1670
1687
exprt str=allocate_fresh_string (type.return_type (), loc, symbol_table, code);
1671
1688
code.add (
1672
- code_assign_string_expr_to_java_string (str, string_expr, symbol_table));
1689
+ code_assign_string_expr_to_java_string (str, string_expr, symbol_table),
1690
+ loc);
1673
1691
1674
1692
// Return value
1675
- code.add (code_returnt (str));
1693
+ code.add (code_returnt (str), loc );
1676
1694
return code;
1677
1695
}
1678
1696
@@ -1707,8 +1725,8 @@ codet java_string_library_preprocesst::make_copy_constructor_code(
1707
1725
// Assign string_expr to `this` object
1708
1726
symbol_exprt arg_this (params[0 ].get_identifier (), params[0 ].type ());
1709
1727
code.add (
1710
- code_assign_string_expr_to_java_string (
1711
- arg_this, string_expr, symbol_table) );
1728
+ code_assign_string_expr_to_java_string (arg_this, string_expr, symbol_table),
1729
+ loc );
1712
1730
1713
1731
return code;
1714
1732
}
@@ -1752,8 +1770,8 @@ codet java_string_library_preprocesst::make_init_from_array_code(
1752
1770
// Assign string_expr to `this` object
1753
1771
symbol_exprt arg_this (params[0 ].get_identifier (), params[0 ].type ());
1754
1772
code.add (
1755
- code_assign_string_expr_to_java_string (
1756
- arg_this, string_expr, symbol_table) );
1773
+ code_assign_string_expr_to_java_string (arg_this, string_expr, symbol_table),
1774
+ loc );
1757
1775
1758
1776
return code;
1759
1777
}
0 commit comments