-
Notifications
You must be signed in to change notification settings - Fork 273
Linking: perform macro expansion and type updates just once #2254
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
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 |
---|---|---|
|
@@ -12,12 +12,24 @@ Author: Daniel Kroening, [email protected] | |
#ifndef CPROVER_GOTO_PROGRAMS_LINK_GOTO_MODEL_H | ||
#define CPROVER_GOTO_PROGRAMS_LINK_GOTO_MODEL_H | ||
|
||
#include <util/nodiscard.h> | ||
#include <util/replace_symbol.h> | ||
|
||
class goto_modelt; | ||
class message_handlert; | ||
|
||
void link_goto_model( | ||
/// Link goto model \p src into goto model \p dest, invalidating \p src in this | ||
/// process. Linking may require updates to object types contained in \p dest, | ||
/// which need to be applied using \ref finalize_linking. | ||
/// \return nullopt if linking fails, else a (possibly empty) collection of | ||
/// replacements to be applied. | ||
NODISCARD optionalt<replace_symbolt::expr_mapt> | ||
link_goto_model(goto_modelt &dest, goto_modelt &&src, message_handlert &); | ||
|
||
/// Apply \p type_updates to \p dest, where \p type_updates were constructed | ||
/// from one or more calls to \p link_goto_model. | ||
void finalize_linking( | ||
goto_modelt &dest, | ||
goto_modelt &src, | ||
message_handlert &); | ||
const replace_symbolt::expr_mapt &type_updates); | ||
|
||
#endif // CPROVER_GOTO_PROGRAMS_LINK_GOTO_MODEL_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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,29 +12,27 @@ Author: Daniel Kroening, [email protected] | |
#ifndef CPROVER_GOTO_PROGRAMS_READ_GOTO_BINARY_H | ||
#define CPROVER_GOTO_PROGRAMS_READ_GOTO_BINARY_H | ||
|
||
#include <list> | ||
#include <string> | ||
|
||
#include <util/optional.h> | ||
|
||
class goto_functionst; | ||
class goto_modelt; | ||
class message_handlert; | ||
class symbol_tablet; | ||
|
||
optionalt<goto_modelt> | ||
read_goto_binary(const std::string &filename, message_handlert &); | ||
|
||
bool is_goto_binary(const std::string &filename, message_handlert &); | ||
|
||
bool read_object_and_link( | ||
const std::string &file_name, | ||
symbol_tablet &, | ||
goto_functionst &, | ||
message_handlert &); | ||
|
||
bool read_object_and_link( | ||
const std::string &file_name, | ||
goto_modelt &, | ||
message_handlert &); | ||
/// Reads object files and updates the config if any files were read. | ||
/// \param file_names: file names of goto binaries; if empty, just returns false | ||
/// \param dest: goto model to update | ||
/// \param message_handler: for diagnostics | ||
/// \return True on error, false otherwise | ||
bool read_objects_and_link( | ||
const std::list<std::string> &file_names, | ||
goto_modelt &dest, | ||
message_handlert &message_handler); | ||
|
||
#endif // CPROVER_GOTO_PROGRAMS_READ_GOTO_BINARY_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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ json-symtab-language | |
langapi | ||
goto-programs | ||
ansi-c | ||
linking |
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.
std::list
is quite surprising -- do we really need any oflist
's properties (cheap insert / delete, stable iterators)? If not I'd stick withvector
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'd prefer to say "use whatever SequenceContainer you want," but then I can't do that unless I add a template parameter. The difference will not be measurable. The number of entries will typically be a very small number, with the 1000-2000 entries that the Linux kernel yields being close to an upper bound. I have picked
std::list
, because the number of entries is not known a priori incompilet
, and hence append-at-the-end would be inefficient withstd::vector
. Again, "inefficient" in theory, practically not measurably so.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.
ok, not a big deal either way
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'm not going to insist on using
std::list
either - but I did have to change one or the other, and if you want me to flip a coin I can do that as well :-)