Commit Graph

20554 Commits

Author SHA1 Message Date
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
Owen 13eac31535 Add tests for inheritance of cproverNondetInitialize 2019-09-20 07:42:22 +01:00
Owen 40ffd7d8f9 Inherit cproverNondetInitialize like a virtual method
We should look for it on the super class, and on that's super class,
and so on till we reach the top of the class hierarchy.
2019-09-20 07:31:50 +01:00
Owen 5321624cf4 Fix unit test to set up symbol table correctly
It didn't add proper type for java.lang.Object symbol, which
caused find_cprover_nondet_initialise to fall over.
2019-09-20 07:18:48 +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
Daniel Poetzl 6155f2a1ab Add regression tests for constant propagation of StringBuffer.append() 2019-09-18 13:59:50 +01:00
Daniel Poetzl f53a598fb3 Remove ID of unimplemented string function
The string function with ID_cprover_string_concat_long_func was unimplemented
and will be obsolete when the functionality is handled by a model.
2019-09-18 13:58:44 +01:00
Daniel Poetzl 6ecf35ec9c Add regression tests for constant propagation of StringBuilder.append() 2019-09-18 10:47:19 +01:00
Daniel Poetzl 39d13e4e9e Add entry for StringBuilder.append(StringBuffer) to string preprocessing table 2019-09-17 18:03:57 +01:00
Daniel Poetzl b40e637914 Add tests for the constant propagation of String and StringBuilder constructors
Add regression tests that test the constructors that take string types or
primitive types.
2019-09-16 14:43:02 +01:00
Daniel Poetzl b88b01513d Adjust data invariant for constant propagation of the empty string
Require >= 2 arguments instead of 2 arguments. This enables the modelling of
methods that result in the empty string but take arguments that are ignored.
2019-09-16 14:43:02 +01:00
Daniel Poetzl 85cfa30a25 Add entry for StringBuilder constructors to the string preprocessing
Add entries for StringBuilder(CharSequence) and StringBuilder(int capacity) to
the string library preprocessing
2019-09-16 14:43:02 +01:00
Daniel Poetzl 42c19fb3ef Rename default constructor constant evaluation regression tests
Rename the directories to follow the existing naming convention
2019-09-16 11:33:06 +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
Nathan Phillips 139c411ab9 Fix code issues causing warnings in CLion IDE
Mostly relate to signed/unsigned mismatch and passing as const reference
2019-09-12 17:19:15 +01:00
Nathan Phillips 04d30bdd33 Correct test message 2019-09-12 17:19:15 +01:00
Nathan Phillips 435f46c0ea Tidy up comments 2019-09-12 17:20:40 +01:00