-
Notifications
You must be signed in to change notification settings - Fork 274
Cleanup in string preprocessing #2374
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cleanup in string preprocessing #2374
Conversation
4defa93
to
b00b5f1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passed Diffblue compatibility checks (cbmc commit: b00b5f1).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/77563791
b00b5f1
to
abf0bb0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passed Diffblue compatibility checks (cbmc commit: abf0bb0).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/78068569
abf0bb0
to
6968a82
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passed Diffblue compatibility checks (cbmc commit: 6968a82).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/78384602
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only formatting issues in the test. Otherwise looks good to me!
StringBuilder buffer = new StringBuilder(); | ||
public static String ofCharArray(char value[], int offset, int count) { | ||
org.cprover.CProver.assume(value != null); | ||
org.cprover.CProver.assume(value.length - count >= offset |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bad indentation (in many places).
String s = ofCharArray(diff, 0, diff.length); | ||
buffer.append(ofCharArray(diff, 0, diff.length)) | ||
.append(ofCharArray(blue, 0, blue.length)); | ||
String tmp=buffer.toString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spaces around =
6968a82
to
2a3420f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR failed Diffblue compatibility checks (cbmc commit: 2a3420f).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/80857319
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.
Common spurious failures:
- the cbmc commit has disappeared in the mean time (e.g. in a force-push)
- the author is not in the list of contributors (e.g. first-time contributors).
8dc4b9d
to
d26d482
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passed Diffblue compatibility checks (cbmc commit: d26d482).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/81006696
d26d482
to
b0afa53
Compare
char[] blue = {'b', 'l', 'u', 'e'}; | ||
|
||
StringBuilder buffer = new StringBuilder(); | ||
public static String ofCharArray(char value[], int offset, int count) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
char[] value
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both notations are acceptable.
checked_dereference(array_pointer, array_pointer.type().subtype()); | ||
// array_data is array_pointer-> data | ||
const exprt array_data = get_data(array, symbol_table); | ||
symbolt sym_char_array = get_fresh_aux_symbol( | ||
const symbolt sym_char_array = get_fresh_aux_symbol( | ||
array_data.type(), "char_array", "char_array", loc, ID_java, symbol_table); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Must take function_id to prefix the symbol name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I propose to add a function that makes sure it's always the case. @peterschrammel Can you have a look at the last commit?
symbolt sym_content = get_fresh_aux_symbol( | ||
const symbol_exprt length_field = sym_length.symbol_expr(); | ||
const pointer_typet array_type = pointer_type(java_char_type()); | ||
const symbolt sym_content = get_fresh_aux_symbol( | ||
array_type, | ||
"cprover_string_content", | ||
"cprover_string_content", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function_id
@@ -763,7 +766,7 @@ refined_string_exprt java_string_library_preprocesst::string_expr_of_function( | |||
code_blockt &code) | |||
{ | |||
// int return_code; | |||
symbolt return_code_sym = get_fresh_aux_symbol( | |||
const symbolt return_code_sym = get_fresh_aux_symbol( | |||
java_int_type(), | |||
std::string("return_code_") + function_name.c_str(), | |||
std::string("return_code_") + function_name.c_str(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function_id
symbolt class1_sym=get_fresh_aux_symbol( | ||
const pointer_typet class_type = | ||
java_reference_type(symbol_table.lookup_ref("java::java.lang.Class").type); | ||
const symbolt class1_sym = get_fresh_aux_symbol( | ||
class_type, "class_symbol", "class_symbol", loc, ID_java, symbol_table); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function_id
char[] blue = {'b', 'l', 'u', 'e'}; | ||
|
||
StringBuilder buffer = new StringBuilder(); | ||
public static String ofCharArray(char value[], int offset, int count) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both notations are acceptable.
char[] blue = {'b', 'l', 'u', 'e'}; | ||
|
||
StringBuilder buffer = new StringBuilder(); | ||
public static String ofCharArray(char value[], int offset, int count) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what this whole change is about. The regression is not clear as to its purpose. Also you mention the test uses CProverString
but I don't see where.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I fail to see how the commit and the commit message are related.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes you are right, I updated java-models-library so that we don't have to change this test.
e5a88ab
to
8115027
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passed Diffblue compatibility checks (cbmc commit: 70f2b64).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/84258693
70f2b64
to
a04f3c0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR failed Diffblue compatibility checks (cbmc commit: a04f3c0).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/84407246
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.
Common spurious failures:
- the cbmc commit has disappeared in the mean time (e.g. in a force-push)
- the author is not in the list of contributors (e.g. first-time contributors).
a04f3c0
to
6cb91f5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passed Diffblue compatibility checks (cbmc commit: 6cb91f5).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/86574191
6cb91f5
to
6146855
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passed Diffblue compatibility checks (cbmc commit: 6146855).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/86718492
@allredj @peterschrammel this is ready for review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
diffblue/java-models-library#9 must be merged first.
const source_locationt &source_location, | ||
symbol_table_baset &symbol_table) | ||
{ | ||
const std::string name_prefix = id2string(source_location.get_function()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 Unfortunately, this is in conflict with #2149
@tautschnig, we must come to a decision there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I strongly believe that the information in the source_location
is a string aimed at the user, and should relate to whatever is found in the source. The actual identifier of the function (the key in goto_functionst::function_map
) used internally may be entirely different. I don't know which one is required here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, something is required that is unique to a goto function. Reason: adding a function to a goto model must not affect the identifiers of another function. This was the source of many goto-diff bugs in the past.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then a function_id
must be passed in. In some call sites in this PR this would be symbol.name
, others require further digging.
6146855
to
8475bc1
Compare
@peterschrammel the part that I think is most important in this PR is independent of the problem with symbols, so I put this part in another #3189 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passed Diffblue compatibility checks (cbmc commit: 8475bc1).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/88137195
Conversion from char array to string does not work, because the string refinement is not aware of the operations performed on the arrays. To construct strings from char array, the constructors have to be implemented using loops instead.
8475bc1
to
f6c3023
Compare
Now pointing to diffblue/java-models-library#master |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passed Diffblue compatibility checks (cbmc commit: f6c3023).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/88298542
This removes broken or unused functions from the preprocessing