-
Notifications
You must be signed in to change notification settings - Fork 274
Standardise interface for accessing the owner of a symbol #4455
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 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4761070
Add owning class functions as interface to the owner of a symbol
thomasspriggs bd2bacd
Use owning class functions as interface to the owner of a symbol
thomasspriggs 242bb0f
Rename `owning_class` to `declaring_class`
thomasspriggs ba971c0
Fix missing declaring class of opaque methods
thomasspriggs 115417a
Add unit tests covering method parsing setting `declaring_class`
thomasspriggs 65e3d31
Test that parsed static fields have correct `declaring_class`
thomasspriggs 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ Author: Chris Smowton, [email protected] | |
/// Unwind loops in static initializers | ||
|
||
#include "java_enum_static_init_unwind_handler.h" | ||
#include "java_utils.h" | ||
|
||
#include <util/invariant.h> | ||
#include <util/suffix.h> | ||
|
@@ -76,11 +77,10 @@ tvt java_enum_static_init_unwind_handler( | |
return tvt::unknown(); | ||
|
||
const symbolt &function_symbol = symbol_table.lookup_ref(enum_function_id); | ||
irep_idt class_id = function_symbol.type.get(ID_C_class); | ||
INVARIANT( | ||
!class_id.empty(), "functions should have their defining class annotated"); | ||
const auto class_id = owning_class(function_symbol); | ||
INVARIANT(class_id, "Java methods should have a defining class."); | ||
|
||
const typet &class_type = symbol_table.lookup_ref(class_id).type; | ||
const typet &class_type = symbol_table.lookup_ref(*class_id).type; | ||
size_t unwinds = class_type.get_size_t(ID_java_enum_static_unwind); | ||
if(unwinds != 0 && unwind_count < unwinds) | ||
{ | ||
|
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 |
---|---|---|
|
@@ -14,6 +14,7 @@ Author: Daniel Kroening, [email protected] | |
#include <unordered_set> | ||
|
||
#include <util/message.h> | ||
#include <util/optional.h> | ||
#include <util/std_expr.h> | ||
#include <util/symbol_table.h> | ||
|
||
|
@@ -115,4 +116,14 @@ symbolt &fresh_java_symbol( | |
const irep_idt &function_name, | ||
symbol_table_baset &symbol_table); | ||
|
||
/// Gets the identifier of the class which owns a given \p symbol. If the symbol | ||
/// is not owned by a class the an empty optional is returned. This is used for | ||
/// method symbols and static field symbols to link them back to the class which | ||
/// owns them. | ||
optionalt<irep_idt> owning_class(const symbolt &symbol); | ||
|
||
/// Sets the identifier of the class which owns a given \p symbol to \p | ||
/// owning_class. | ||
void set_owning_class(symbolt &symbol, const irep_idt &owning_class); | ||
|
||
#endif // CPROVER_JAVA_BYTECODE_JAVA_UTILS_H |
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.
⛏️ Lower down (line 537) you have a writeable ref for this symbol already which is used to update the type. It might be nicer to keep the mutation in one place and do this call down there
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 tried putting it lower down and things didn't work properly. I guess it must be read back somewhere between the two locations.