Commit Graph

20404 Commits

Author SHA1 Message Date
Romain Brenguier 5cd0c45842 add_to_front method for code_with_references_listt
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.
2019-09-23 12:08:19 +01:00
Romain Brenguier 93aa152425 Set the array length of reference when it is assigned
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.
2019-09-23 12:08:19 +01:00
Romain Brenguier c9f4b2b7e3 Get rid of block field of object_creation_infot
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.
2019-09-23 12:08:19 +01:00
Romain Brenguier b40ac5956e Add a class for code with references
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.
2019-09-23 12:08:19 +01:00
Romain Brenguier 4879a7458b Move some code from assign_from_json to new file
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.
2019-09-23 12:08:19 +01:00
Romain Brenguier 85cf5a4369 Make allocate_array take location and return code
This better reflects what this function does and make it easier to
refactor.
2019-09-23 12:08:19 +01:00
Owen Mansel-Chan f097054d17
Merge pull request #5121 from owen-mc-diffblue/owen-mc-diffblue/extremely-minor-code-improvement
Extremely minor code improvement
2019-09-21 06:14:17 +01:00
Owen c156475a17 Move variable declaration inside conditional
Also switch to brace initialisation
2019-09-20 16:31:17 +01:00
Owen Mansel-Chan 9c0e0d36b9
Merge pull request #5115 from antlechner/antonia/context-include
[TG-9294][UFC] Fix context-include/exclude jbmc options
2019-09-20 16:30:33 +01:00
thomasspriggs c7e449b1ef
Merge pull request #5085 from thomasspriggs/tas/invariant_matcher
Improve catch support for checking of thrown instances of `invariant_failedt`
2019-09-20 15:26:07 +01:00
Thomas Spriggs 91d162646a Add printing of `invariant_failedt` in test failure messages
This means that generated error messages show what the particular
invariant failure actually generated was, instead of the catch framework
default of `{?}`.
2019-09-20 10:15:04 +01:00
Thomas Spriggs 7bf92cb225 Replace `try` `catch` blocks with `REQUIRE_THROWS_MATCHES`
`REQUIRE_THROWS_MATCHES` is the functionality built into the catch
framework for this purpose. Using it allows more concise specification
of the requirement.
2019-09-20 10:15:04 +01:00
Thomas Spriggs fafafbd90c Add catch framework matcher for `invariant_failuret` testing
This utility supports writing more succinct requirements on
`invariant_failuret` being thrown and the reason for which it was
thrown.
2019-09-20 10:15:04 +01:00
Romain Brenguier 20164f5bc2
Merge pull request #5106 from romainbrenguier/refactor/assign-from-json
[TG-9450] Allocate array with right length when "@nondetLength" not used in Json
2019-09-20 09:19:46 +01:00
Romain Brenguier 5829c8a5ee Add unit test for assign_from_json
This in particular check that an array field (which is not marked nondet
and not a reference) is allocated with a constant size.
2019-09-20 08:05:46 +01:00
Romain Brenguier 4f06216b72 Allocate array with right size when possible
When the array is not marked as nondet and is not a reference it can
directly be allocated with the right size, which will allow constant
propagation through arrays.
2019-09-20 07:14:25 +01:00
Romain Brenguier 0c669207a5 Split assign_array_from_json into two versions
Depending on whether the array has deterministic length or not.
This will make it easier to allocate the array directly to the right
size in the deterministic case.
2019-09-20 07:14:22 +01:00
Owen Mansel-Chan 2082719e31
Merge pull request #5118 from owen-mc-diffblue/remove-unneeded-class-hierarchy-from-resolve-inherited-componentt
Remove unneeded class hierarchy from resolve_inherited_componentt
2019-09-20 07:11:55 +01:00
Romain Brenguier 0686242ba5 Refactor assume statements of assign_array_from_json
This makes it so that we only have one block.add(code_assumet(...))
instruction, it is thus easier to figure out what the assumption is
depending on the parameters.
2019-09-20 07:04:15 +01:00
Romain Brenguier c35f161347 Make given_length_expr argument non-optional
This simplifies the logic in assign_array_from_json and makes its
specification simpler.
2019-09-20 07:04:15 +01:00
Romain Brenguier e0dfd8bb72 Extract a nondet_length function from assign_array
This makes the assign_array_from_json a bit simpler.
This is an intermediary commit towards removing the optional argument
from assign_array_from_json.
2019-09-20 07:04:15 +01:00
Romain Brenguier db2ef9df0a Avoid double look-up in json_object
By keeping the iterator to the found entry.
2019-09-20 07:04:15 +01:00
Romain Brenguier 674fce368a Missing static keyword
No functional changes
2019-09-20 07:04:15 +01:00
Antonia Lechner ceb297d08d Add documentation for context-include/exclude 2019-09-19 16:25:17 +01:00
Antonia Lechner 331e0bc95a Add unit tests for preserving meta-information of excluded methods
These unit tests complement the regression tests in
jbmc/regression/jbmc/context-include-exclude
that were added in a previous commit to check for properties of excluded
methods. Some properties, like information about accessibility and final
and static status, is easier to check in unit-style tests.
2019-09-19 16:25:16 +01:00
Antonia Lechner 1f2dfcfd84 Split load_goto_model_from_java_class into two functions
The new overload allows specifying the command-line options to run jbmc
with. For example, we will be able to specify that --context-include
should be used.
2019-09-19 16:25:15 +01:00
Antonia Lechner a61441c78a Move load_goto_model... declaration to end of file
This is consistent with the location of the definition in the cpp file.
2019-09-19 16:25:14 +01:00
Antonia Lechner 0c41de7848 Add tests for properties of excluded methods
The tests from the previous commit show that the right methods are
excluded.
The tests from this commit show that an excluded method has the right
properties: meta-information such as parameter types and identifiers
should be preserved, while the real method should not be loaded and a
stub-like "return nondet" body should be used instead.
The tests from this commit would not have passed without the fixes from
this PR.
2019-09-19 16:25:13 +01:00
Antonia Lechner 202919b1d8 Add context-include tests for package and absent prefix
The tests in this commit would have all passed without the previous
fixes already and are just added for completeness.
The tested prefixes are a prefix of a package and a prefix that does not
match anything on the classpath.
2019-09-19 16:25:12 +01:00
Antonia Lechner d53520cd61 Remove "WARNING: no body for function" regexes
These lines appear in the output for methods whose body is empty/nil.
For excluded methods, we now have "return nondet" bodies as we do for
stubs, so the warnings are no longer printed.
2019-09-19 16:25:11 +01:00
Antonia Lechner f9b3b44486 Protect needed_lazy_methods access in an if-block
If we are not using CI lazy methods here (as could happen after the
change from the previous commit that makes sure convert_single_method is
run for all methods), needed_lazy_methods is an empty optional and we
cannot access it.
2019-09-19 16:25:11 +01:00
Antonia Lechner 3302020674 Move convert call above body_provided check
The previous version would have not called convert_single_method on
excluded methods, meaning they would have missed some meta-information,
e.g. parameter identifiers.
2019-09-19 16:25:10 +01:00
Antonia Lechner f7c0ed1633 Remove unused variable assignment 2019-09-19 16:25:09 +01:00
Antonia Lechner de8fa1a833 Amend condition for when stub method body should be made
There are three types of method symbols that we expect here:
1) symbols for regular methods, i.e. the bytecode of the method is
available and the method is in the supplied context
2) symbols for opaque methods, i.e. the bytecode of the method is not
available
3) symbols for excluded methods, i.e. the bytecode of the method is
available but the method is not in the supplied context
The previous check was correct for 1) and 2): we do not want to create
stub bodies ("return nondet") for regular methods but we do want to
create them for opaque methods.
The new check makes sure that stub bodies are also created for excluded
methods (3). Previously the value of those symbols was just left as nil,
meaning the (type of the) return value of the method was not constrained
in any way.
2019-09-19 16:25:08 +01:00
Antonia Lechner 60ad214747 Move method context check before symbol value assignment
The previous check was right at the beginning of convert_single_method,
meaning that for an "excluded" method, we would have never entered
java_bytecode_convert_method, which assigns more than just the symbol
value (body of a method), e.g. parameter identifiers.
The only information that we want to omit for excluded methods is their
bodies / symbol values. This is why the new check is just before the
assignment of symbol values, making sure that parameter identifiers and
other meta-information of the method are correctly assigned for excluded
methods.
2019-09-19 16:25:07 +01:00
Antonia Lechner 0dfafbee7a Rename method_in_context to method_context
The new name makes it clearer that this field defines a context, not a
method.
2019-09-19 16:25:06 +01:00
JohnDumbell da454cebdf
Merge pull request #5031 from JohnDumbell/jd/enhancement/pretty-printers
Fix & enable irept pretty-printer
2019-09-19 13:14:13 +01:00
yumibagge bdb7852852
Merge pull request #5009 from yumibagge/yb/codecov-flag
Add codecov flags, specify codecov file to upload, and remove unit test folder from coverage
2019-09-19 13:08:03 +01:00
Owen 0c9a5bc957 Remove unneeded class hierarchy from resolve_inherited_componentt
This means it can be used even in settings where a class hierarchy isn't
readily available. The class hierarchy was only being used to find
parents, which are easily available from the class type directly, so it
wasn't providing any benefit. (It would have been different if we needed
to find children.)
2019-09-19 12:24:00 +01:00
johndumbell 3a344a4688 Fix clang-format 2019-09-19 11:54:41 +01:00
Yumi Bagge 991a8a254d Script to run test and upload report with flag 2019-09-19 11:50:52 +01:00
Owen Mansel-Chan 3ea03e4694
Merge pull request #5069 from owen-mc-diffblue/disable-clang-format-for-java
Disable clang format for java
2019-09-19 10:35:20 +01:00
Yumi Bagge 59c2558b37 Consolidate tests to 3 and run/upload via script 2019-09-19 10:30:30 +01:00
johndumbell bfd2313ce9 Fix & enable irept pretty-printer 2019-09-19 10:22:36 +01:00
Yumi Bagge 08d95df64a Remove 'unit' from coverage report file 2019-09-19 05:14:21 +01:00
Yumi Bagge 1834ab66c6 Add codecov flags and specify lcov.file to upload 2019-09-19 05:14:21 +01:00
Owen Mansel-Chan d74a8d83e0
Merge pull request #5091 from owen-mc-diffblue/goto-symex-propagate-notequal-conditions-for-boolean-types
[TG-9390] GOTO-symex: propagate notequal conditions for boolean types
2019-09-13 18:07:20 +01:00
Owen a2cbcc2d54 Test we don't call static initialisers unnecessarily
Previously we couldn't properly track when we had definitely already
called them.
2019-09-13 15:06:22 +01:00
Nathan Phillips fcbbb59399
Merge pull request #5105 from NathanJPhillips/cleanup/pre-split-parser
Cleanups before splitting java_bytecode_parsert
2019-09-13 13:36:13 +02:00
Nathan Phillips 7a9e0cef5e Remove unnecessary parameter referring to field 2019-09-12 17:23:09 +01:00