-
Notifications
You must be signed in to change notification settings - Fork 274
fix exprt::opX accesses in java_bytecode #5018
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
Merged
Changes from all commits
Commits
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
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 |
---|---|---|
|
@@ -378,11 +378,10 @@ void java_bytecode_instrumentt::instrument_code(codet &code) | |
code_assert.assertion().operands().size()==2, | ||
"Instanceof should have 2 operands"); | ||
|
||
code= | ||
check_class_cast( | ||
code_assert.assertion().op0(), | ||
code_assert.assertion().op1(), | ||
code_assert.source_location()); | ||
const auto & instanceof = to_binary_expr(code_assert.assertion()); | ||
|
||
code = check_class_cast( | ||
instanceof.op0(), instanceof.op1(), code_assert.source_location()); | ||
} | ||
} | ||
else if(statement==ID_block) | ||
|
@@ -494,20 +493,23 @@ optionalt<codet> java_bytecode_instrumentt::instrument_expr(const exprt &expr) | |
{ | ||
// this corresponds to a throw and so we check that | ||
// we don't throw null | ||
result.add(check_null_dereference(expr.op0(), expr.source_location())); | ||
result.add(check_null_dereference( | ||
to_unary_expr(expr).op(), expr.source_location())); | ||
} | ||
else if(statement==ID_java_new_array) | ||
{ | ||
// this corresponds to new array so we check that | ||
// length is >=0 | ||
result.add(check_array_length(expr.op0(), expr.source_location())); | ||
result.add(check_array_length( | ||
to_multi_ary_expr(expr).op0(), expr.source_location())); | ||
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. Add a container for java_new_array? |
||
} | ||
} | ||
else if((expr.id()==ID_div || expr.id()==ID_mod) && | ||
expr.type().id()==ID_signedbv) | ||
{ | ||
// check division by zero (for integer types only) | ||
result.add(check_arithmetic_exception(expr.op1(), expr.source_location())); | ||
result.add(check_arithmetic_exception( | ||
to_binary_expr(expr).op1(), expr.source_location())); | ||
} | ||
else if(expr.id()==ID_dereference && | ||
expr.get_bool(ID_java_member_access)) | ||
|
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 |
---|---|---|
|
@@ -21,7 +21,8 @@ Author: Daniel Kroening, [email protected] | |
/// \return dereferenced pointer | ||
static exprt clean_deref(const exprt &ptr) | ||
{ | ||
return ptr.id() == ID_address_of ? ptr.op0() : dereference_exprt{ptr}; | ||
return ptr.id() == ID_address_of ? to_address_of_expr(ptr).object() | ||
: dereference_exprt{ptr}; | ||
} | ||
|
||
/// \par parameters: pointer | ||
|
@@ -71,7 +72,7 @@ static const exprt &look_through_casts(const exprt &in) | |
if(in.id()==ID_typecast) | ||
{ | ||
assert(in.type().id()==ID_pointer); | ||
return look_through_casts(in.op0()); | ||
return look_through_casts(to_typecast_expr(in).op()); | ||
} | ||
else | ||
return in; | ||
|
@@ -108,7 +109,7 @@ exprt make_clean_pointer_cast( | |
bare_ptr.type().id()==ID_pointer && | ||
"Non-pointer in make_clean_pointer_cast?"); | ||
if(bare_ptr.type().subtype() == java_void_type()) | ||
bare_ptr=bare_ptr.op0(); | ||
bare_ptr = to_typecast_expr(bare_ptr).op(); | ||
} | ||
|
||
assert( | ||
|
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
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.
We have
side_effect_expr_throwt
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.
yes, but that doesn't have operands -- will make that a separate PR.