-
Notifications
You must be signed in to change notification settings - Fork 277
String preprocessing: don't re-initialise objects that already exist #3545
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
String preprocessing: don't re-initialise objects that already exist #3545
Conversation
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.
Is it just me, or is is_constructor
always set to true
?
@@ -826,24 +826,37 @@ codet java_string_library_preprocesst::code_assign_components_to_java_string( | |||
const exprt &lhs, | |||
const exprt &rhs_array, | |||
const exprt &rhs_length, | |||
const symbol_table_baset &symbol_table) | |||
const symbol_table_baset &symbol_table, | |||
bool is_constructor) |
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.
🚫 update documentation
@@ -1083,14 +1097,14 @@ code_blockt java_string_library_preprocesst::make_init_function_from_call( | |||
const java_method_typet &type, | |||
const source_locationt &loc, | |||
symbol_table_baset &symbol_table, | |||
bool ignore_first_arg) | |||
bool is_constructor) |
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.
🚫 update documentation
@@ -857,10 +870,11 @@ codet java_string_library_preprocesst::code_assign_components_to_java_string( | |||
codet java_string_library_preprocesst::code_assign_string_expr_to_java_string( | |||
const exprt &lhs, | |||
const refined_string_exprt &rhs, | |||
const symbol_table_baset &symbol_table) | |||
const symbol_table_baset &symbol_table, | |||
bool is_constructor) |
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.
🚫 update documentation
struct_rhs.copy_to_operands(rhs_array); | ||
return code_assignt( | ||
checked_dereference(lhs, lhs.type().subtype()), struct_rhs); | ||
if(is_constructor) |
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.
Documenting the "why" would be useful.
8322911
to
655a788
Compare
Just set their length and data fields, leaving the others alone; otherwise it will overwrite taint fields, as well as lock fields and anything else introduced to java.lang.Object.
655a788
to
e6fca9b
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: e6fca9b).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/94196111
@allredj take a look at |
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.
LGTM
Just set their length and data fields, leaving the others alone; otherwise it will overwrite any fields stored on java.lang.Object with their initialiser value.
This should not change any behaviour in cbmc / test-gen; it only has an effect when java.lang.Object has been augmented with extra fields, as we do to track taint, and I know the concurrency work has done to better model locks.