44#define DOTGRAPHSETTINGS "color=black;" \
45 "orientation=portrait;" \
44#define DOTGRAPHSETTINGS "color=black;" \ …
67 log.
debug() <<
"Library not found: " << library <<
" (ignoring)"
127 const std::string &file_name,
131 std::ifstream in(file_name);
135 const std::string::size_type
r = file_name.rfind(
'.');
137 const std::string
ext =
138 r == std::string::npos ?
"" : file_name.substr(
r + 1, file_name.length());
141 ext ==
"c" ||
ext ==
"cc" ||
ext ==
"cp" ||
ext ==
"cpp" ||
ext ==
"CPP" ||
142 ext ==
"c++" ||
ext ==
"C" ||
ext ==
"i" ||
ext ==
"ii" ||
ext ==
"class" ||
172 log.
warning() <<
"failed to open file '" << file_name
178 log.
debug() <<
"unknown file type in '" << file_name <<
"'"
184 log.
debug() <<
"ELF object without goto-cc section: '" << file_name <<
"'"
209 const std::string &file_name,
219 std::filesystem::current_path(
tmp_dirs.back());
253 while(!in.fail() && std::getline(in, line))
255 std::string t = std::filesystem::path(
tstr).append(line).string();
260 log.
debug() <<
"Object file is not a goto binary: " << line
280 std::filesystem::path(
library_path).append(
"lib" + name +
".a").string();
289 .append(
"lib" + name +
".so")
298 log.
warning() <<
"Warning: Cannot read ELF library "
322 if(symbol_table.has_value())
383 std::cout <<
get_base_name(file_name,
false) <<
'\n' << std::flush;
393 std::ifstream in(file_name, std::ios::binary);
452 return std::move(symbol_table);
458 const std::string &file_name,
473 else if(file_name !=
"-")
478 log.
error() <<
"failed to figure out type of file '" << file_name <<
"'"
490 log.
error() <<
"failed to open input file '" << file_name <<
"'"
502 std::ostream *os = &std::cout;
544 std::ostream *os = &std::cout;
575 const std::string &file_name,
588 log.
statistics() <<
"Writing binary format object '" << file_name <<
"'"
596 std::ofstream outfile(file_name, std::ios::binary);
598 if(!outfile.is_open())
620std::optional<symbol_tablet>
625 if(
parse(file_name, language_files))
653 cmdline.isset(
"export-function-local-symbols") ||
654 cmdline.isset(
"export-file-local-symbols")),
655 file_local_mangle_suffix(
656 cmdline.isset(
"mangle-suffix") ? cmdline.get_value(
"mangle-suffix") :
"")
666 <<
"The `--export-function-local-symbols` flag is deprecated. "
667 "Please use `--export-file-local-symbols` instead."
678 std::filesystem::remove_all(
dir);
683 std::size_t count = 0;
686 if(f.second.body_available())
708 symbol_tablet::symbolst::size_type before=0;
721 for(
const auto &symbol : symbols)
723 symbol_tablet::symbolst::const_iterator
s_it =
728 s_it->second.is_function() && !
s_it->second.is_compiled() &&
729 s_it->second.value.is_not_nil())
753 std::map<irep_idt, symbolt>::iterator old;
756 if(!inserted && old->second.type!=
new_type)
758 log.
error() <<
"Incompatible CPROVER macro symbol types:" <<
'\n'
759 << old->second.type.pretty() <<
"(at " << old->second.location
762 <<
new_type.pretty() <<
"(at " <<
pair.second.location <<
")"
bool ansi_c_entry_point(symbol_table_baset &symbol_table, message_handlert &message_handler, const c_object_factory_parameterst &object_factory_parameters)
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
std::string get_value(char option) const
virtual bool isset(char option) const
@ COMPILE_LINK_EXECUTABLE
void add_compiler_specific_defines() const
std::optional< symbol_tablet > compile()
Parses source files and writes object files, or keeps the symbols in the symbol_table if not compilin...
bool parse_stdin(languaget &)
parses a source file (low-level parsing)
bool parse(const std::string &filename, language_filest &)
parses a source file (low-level parsing)
std::string working_directory
std::list< std::string > tmp_dirs
std::string override_language
std::string output_file_object
bool add_input_file(const std::string &)
puts input file names into a list and does preprocessing for libraries.
std::list< std::string > libraries
std::string output_directory_object
std::list< std::string > object_files
bool link(std::optional< symbol_tablet > &&symbol_table)
parses object files and links them
bool doit()
reads and source and object files, compiles and links them into goto program objects.
std::list< std::string > source_files
~compilet()
cleans up temporary files
bool add_written_cprover_symbols(const symbol_tablet &symbol_table)
std::string object_file_extension
compilet(cmdlinet &_cmdline, message_handlert &mh, bool Werror)
constructor
const bool keep_file_local
Whether to keep implementations of file-local symbols.
static std::size_t function_body_count(const goto_functionst &)
void convert_symbols(goto_modelt &)
std::map< irep_idt, symbolt > written_macros
bool add_files_from_archive(const std::string &file_name, bool thin_archive)
extracts goto binaries from AR archive and add them as input files.
bool find_library(const std::string &)
tries to find a library object file that matches the given library name.
std::optional< symbol_tablet > parse_source(const std::string &)
Parses and type checks a source file located at file_name.
static bool write_bin_object_file(const std::string &file_name, const goto_modelt &src_goto_model, bool validate_goto_model, message_handlert &message_handler)
Writes the goto functions of src_goto_model to a binary format object file.
const std::string file_local_mangle_suffix
String to include in all mangled names.
std::list< std::string > library_paths
std::string output_file_executable
struct configt::ansi_ct ansi_c
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
bool starts_with(const char *s) const
equivalent of as_string().starts_with(s)
void convert_function(const irep_idt &identifier, goto_functionst::goto_functiont &result)
A collection of goto functions.
function_mapt function_map
static irep_idt entry_point()
Get the identifier of the entry point to a goto model.
symbol_tablet symbol_table
Symbol table.
goto_functionst goto_functions
GOTO functions.
bool typecheck(symbol_table_baset &symbol_table, const bool keep_file_local, message_handlert &message_handler)
language_filet & add_file(const std::string &filename)
bool final(symbol_table_baset &symbol_table)
virtual bool parse(std::istream &instream, const std::string &path, message_handlert &message_handler)=0
virtual bool preprocess(std::istream &instream, const std::string &path, std::ostream &outstream, message_handlert &)
std::size_t get_message_count(unsigned level) const
Class that provides messages with a built-in verbosity 'level'.
message_handlert & get_message_handler()
mstreamt & statistics() const
mstreamt & warning() const
mstreamt & status() const
bool remove(const irep_idt &name)
Remove a symbol from the symbol table.
const symbolst & symbols
Read-only field, used to look up symbols given their names.
static symbol_table_buildert wrap(symbol_table_baset &base_symbol_table)
The type of an expression, extends irept.
static file_typet detect_file_type(const std::string &file_name, message_handlert &message_handler)
Compile and link source and object files.
std::string get_base_name(const std::string &in, bool strip_suffix)
cleans a filename from path and extension
Goto Programs with Functions.
Abstract interface to support a programming language.
bool linking(symbol_table_baset &dest_symbol_table, const symbol_table_baset &new_symbol_table, message_handlert &message_handler)
Merges the symbol table new_symbol_table into dest_symbol_table, renaming symbols from new_symbol_tab...
std::unique_ptr< languaget > get_language_from_mode(const irep_idt &mode)
Get the language corresponding to the given mode.
std::unique_ptr< languaget > get_language_from_filename(const std::string &filename)
Get the language corresponding to the registered file name extensions.
Mangle names of file-local functions to make them unique.
#define FILE_LOCAL_PREFIX
bool is_goto_binary(const std::string &filename, message_handlert &message_handler)
bool read_objects_and_link(const std::list< std::string > &file_names, goto_modelt &dest, message_handlert &message_handler)
Reads object files and updates the config if any files were read.
int run(const std::string &what, const std::vector< std::string > &argv)
#define CHECK_RETURN(CONDITION)
#define UNREACHABLE
This should be used to mark dead code.
#define INITIALIZE_FUNCTION
int strncmp(const char *s1, const char *s2, size_t n)
int memcmp(const void *s1, const void *s2, size_t n)
std::string get_temporary_directory(const std::string &name_template)
#define widen_if_needed(s)
void validate_goto_model(const goto_functionst &goto_functions, const validation_modet vm, const goto_model_validation_optionst validation_options)
const char * CBMC_VERSION
static void write_goto_binary(std::ostream &out, const symbol_table_baset &symbol_table, const goto_functionst &goto_functions, irep_serializationt &irepconverter)
Writes a goto program to disc, using goto binary format.