-
Notifications
You must be signed in to change notification settings - Fork 273
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
Java nondet test gen support #607
Java nondet test gen support #607
Conversation
Update test.desc files with correct outcomes Fix formatting issues
Update generic testcase
Remove test case with multiple test methods
Remove mistakenly-added txt files Fix formatting issues
Add nondet recursive expansion to typecheck_expr
Update nondet generic test cases
Removed CProver.class
The new block type is replaced by a nondet initializer during bytecode conversion and typechecking. Add missing test case Make small fixes to test cases Fix formatting issues
These tests don't work as expected at the moment, because nondetWithoutNull has not been implemented yet.
src/util/std_code.cpp
Outdated
@@ -177,3 +177,4 @@ const codet &codet::last_statement() const | |||
|
|||
return *this; | |||
} | |||
|
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.
??
src/util/std_code.h
Outdated
static inline const side_effect_expr_nondett & | ||
to_side_effect_expr_nondet(const exprt &expr) | ||
{ | ||
const auto &x = to_side_effect_expr(expr); |
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.
cpplint
src/util/std_code.h
Outdated
static inline const side_effect_expr_nondett & | ||
to_side_effect_expr_nondet(const exprt &expr) | ||
{ | ||
const auto &x = to_side_effect_expr(expr); |
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.
better rename x
to side_effect_expr
@@ -47,11 +50,16 @@ void java_bytecode_typecheckt::typecheck_expr(exprt &expr) | |||
typecheck_expr_symbol(to_symbol_expr(expr)); | |||
else if(expr.id()==ID_side_effect) | |||
{ | |||
const irep_idt &statement=to_side_effect_expr(expr).get_statement(); | |||
auto &side_effect_expr = to_side_effect_expr(expr); |
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.
cpplint
@@ -43,7 +43,7 @@ class java_bytecode_typecheckt:public typecheckt | |||
{ | |||
} | |||
|
|||
virtual ~java_bytecode_typecheckt() { } | |||
virtual ~java_bytecode_typecheckt() = default; |
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.
Let's keep the old version in this PR. We can change this consistently in the whole code base in separate PR.
{ | ||
if(&(*it)==before_1) | ||
{ | ||
assert(it+1!=end); |
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.
This makes an assumption about the implementation of exprt::operandst. Use a second iterator and increment to point at the next element.
id_regex)) | ||
{ | ||
assert(2<=parents.size()); | ||
const auto before_1=*(parents.end()-1); |
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.
It's nicer to user decrements instead of pointer arithmetic here.
template <typename Func> | ||
static void traverse_expr_tree( | ||
exprt &expr, | ||
std::vector<exprt*> &parents, |
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.
exprt *
std::vector<exprt*> &parents, | ||
Func func) | ||
{ | ||
const auto& parents_ref=parents; |
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.
&parents
|
||
\*******************************************************************/ | ||
|
||
template <typename Func> |
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.
This function should go into util/expr_util.h
4671957
to
7fc5583
Compare
7fc5583
to
67697aa
Compare
There are failing tests: https://travis-ci.org/diffblue/cbmc/jobs/208984797#L1874 |
491ba2e
to
08cb9f5
Compare
08cb9f5
to
101a65d
Compare
In the case where we really want to create a nondet java.lang.Object, the java compiler does not emit a checkcast instruction, which means that our attempt to divine the nondet type using checkcast fails. This commit changes the behaviour of nondetWithNull so that it will create an Object if the following instruction is not a checkcast. The test nondetCastToObject tests this behaviour.
ba4628e
to
8321fa8
Compare
Only allow "returnValue" value for location field in JSON rules file
Adds support for modelling nondet values explicitly in Java code.
Tests demonstrating the new Java interface are located in
regression/cbmc-java/nondet*
. For objects, the interface has been simplified:Foo f = CProver.nondetWithNull();
Currently, all nondet objects may be initialised to
null
, because of the opaque method stubbing behaviour. An extra methodCProver.nondetWithoutNull()
could be added in the future, if the method stubbing were modified to allow non-null initialisation.The build succeeds but some of the added nondet tests fail.
The proper functioning of the code in this pull request depends on the opaque-stubbing behaviour (from java_opaque_method_stubs.h), which hasn't made its way into cbmc/test-gen-support yet. The feature will work properly once this feature is also merged in.