-
Notifications
You must be signed in to change notification settings - Fork 274
[TG-9450] Allocate reference arrays with constant size in assignments from json #5112
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
[TG-9450] Allocate reference arrays with constant size in assignments from json #5112
Conversation
473a686
to
d114b94
Compare
Codecov Report
@@ Coverage Diff @@
## develop #5112 +/- ##
===========================================
+ Coverage 66.95% 66.96% +<.01%
===========================================
Files 1145 1146 +1
Lines 93653 93702 +49
===========================================
+ Hits 62702 62743 +41
- Misses 30951 30959 +8
Continue to review full report at Codecov.
|
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: d114b94).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/128489226
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 don't fully grasp why the references are necessary (perhaps add some high-level docs about what they're doing?), but I don't see anything troubling.
@@ -28,9 +28,6 @@ Author: Diffblue Ltd. | |||
/// ones that are not marked `const` may be mutated. | |||
struct object_creation_infot |
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.
Commit message: "We make is to make it so" -> "We make it so"
public: | ||
std::list<std::shared_ptr<code_with_referencest>> list; | ||
|
||
void add(code_without_referencest code); |
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.
You seem to use add(code_without_referencest{...})
a lot, so perhaps just create an add(codet)
overload?
*reference.array_length, ID_ge, from_integer(0, java_int_type())}}}); | ||
code.add(code_without_referencest{ | ||
allocate_array(reference.expr, *reference.array_length, info.loc)}); | ||
code.add(reference_allocationt{id, info.loc}); |
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.
Commit "Add reference allocation code for references" doesn't seem to do what it says (it only deletes code from get_or_create_reference
)
@@ -63,3 +63,9 @@ void code_with_references_listt::append(code_with_references_listt &&other) | |||
{ | |||
list.splice(list.end(), other.list); | |||
} | |||
|
|||
void code_with_references_listt::add_to_front(code_without_referencest code) |
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.
Commit message: typo "begginning"
d114b94
to
69348e0
Compare
This is already explained in the documentation of |
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: 69348e0).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/128702645
Not that the json file has been modified on purpose so that this checks | ||
that it is actually loaded and not retrieved by execution of the Util function. | ||
This test does not work with symex-driven-lazy-loading because this option is | ||
not compatible with --property. |
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.
⛏️ Missing new line
@@ -902,11 +902,10 @@ code_with_references_listt assign_from_json_rec( | |||
return result; | |||
} | |||
|
|||
void assign_from_json( | |||
code_with_references_listt assign_from_json( |
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.
⛏️ Typo in the commit message: the all the value pairs
-> all the value pairs
This better reflects what this function does and make it easier to refactor.
This is in preparation for adding a new class in this file, we add there the function and class which will be needed by this class.
This will be use in assign_from_json for json files in which the "@ref" and "@id" entries are used, so that we can easily substitute code marked by "@ref" by the code corresponding to the object marked by "@id". This also move object_creation_referencet to the new header file since it will be used there, and the allocate_array is now declared in the new header and defined in the corresponding cpp file.
This should be an output of the functions rather than an "info". We make it so that assign_*_from_json functions have a return type which reflects what the function does. That way we separate the json to assignment conversion from the writting of code blocks, which will ultimately allow us to rewrite references in the assignments.
We know the number of elements of the reference array only when it is assigned so we replace the reference.array_length field at that point.
This will make it easier to add declarations at the begginning of a list of codet after the rest of the code has been generated.
This will allow references to be replaced after the all value pairs have been replaced. For instance in the regression test regression/jbmc/deterministic_assignments_json/test_char_array_pass.desc the reference 2 wouldn't have been assigned before the end of the assign_from_json call in which it is referenced for the first time so its allocation size would be non-deterministic but this is fixed by this commit.
This is a case for the json conversion which requires particular attention.
This checks that array cell sensitivity works fine for static arrays, whether we use the --static-values option or not.
69348e0
to
bc47e49
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: bc47e49).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/128757153
This is to ensure static reference arrays retrieved from a json file are assigned with a constant size (when not marked as
@nondetLength
). This is so that array-cell-sensitivity can apply to such arrays.