-
Notifications
You must be signed in to change notification settings - Fork 274
[TG-9294][UFC] Fix context-include/exclude jbmc options #5115
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
owen-mc-diffblue
merged 13 commits into
diffblue:develop
from
antlechner:antonia/context-include
Sep 20, 2019
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
0dfafbe
Rename method_in_context to method_context
antlechner 60ad214
Move method context check before symbol value assignment
antlechner de8fa1a
Amend condition for when stub method body should be made
antlechner f7c0ed1
Remove unused variable assignment
antlechner 3302020
Move convert call above body_provided check
antlechner f9b3b44
Protect needed_lazy_methods access in an if-block
antlechner d53520c
Remove "WARNING: no body for function" regexes
antlechner 202919b
Add context-include tests for package and absent prefix
antlechner 0c41de7
Add tests for properties of excluded methods
antlechner a61441c
Move load_goto_model... declaration to end of file
antlechner 1f2dfcf
Split load_goto_model_from_java_class into two functions
antlechner 331e0bc
Add unit tests for preserving meta-information of excluded methods
antlechner ceb297d
Add documentation for context-include/exclude
antlechner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file added
BIN
+1.01 KB
jbmc/regression/jbmc/context-include-exclude/ExcludedProperties.class
Binary file not shown.
30 changes: 30 additions & 0 deletions
30
jbmc/regression/jbmc/context-include-exclude/ExcludedProperties.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import org.cprover.other.MyOther; | ||
import org.cprover.other.Parent; | ||
import org.cprover.other.Child; | ||
|
||
public class ExcludedProperties { | ||
|
||
public static void parameters() { | ||
int i = MyOther.identity(21); | ||
assert (i == 21); | ||
} | ||
|
||
public static void compileTimeReturnType() { | ||
Parent p = MyOther.subclass(); | ||
assert (p == null || p instanceof Parent); | ||
if (p == null) { | ||
assert false; // reachable with "return nondet" body | ||
} else { | ||
if (p.num() == 1) { | ||
assert false; // reachable with "return nondet" body | ||
} else { | ||
assert false; // reachable with "return nondet" body | ||
} | ||
} | ||
} | ||
|
||
public static void runtimeReturnType() { | ||
Parent p = MyOther.subclass(); | ||
assert (p == null || p instanceof Child); | ||
} | ||
} |
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+262 Bytes
jbmc/regression/jbmc/context-include-exclude/org/cprover/other/Child.class
Binary file not shown.
6 changes: 6 additions & 0 deletions
6
jbmc/regression/jbmc/context-include-exclude/org/cprover/other/Child.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package org.cprover.other; | ||
|
||
public class Child extends Parent { | ||
|
||
public int num() { return 2; } | ||
} |
Binary file added
BIN
+386 Bytes
jbmc/regression/jbmc/context-include-exclude/org/cprover/other/MyOther.class
Binary file not shown.
8 changes: 8 additions & 0 deletions
8
jbmc/regression/jbmc/context-include-exclude/org/cprover/other/MyOther.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.cprover.other; | ||
|
||
public class MyOther { | ||
|
||
public static int identity(int x) { return x; } | ||
|
||
public static Parent subclass() { return new Child(); } | ||
} |
Binary file added
BIN
+298 Bytes
jbmc/regression/jbmc/context-include-exclude/org/cprover/other/Parent.class
Binary file not shown.
8 changes: 8 additions & 0 deletions
8
jbmc/regression/jbmc/context-include-exclude/org/cprover/other/Parent.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.cprover.other; | ||
|
||
public class Parent { | ||
|
||
int field = 1; | ||
|
||
public int num() { return field; } | ||
} |
14 changes: 14 additions & 0 deletions
14
jbmc/regression/jbmc/context-include-exclude/test_exclude_absent.desc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
CORE | ||
Main.class | ||
--context-exclude org.cprover.oh | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
.* line 12 assertion at file Main.java line 12 .*: SUCCESS | ||
.* line 13 assertion at file Main.java line 13 .*: SUCCESS | ||
.* line 14 assertion at file Main.java line 14 .*: SUCCESS | ||
.* line 15 assertion at file Main.java line 15 .*: SUCCESS | ||
-- | ||
WARNING: no body for function .* | ||
-- | ||
Tests that when --context-exclude is given a package prefix that does not occur | ||
anywhere on the classpath, it has no effect. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
jbmc/regression/jbmc/context-include-exclude/test_exclude_package_prefix.desc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
CORE | ||
Main.class | ||
--context-include Main --context-include org.cprover --context-exclude org.cprover.ot | ||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
.* line 12 assertion at file Main.java line 12 .*: SUCCESS | ||
.* line 13 assertion at file Main.java line 13 .*: SUCCESS | ||
.* line 14 assertion at file Main.java line 14 .*: SUCCESS | ||
.* line 15 assertion at file Main.java line 15 .*: FAILURE | ||
-- | ||
WARNING: no body for function .* | ||
-- | ||
Tests that --context-exclude works with an argument that is the prefix of a | ||
package name. |
12 changes: 12 additions & 0 deletions
12
jbmc/regression/jbmc/context-include-exclude/test_excluded_deleted_original_body.desc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
CORE | ||
ExcludedProperties.class | ||
--context-exclude org.cprover.other --function ExcludedProperties.runtimeReturnType | ||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
.* line 28 assertion at file ExcludedProperties.java line 28.*: FAILURE | ||
-- | ||
-- | ||
Test that for an excluded method, we do not convert its "real" body from the | ||
bytecode. | ||
We instead assign it a "return nondet" body as for stubbed methods, which is | ||
tested by test_excluded_has_nondet_body.desc. |
15 changes: 15 additions & 0 deletions
15
jbmc/regression/jbmc/context-include-exclude/test_excluded_has_nondet_body.desc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
CORE | ||
ExcludedProperties.class | ||
--context-exclude org.cprover.other --function ExcludedProperties.compileTimeReturnType | ||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
.* line 14 assertion at file ExcludedProperties.java line 14 .*: SUCCESS | ||
.* line 16 assertion at file ExcludedProperties.java line 16 .*: FAILURE | ||
.* line 19 assertion at file ExcludedProperties.java line 19 .*: FAILURE | ||
.* line 21 assertion at file ExcludedProperties.java line 21 .*: FAILURE | ||
-- | ||
-- | ||
Test that for an excluded method, we keep the information about the | ||
(compile-time) return type of the method and return a nondet object of that | ||
type, or null. | ||
Note that we do this in the same way as for stubbed methods. |
13 changes: 13 additions & 0 deletions
13
jbmc/regression/jbmc/context-include-exclude/test_excluded_has_parameter_info.desc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
CORE | ||
ExcludedProperties.class | ||
--context-exclude org.cprover.other --show-symbol-table --function ExcludedProperties.parameters | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
java::org\.cprover\.other\.MyOther\.identity:\(I\)I::arg0i | ||
-- | ||
java::org\.cprover\.other\.MyOther\.identity:\(I\)I::stub | ||
-- | ||
Test that for an excluded method, we still create a symbol for its parameter(s) | ||
just like for non-excluded methods. | ||
Only the body of excluded methods should be missing, not their signature or | ||
other "meta-information". |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -425,7 +425,8 @@ static irep_idt get_method_identifier( | |
|
||
void java_bytecode_convert_methodt::convert( | ||
const symbolt &class_symbol, | ||
const methodt &m) | ||
const methodt &m, | ||
const optionalt<prefix_filtert> &method_context) | ||
{ | ||
// Construct the fully qualified method name | ||
// (e.g. "my.package.ClassName.myMethodName:(II)I") and query the symbol table | ||
|
@@ -605,8 +606,12 @@ void java_bytecode_convert_methodt::convert( | |
if((!m.is_abstract) && (!m.is_native)) | ||
{ | ||
code_blockt code(convert_parameter_annotations(m, method_type)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this line outside the if? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it should be inside. Antonia is away for three days, so I've made a follow-up PR to make this change: #5121 |
||
code.append(convert_instructions(m)); | ||
method_symbol.value = std::move(code); | ||
// Do not convert if method is not in context | ||
if(!method_context || (*method_context)(id2string(method_identifier))) | ||
{ | ||
code.append(convert_instructions(m)); | ||
method_symbol.value = std::move(code); | ||
} | ||
} | ||
} | ||
|
||
|
@@ -3184,7 +3189,8 @@ void java_bytecode_convert_method( | |
optionalt<ci_lazy_methods_neededt> needed_lazy_methods, | ||
java_string_library_preprocesst &string_preprocess, | ||
const class_hierarchyt &class_hierarchy, | ||
bool threading_support) | ||
bool threading_support, | ||
const optionalt<prefix_filtert> &method_context) | ||
|
||
{ | ||
java_bytecode_convert_methodt java_bytecode_convert_method( | ||
|
@@ -3197,7 +3203,7 @@ void java_bytecode_convert_method( | |
class_hierarchy, | ||
threading_support); | ||
|
||
java_bytecode_convert_method(class_symbol, method); | ||
java_bytecode_convert_method(class_symbol, method, method_context); | ||
} | ||
|
||
/// Returns true iff method \p methodid from class \p classname is | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ Author: Daniel Kroening, [email protected] | |
#include <util/symbol_table.h> | ||
|
||
class class_hierarchyt; | ||
class prefix_filtert; | ||
|
||
void java_bytecode_initialize_parameter_names( | ||
symbolt &method_symbol, | ||
|
@@ -37,7 +38,8 @@ void java_bytecode_convert_method( | |
optionalt<ci_lazy_methods_neededt> needed_lazy_methods, | ||
java_string_library_preprocesst &string_preprocess, | ||
const class_hierarchyt &class_hierarchy, | ||
bool threading_support); | ||
bool threading_support, | ||
const optionalt<prefix_filtert> &method_context); | ||
|
||
void create_method_stub_symbol( | ||
const irep_idt &identifier, | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 this one removed because it is useless, or does the warning now appear?
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.
Because it's (probably) useless. There is a test in a later commit that checks that the body of an excluded method is a stub-style "return nondet" body. Do you think it still makes sense to check for
WARNING: ...
as a negative regex everywhere?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.
If there is no way this warning could be produced for any input then it can be removed, otherwise it's probably safer to keep it in just in case.
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'm keeping it as a negative regex here now, and also added it as a negative regex in all existing tests and the new tests for exclude package and exclude absent.