-
Notifications
You must be signed in to change notification settings - Fork 277
C++ front-end: Use C factory for compiler builtins #2294
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
8 commits
Select commit
Hold shift + click to select a range
d597d90
Remove unused include
tautschnig c471f72
jdiff: remove C library
tautschnig c8702ab
CPROVER library linking: move status message to front-end
tautschnig 0ea6143
Make link_to_library independent of the C front-end
tautschnig ed05d3e
Refactor add_cprover_library to make parts re-usable by the C++ front…
tautschnig 0451f1e
C++ front-end now has its own library
tautschnig 1201ffe
C++ front-end: Use C factory for compiler builtins
tautschnig 4edecbc
Rename add_cprover_X_library to cprover_X_library_factory
tautschnig 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 |
---|---|---|
|
@@ -22,7 +22,6 @@ Author: Daniel Kroening, [email protected] | |
#include <goto-programs/goto_convert_functions.h> | ||
#include <goto-programs/goto_inline.h> | ||
#include <goto-programs/initialize_goto_model.h> | ||
#include <goto-programs/link_to_library.h> | ||
#include <goto-programs/read_goto_binary.h> | ||
#include <goto-programs/remove_complex.h> | ||
#include <goto-programs/remove_function_pointers.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
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,15 +14,7 @@ Author: Daniel Kroening, [email protected] | |
|
||
#include "ansi_c_language.h" | ||
|
||
struct cprover_library_entryt | ||
{ | ||
const char *function; | ||
const char *model; | ||
} cprover_library[]= | ||
#include "cprover_library.inc" | ||
; // NOLINT(whitespace/semicolon) | ||
|
||
std::string get_cprover_library_text( | ||
static std::string get_cprover_library_text( | ||
const std::set<irep_idt> &functions, | ||
const symbol_tablet &symbol_table) | ||
{ | ||
|
@@ -35,10 +27,29 @@ std::string get_cprover_library_text( | |
if(config.ansi_c.string_abstraction) | ||
library_text << "#define __CPROVER_STRING_ABSTRACTION\n"; | ||
|
||
// cprover_library.inc may not have been generated when running Doxygen, thus | ||
// make Doxygen skip this part | ||
/// \cond | ||
const struct cprover_library_entryt cprover_library[] = | ||
#include "cprover_library.inc" | ||
; // NOLINT(whitespace/semicolon) | ||
/// \endcond | ||
|
||
return get_cprover_library_text( | ||
functions, symbol_table, cprover_library, library_text.str()); | ||
} | ||
|
||
std::string get_cprover_library_text( | ||
const std::set<irep_idt> &functions, | ||
const symbol_tablet &symbol_table, | ||
const struct cprover_library_entryt cprover_library[], | ||
const std::string &prologue) | ||
{ | ||
std::ostringstream library_text(prologue); | ||
|
||
std::size_t count=0; | ||
|
||
for(cprover_library_entryt *e=cprover_library; | ||
e->function!=nullptr; | ||
for(const cprover_library_entryt *e = cprover_library; e->function != nullptr; | ||
e++) | ||
{ | ||
irep_idt id=e->function; | ||
|
@@ -63,7 +74,7 @@ std::string get_cprover_library_text( | |
return library_text.str(); | ||
} | ||
|
||
void add_cprover_library( | ||
void cprover_c_library_factory( | ||
const std::set<irep_idt> &functions, | ||
symbol_tablet &symbol_table, | ||
message_handlert &message_handler) | ||
|
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 |
---|---|---|
|
@@ -15,16 +15,24 @@ Author: Daniel Kroening, [email protected] | |
#include <util/symbol_table.h> | ||
#include <util/message.h> | ||
|
||
struct cprover_library_entryt | ||
{ | ||
const char *function; | ||
const char *model; | ||
}; | ||
|
||
std::string get_cprover_library_text( | ||
const std::set<irep_idt> &functions, | ||
const symbol_tablet &); | ||
const symbol_tablet &, | ||
const struct cprover_library_entryt[], | ||
const std::string &prologue); | ||
|
||
void add_library( | ||
const std::string &src, | ||
symbol_tablet &, | ||
message_handlert &); | ||
|
||
void add_cprover_library( | ||
void cprover_c_library_factory( | ||
const std::set<irep_idt> &functions, | ||
symbol_tablet &, | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,9 @@ Author: Daniel Kroening, [email protected] | |
#include <langapi/language.h> | ||
|
||
#include <ansi-c/c_preprocess.h> | ||
#include <ansi-c/cprover_library.h> | ||
|
||
#include <cpp/cprover_library.h> | ||
|
||
#include <goto-programs/adjust_float_expressions.h> | ||
#include <goto-programs/initialize_goto_model.h> | ||
|
@@ -711,7 +714,12 @@ bool cbmc_parse_optionst::process_goto_program( | |
remove_asm(goto_model); | ||
|
||
// add the library | ||
link_to_library(goto_model, log.get_message_handler()); | ||
log.status() << "Adding CPROVER library (" << config.ansi_c.arch << ")" | ||
<< eom; | ||
link_to_library( | ||
goto_model, log.get_message_handler(), cprover_cpp_library_factory); | ||
link_to_library( | ||
goto_model, log.get_message_handler(), cprover_c_library_factory); | ||
|
||
if(options.get_bool_option("string-abstraction")) | ||
string_instrumentation(goto_model, log.get_message_handler()); | ||
|
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 |
---|---|---|
|
@@ -27,7 +27,6 @@ Author: Daniel Kroening, [email protected] | |
#include <goto-programs/set_properties.h> | ||
#include <goto-programs/read_goto_binary.h> | ||
#include <goto-programs/loop_ids.h> | ||
#include <goto-programs/link_to_library.h> | ||
#include <goto-programs/goto_inline.h> | ||
#include <goto-programs/xml_goto_trace.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
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.
This cannot be right.
Uh oh!
There was an error while loading. Please reload this page.
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 afraid it can: expr2java builds upon expr2c. It was just previously hidden by the fact that
goto-programs
already provided the link toansi-c
.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.
Splitting these up is on the todo-list (meaning there should be some factoring out of what's common, and it should be done using the new format_expr stuff).