Skip to content

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

Merged

Conversation

romainbrenguier
Copy link
Contributor

This removes broken or unused functions from the preprocessing

Copy link
Contributor

@allredj allredj left a 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

@romainbrenguier romainbrenguier force-pushed the clean-up/preprocessing branch from b00b5f1 to abf0bb0 Compare July 4, 2018 08:27
Copy link
Contributor

@allredj allredj left a 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

Copy link
Contributor

@allredj allredj left a 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

Copy link
Contributor

@allredj allredj left a 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
Copy link
Contributor

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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spaces around =

@romainbrenguier romainbrenguier force-pushed the clean-up/preprocessing branch from 6968a82 to 2a3420f Compare August 3, 2018 09:33
Copy link
Contributor

@allredj allredj left a 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).

@romainbrenguier romainbrenguier force-pushed the clean-up/preprocessing branch 2 times, most recently from 8dc4b9d to d26d482 Compare August 6, 2018 09:14
Copy link
Contributor

@allredj allredj left a 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

@romainbrenguier romainbrenguier force-pushed the clean-up/preprocessing branch from d26d482 to b0afa53 Compare August 6, 2018 12:02
char[] blue = {'b', 'l', 'u', 'e'};

StringBuilder buffer = new StringBuilder();
public static String ofCharArray(char value[], int offset, int count) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

char[] value?

Copy link
Contributor

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);
Copy link
Member

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

Copy link
Contributor Author

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",
Copy link
Member

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(),
Copy link
Member

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);
Copy link
Member

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) {
Copy link
Contributor

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) {
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

@romainbrenguier romainbrenguier force-pushed the clean-up/preprocessing branch 3 times, most recently from e5a88ab to 8115027 Compare August 9, 2018 09:44
Copy link
Contributor

@allredj allredj left a 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

Copy link
Contributor

@allredj allredj left a 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).

Copy link
Contributor

@allredj allredj left a 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

Copy link
Contributor

@allredj allredj left a 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

@romainbrenguier
Copy link
Contributor Author

@allredj @peterschrammel this is ready for review

Copy link
Contributor

@allredj allredj left a 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());
Copy link
Member

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.

Copy link
Collaborator

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.

Copy link
Member

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.

Copy link
Collaborator

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.

@romainbrenguier
Copy link
Contributor Author

@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
Can you check there is nothing blocking in the commits that are left?

Copy link
Contributor

@allredj allredj left a 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.
@romainbrenguier
Copy link
Contributor Author

Now pointing to diffblue/java-models-library#master

Copy link
Contributor

@allredj allredj left a 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

@romainbrenguier romainbrenguier merged commit c6a220c into diffblue:develop Oct 18, 2018
@romainbrenguier romainbrenguier deleted the clean-up/preprocessing branch October 18, 2018 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants