-
Notifications
You must be signed in to change notification settings - Fork 274
Support null-pointer without operand in interpreter #2917
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
mgudemann
merged 4 commits into
diffblue:develop
from
mgudemann:fix/interpreter/null_pointer_no_operand
Sep 13, 2018
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
7857669
Correct input initialization in builtin function
romainbrenguier 207ca8c
Support null-pointer without operand in interpreter
df6c64f
Remove ID_address_of check for types as it can only be exprt
f7e9715
Add unit test for interpreter evaluation
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
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 |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/*******************************************************************\ | ||
|
||
Module: Interpreter unit tests. | ||
|
||
Author: Diffblue Ltd. | ||
|
||
\*******************************************************************/ | ||
|
||
#include <testing-utils/catch.hpp> | ||
|
||
#include <goto-programs/goto_functions.h> | ||
#include <goto-programs/interpreter_class.h> | ||
#include <util/message.h> | ||
#include <util/mp_arith.h> | ||
#include <util/namespace.h> | ||
|
||
typedef interpretert::mp_vectort mp_vectort; | ||
|
||
class interpreter_testt | ||
{ | ||
symbol_tablet symbol_table; | ||
goto_functionst goto_functions; | ||
null_message_handlert null_message_handler; | ||
interpretert interpreter; | ||
|
||
public: | ||
explicit interpreter_testt() | ||
: interpreter(symbol_table, goto_functions, null_message_handler) | ||
{ | ||
} | ||
|
||
mp_vectort evaluate(const exprt &expression) | ||
{ | ||
mp_vectort result; | ||
interpreter.evaluate(expression, result); | ||
return result; | ||
} | ||
}; | ||
|
||
SCENARIO("interpreter evaluation null pointer expressions") | ||
{ | ||
interpreter_testt interpreter_test; | ||
mp_vectort null_vector = {0}; | ||
|
||
THEN("null pointer without operands") | ||
{ | ||
unsignedbv_typet java_char(16); | ||
pointer_typet pointer_type(java_char, 64); | ||
|
||
constant_exprt constant_expr(ID_NULL, pointer_type); | ||
|
||
mp_vectort mp_vector = interpreter_test.evaluate(constant_expr); | ||
|
||
REQUIRE_THAT(mp_vector, Catch::Equals(null_vector)); | ||
} | ||
THEN("null pointer with operands") | ||
{ | ||
pointer_typet outer_pointer_type(empty_typet(), 64); | ||
constant_exprt outer_expression( | ||
"0000000000000000000000000000000000000000000000000000000000000000", | ||
outer_pointer_type); | ||
|
||
pointer_typet inner_pointer_type(empty_typet(), 64); | ||
constant_exprt inner_expression(ID_NULL, inner_pointer_type); | ||
|
||
outer_expression.move_to_operands(inner_expression); | ||
|
||
mp_vectort mp_vector = interpreter_test.evaluate(outer_expression); | ||
|
||
REQUIRE_THAT(mp_vector, Catch::Equals(null_vector)); | ||
} | ||
} |
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,3 @@ | ||
goto-programs | ||
testing-utils | ||
util |
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.
Uh oh!
There was an error while loading. Please reload this page.