-
Notifications
You must be signed in to change notification settings - Fork 284
Add analysis cache #3204
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
Closed
Closed
Add analysis cache #3204
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7f40646
Adding object_cachet
JohnDumbell bbc2701
Adding new constructor to class_hierarchy
JohnDumbell aca4040
Fix whitespace error
JohnDumbell 8148adc
remove_instanceof: compute the class hierarchy on demand
JohnDumbell bf6fdec
remove_exceptions: compute the class hierarchy on demand
JohnDumbell 71ea34d
Update test to use goto_modelt and goto_model_functiont with remove_e…
JohnDumbell 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 |
|---|---|---|
|
|
@@ -11,7 +11,6 @@ Author: Chris Smowton, [email protected] | |
|
|
||
| #include "remove_instanceof.h" | ||
|
|
||
| #include <goto-programs/class_hierarchy.h> | ||
| #include <goto-programs/class_identifier.h> | ||
| #include <goto-programs/goto_convert.h> | ||
|
|
||
|
|
@@ -24,12 +23,14 @@ class remove_instanceoft | |
| { | ||
| public: | ||
| remove_instanceoft( | ||
| symbol_table_baset &symbol_table, message_handlert &message_handler) | ||
| : symbol_table(symbol_table) | ||
| , ns(symbol_table) | ||
| , message_handler(message_handler) | ||
| symbol_table_baset &symbol_table, | ||
| const class_hierarchyt &class_hierarchy, | ||
| message_handlert &message_handler) | ||
| : symbol_table(symbol_table), | ||
| ns(symbol_table), | ||
| class_hierarchy(class_hierarchy), | ||
| message_handler(message_handler) | ||
| { | ||
| class_hierarchy(symbol_table); | ||
| } | ||
|
|
||
| // Lower instanceof for a single function | ||
|
|
@@ -41,7 +42,7 @@ class remove_instanceoft | |
| protected: | ||
| symbol_table_baset &symbol_table; | ||
| namespacet ns; | ||
| class_hierarchyt class_hierarchy; | ||
| const class_hierarchyt &class_hierarchy; | ||
| message_handlert &message_handler; | ||
|
|
||
| bool lower_instanceof( | ||
|
|
@@ -245,44 +246,30 @@ void remove_instanceof( | |
| goto_programt::targett target, | ||
| goto_programt &goto_program, | ||
| symbol_table_baset &symbol_table, | ||
| const class_hierarchyt &class_hierarchy, | ||
| message_handlert &message_handler) | ||
| { | ||
| remove_instanceoft rem(symbol_table, message_handler); | ||
| remove_instanceoft rem(symbol_table, class_hierarchy, message_handler); | ||
| rem.lower_instanceof(goto_program, target); | ||
| } | ||
|
|
||
| /// Replace every instanceof in the passed function with an explicit | ||
| /// class-identifier test. | ||
| /// \remarks Extra auxiliary variables may be introduced into symbol_table. | ||
| /// \param function: The function to work on. | ||
| /// \param symbol_table: The symbol table to add symbols to. | ||
| /// \remarks Extra auxiliary variables may be introduced into | ||
| /// goto_model_function's symbol_table. | ||
| /// \param goto_model_function: The function to work on. | ||
| /// \param message_handler: logging output | ||
| void remove_instanceof( | ||
| goto_functionst::goto_functiont &function, | ||
| symbol_table_baset &symbol_table, | ||
| goto_model_functiont &goto_model_function, | ||
| message_handlert &message_handler) | ||
| { | ||
| remove_instanceoft rem(symbol_table, message_handler); | ||
| rem.lower_instanceof(function.body); | ||
| } | ||
| symbol_table_baset &symbol_table = goto_model_function.get_symbol_table(); | ||
| const class_hierarchyt &class_hierarchy( | ||
| goto_model_function.get_analysis_cache().get_or_create<class_hierarchyt>( | ||
| symbol_table)); | ||
|
|
||
| /// Replace every instanceof in every function with an explicit | ||
| /// class-identifier test. | ||
| /// \remarks Extra auxiliary variables may be introduced into symbol_table. | ||
| /// \param goto_functions: The functions to work on. | ||
| /// \param symbol_table: The symbol table to add symbols to. | ||
| /// \param message_handler: logging output | ||
| void remove_instanceof( | ||
| goto_functionst &goto_functions, | ||
| symbol_table_baset &symbol_table, | ||
| message_handlert &message_handler) | ||
| { | ||
| remove_instanceoft rem(symbol_table, message_handler); | ||
| bool changed=false; | ||
| for(auto &f : goto_functions.function_map) | ||
| changed=rem.lower_instanceof(f.second.body) || changed; | ||
| if(changed) | ||
| goto_functions.compute_location_numbers(); | ||
| remove_instanceoft rem(symbol_table, class_hierarchy, message_handler); | ||
| rem.lower_instanceof(goto_model_function.get_goto_function().body); | ||
| } | ||
|
|
||
| /// Replace every instanceof in every function with an explicit | ||
|
|
@@ -295,6 +282,14 @@ void remove_instanceof( | |
| goto_modelt &goto_model, | ||
| message_handlert &message_handler) | ||
| { | ||
| remove_instanceof( | ||
| goto_model.goto_functions, goto_model.symbol_table, message_handler); | ||
| const class_hierarchyt &class_hierarchy( | ||
| goto_model.get_analysis_cache().get_or_create<class_hierarchyt>( | ||
| goto_model.symbol_table)); | ||
| remove_instanceoft rem( | ||
| goto_model.symbol_table, class_hierarchy, message_handler); | ||
| bool changed=false; | ||
| for(auto &f : goto_model.goto_functions.function_map) | ||
| changed=rem.lower_instanceof(f.second.body) || changed; | ||
| if(changed) | ||
| goto_model.goto_functions.compute_location_numbers(); | ||
| } | ||
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 |
|---|---|---|
|
|
@@ -79,6 +79,7 @@ Author: Chris Smowton, [email protected] | |
| #ifndef CPROVER_JAVA_BYTECODE_REMOVE_INSTANCEOF_H | ||
| #define CPROVER_JAVA_BYTECODE_REMOVE_INSTANCEOF_H | ||
|
|
||
| #include <goto-programs/class_hierarchy.h> | ||
| #include <goto-programs/goto_functions.h> | ||
| #include <goto-programs/goto_model.h> | ||
|
|
||
|
|
@@ -89,16 +90,15 @@ void remove_instanceof( | |
| goto_programt::targett target, | ||
| goto_programt &goto_program, | ||
| symbol_table_baset &symbol_table, | ||
| const class_hierarchyt &class_hierarchy, | ||
| message_handlert &); | ||
|
|
||
| void remove_instanceof( | ||
| goto_functionst::goto_functiont &function, | ||
| symbol_table_baset &symbol_table, | ||
| goto_model_functiont &goto_model_function, | ||
| message_handlert &); | ||
|
|
||
| void remove_instanceof( | ||
| goto_functionst &goto_functions, | ||
| symbol_table_baset &symbol_table, | ||
| goto_modelt &goto_model, | ||
| message_handlert &); | ||
|
|
||
| void remove_instanceof(goto_modelt &model, message_handlert &); | ||
|
|
||
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
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.
Unusual to initialise a reference using brackets rather than = (repeated below)