1
1
/* * -*- C++ -*- *****************************************************\
2
2
3
- Module: Constraint generation from string function calls
4
- for the PASS algorithm (see the PASS paper at HVC'13)
3
+ Module: Generates string constraints to link results from string functions
4
+ with their arguments. This is inspired by the PASS paper at HVC'13
5
+ which gives examples of constraints for several functions.
5
6
6
7
Author: Romain Brenguier, [email protected]
7
8
@@ -71,6 +72,19 @@ symbol_exprt string_constraint_generatort::fresh_boolean
71
72
}
72
73
73
74
75
+ /* ******************************************************************\
76
+
77
+ Function: string_constraint_generatort::add_axioms_for_string_expr
78
+
79
+ Inputs: an expression of type string
80
+
81
+ Outputs: a string expression that is link to the argument through
82
+ axioms that are added to the list
83
+
84
+ Purpose: obtain a refined string expression corresponding to string
85
+ variable of string function call
86
+
87
+ \*******************************************************************/
74
88
string_exprt string_constraint_generatort::add_axioms_for_string_expr
75
89
(const exprt & unrefined_string)
76
90
{
@@ -144,7 +158,19 @@ string_exprt string_constraint_generatort::find_or_add_string_of_symbol
144
158
return symbol_to_string[id];
145
159
}
146
160
161
+ /* ******************************************************************\
147
162
163
+ Function: string_constraint_generatort::add_axioms_for_function_application
164
+
165
+ Inputs: an expression containing a function application
166
+
167
+ Outputs: expression corresponding to the result of the function application
168
+
169
+ Purpose: strings contained in this call are converted to objects of type
170
+ `string_exprt`, through adding axioms. Axioms are then added to
171
+ enforce that the result corresponds to the function application.
172
+
173
+ \*******************************************************************/
148
174
exprt string_constraint_generatort::add_axioms_for_function_application
149
175
(const function_application_exprt & expr)
150
176
{
@@ -159,7 +185,7 @@ exprt string_constraint_generatort::add_axioms_for_function_application
159
185
else if (id==ID_cprover_string_length_func)
160
186
return add_axioms_for_length (expr);
161
187
else if (id==ID_cprover_string_equal_func)
162
- return add_axioms_for_equal (expr);
188
+ return add_axioms_for_equals (expr);
163
189
else if (id==ID_cprover_string_equals_ignore_case_func)
164
190
return add_axioms_for_equals_ignore_case (expr);
165
191
else if (id==ID_cprover_string_is_empty_func)
@@ -1202,7 +1228,7 @@ string_exprt string_constraint_generatort::add_axioms_for_insert_float
1202
1228
}
1203
1229
1204
1230
1205
- exprt string_constraint_generatort::add_axioms_for_equal
1231
+ exprt string_constraint_generatort::add_axioms_for_equals
1206
1232
(const function_application_exprt &f)
1207
1233
{
1208
1234
assert (f.type ()==bool_typet () || f.type ().id ()==ID_c_bool);
@@ -1720,7 +1746,7 @@ exprt string_constraint_generatort::add_axioms_for_index_of
1720
1746
else
1721
1747
assert (false );
1722
1748
1723
- if (refined_string_typet::is_java_string_type (c.type ()))
1749
+ if (refined_string_typet::is_java_string_pointer_type (c.type ()))
1724
1750
{
1725
1751
string_exprt sub=add_axioms_for_string_expr (c);
1726
1752
return add_axioms_for_index_of_string (str, sub, from_index);
@@ -1788,7 +1814,7 @@ exprt string_constraint_generatort::add_axioms_for_last_index_of
1788
1814
else
1789
1815
assert (false );
1790
1816
1791
- if (refined_string_typet::is_java_string_type (c.type ()))
1817
+ if (refined_string_typet::is_java_string_pointer_type (c.type ()))
1792
1818
{
1793
1819
string_exprt sub=add_axioms_for_string_expr (c);
1794
1820
return add_axioms_for_last_index_of_string (str, sub, from_index);
0 commit comments