cprover
compile.cpp
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Compile and link source and object files.
4 
5 Author: CM Wintersteiger
6 
7 Date: June 2006
8 
9 \*******************************************************************/
10 
13 
14 #include "compile.h"
15 
16 #include <cstring>
17 #include <fstream>
18 #include <iostream>
19 
20 #include <util/cmdline.h>
21 #include <util/config.h>
22 #include <util/file_util.h>
23 #include <util/get_base_name.h>
24 #include <util/prefix.h>
25 #include <util/run.h>
27 #include <util/tempdir.h>
28 #include <util/tempfile.h>
29 #include <util/version.h>
30 
31 #ifdef _MSC_VER
32 # include <util/unicode.h>
33 #endif
34 
37 
42 
43 #include <langapi/language.h>
44 #include <langapi/language_file.h>
45 #include <langapi/mode.h>
46 
47 #include <linking/linking.h>
49 
50 #define DOTGRAPHSETTINGS "color=black;" \
51  "orientation=portrait;" \
52  "fontsize=20;"\
53  "compound=true;"\
54  "size=\"30,40\";"\
55  "ratio=compress;"
56 
61 {
63 
64  // Parse command line for source and object file names
65  for(const auto &arg : cmdline.args)
66  if(add_input_file(arg))
67  return true;
68 
69  for(const auto &library : libraries)
70  {
71  if(!find_library(library))
72  // GCC is going to complain if this doesn't exist
73  log.debug() << "Library not found: " << library << " (ignoring)"
74  << messaget::eom;
75  }
76 
77  log.statistics() << "No. of source files: " << source_files.size()
78  << messaget::eom;
79  log.statistics() << "No. of object files: " << object_files.size()
80  << messaget::eom;
81 
82  // Work through the given source files
83 
84  if(source_files.empty() && object_files.empty())
85  {
86  log.error() << "no input files" << messaget::eom;
87  return true;
88  }
89 
90  if(mode==LINK_LIBRARY && !source_files.empty())
91  {
92  log.error() << "cannot link source files" << messaget::eom;
93  return true;
94  }
95 
96  if(mode==PREPROCESS_ONLY && !object_files.empty())
97  {
98  log.error() << "cannot preprocess object files" << messaget::eom;
99  return true;
100  }
101 
102  const unsigned warnings_before =
104 
105  auto symbol_table_opt = compile();
106  if(!symbol_table_opt.has_value())
107  return true;
108 
109  if(mode==LINK_LIBRARY ||
110  mode==COMPILE_LINK ||
112  {
113  if(link(*symbol_table_opt))
114  return true;
115  }
116 
118  messaget::M_WARNING) != warnings_before;
119 }
120 
121 enum class file_typet
122 {
124  UNKNOWN,
125  SOURCE_FILE,
127  THIN_ARCHIVE,
128  GOTO_BINARY,
129  ELF_OBJECT
130 };
131 
133  const std::string &file_name,
134  message_handlert &message_handler)
135 {
136  // first of all, try to open the file
137  std::ifstream in(file_name);
138  if(!in)
140 
141  const std::string::size_type r = file_name.rfind('.');
142 
143  const std::string ext =
144  r == std::string::npos ? "" : file_name.substr(r + 1, file_name.length());
145 
146  if(
147  ext == "c" || ext == "cc" || ext == "cp" || ext == "cpp" || ext == "CPP" ||
148  ext == "c++" || ext == "C" || ext == "i" || ext == "ii" || ext == "class" ||
149  ext == "jar" || ext == "jsil")
150  {
152  }
153 
154  char hdr[8];
155  in.get(hdr, 8);
156  if((ext == "a" || ext == "o") && strncmp(hdr, "!<thin>", 8) == 0)
158 
159  if(ext == "a")
161 
162  if(is_goto_binary(file_name, message_handler))
164 
165  if(hdr[0] == 0x7f && memcmp(hdr + 1, "ELF", 3) == 0)
166  return file_typet::ELF_OBJECT;
167 
168  return file_typet::UNKNOWN;
169 }
170 
173 bool compilet::add_input_file(const std::string &file_name)
174 {
175  switch(detect_file_type(file_name, log.get_message_handler()))
176  {
178  log.warning() << "failed to open file '" << file_name
179  << "': " << std::strerror(errno) << messaget::eom;
180  return warning_is_fatal; // generously ignore unless -Werror
181 
182  case file_typet::UNKNOWN:
183  // unknown extension, not a goto binary, will silently ignore
184  log.debug() << "unknown file type in '" << file_name << "'"
185  << messaget::eom;
186  return false;
187 
189  // ELF file without goto-cc section, silently ignore
190  log.debug() << "ELF object without goto-cc section: '" << file_name << "'"
191  << messaget::eom;
192  return false;
193 
195  source_files.push_back(file_name);
196  return false;
197 
199  return add_files_from_archive(file_name, false);
200 
202  return add_files_from_archive(file_name, true);
203 
205  object_files.push_back(file_name);
206  return false;
207  }
208 
209  UNREACHABLE;
210 }
211 
215  const std::string &file_name,
216  bool thin_archive)
217 {
218  std::string tstr = working_directory;
219 
220  if(!thin_archive)
221  {
222  tstr = get_temporary_directory("goto-cc.XXXXXX");
223 
224  tmp_dirs.push_back(tstr);
225  set_current_path(tmp_dirs.back());
226 
227  // unpack now
228  int ret =
229  run("ar", {"ar", "x", concat_dir_file(working_directory, file_name)});
230  if(ret != 0)
231  {
232  log.error() << "Failed to extract archive " << file_name << messaget::eom;
233  return true;
234  }
235  }
236 
237  // add the files from "ar t"
238  temporary_filet tmp_file_out("", "");
239  int ret = run(
240  "ar",
241  {"ar", "t", concat_dir_file(working_directory, file_name)},
242  "",
243  tmp_file_out(),
244  "");
245  if(ret != 0)
246  {
247  log.error() << "Failed to list archive " << file_name << messaget::eom;
248  return true;
249  }
250 
251  std::ifstream in(tmp_file_out());
252  std::string line;
253 
254  while(!in.fail() && std::getline(in, line))
255  {
256  std::string t = concat_dir_file(tstr, line);
257 
259  object_files.push_back(t);
260  else
261  log.debug() << "Object file is not a goto binary: " << line
262  << messaget::eom;
263  }
264 
265  if(!thin_archive)
267 
268  return false;
269 }
270 
274 bool compilet::find_library(const std::string &name)
275 {
276  std::string library_file_name;
277 
278  for(const auto &library_path : library_paths)
279  {
280  library_file_name = concat_dir_file(library_path, "lib" + name + ".a");
281 
282  std::ifstream in(library_file_name);
283 
284  if(in.is_open())
285  return !add_input_file(library_file_name);
286  else
287  {
288  library_file_name = concat_dir_file(library_path, "lib" + name + ".so");
289 
290  switch(detect_file_type(library_file_name, log.get_message_handler()))
291  {
293  return !add_input_file(library_file_name);
294 
296  log.warning() << "Warning: Cannot read ELF library "
297  << library_file_name << messaget::eom;
298  return warning_is_fatal;
299 
304  case file_typet::UNKNOWN:
305  break;
306  }
307  }
308  }
309 
310  return false;
311 }
312 
316 {
317  // "compile" hitherto uncompiled functions
318  log.statistics() << "Compiling functions" << messaget::eom;
319  goto_modelt goto_model;
320  if(symbol_table.has_value())
321  goto_model.symbol_table = std::move(*symbol_table);
322  convert_symbols(goto_model);
323 
324  // parse object files
325  for(const auto &file_name : object_files)
326  {
327  if(read_object_and_link(file_name, goto_model, log.get_message_handler()))
328  return true;
329  }
330 
331  // produce entry point?
332 
334  {
335  // new symbols may have been added to a previously linked file
336  // make sure a new entry point is created that contains all
337  // static initializers
339 
341  goto_model.goto_functions.function_map.erase(
343 
344  const bool error = ansi_c_entry_point(
345  goto_model.symbol_table,
348 
349  if(error)
350  return true;
351 
352  // entry_point may (should) add some more functions.
353  convert_symbols(goto_model);
354  }
355 
356  if(keep_file_local)
357  {
360  mangler.mangle();
361  }
362 
364  return true;
365 
366  return add_written_cprover_symbols(goto_model.symbol_table);
367 }
368 
373 {
374  symbol_tablet symbol_table;
375 
376  while(!source_files.empty())
377  {
378  std::string file_name=source_files.front();
379  source_files.pop_front();
380 
381  // Visual Studio always prints the name of the file it's doing
382  // onto stdout. The name of the directory is stripped.
383  if(echo_file_name)
384  std::cout << get_base_name(file_name, false) << '\n' << std::flush;
385 
386  auto file_symbol_table = parse_source(file_name);
387 
388  if(!file_symbol_table.has_value())
389  {
390  const std::string &debug_outfile=
391  cmdline.get_value("print-rejected-preprocessed-source");
392  if(!debug_outfile.empty())
393  {
394  std::ifstream in(file_name, std::ios::binary);
395  std::ofstream out(debug_outfile, std::ios::binary);
396  out << in.rdbuf();
397  log.warning() << "Failed sources in " << debug_outfile << messaget::eom;
398  }
399 
400  return {}; // parser/typecheck error
401  }
402 
404  {
405  // output an object file for every source file
406 
407  // "compile" functions
408  goto_modelt file_goto_model;
409  file_goto_model.symbol_table = std::move(*file_symbol_table);
410  convert_symbols(file_goto_model);
411 
412  std::string cfn;
413 
414  if(output_file_object.empty())
415  {
416  const std::string file_name_with_obj_ext =
417  get_base_name(file_name, true) + "." + object_file_extension;
418 
419  if(!output_directory_object.empty())
420  cfn = concat_dir_file(output_directory_object, file_name_with_obj_ext);
421  else
422  cfn = file_name_with_obj_ext;
423  }
424  else
425  cfn = output_file_object;
426 
427  if(keep_file_local)
428  {
430  log.get_message_handler(), file_goto_model, file_local_mangle_suffix);
431  mangler.mangle();
432  }
433 
434  if(write_bin_object_file(cfn, file_goto_model))
435  return {};
436 
437  if(add_written_cprover_symbols(file_goto_model.symbol_table))
438  return {};
439  }
440  else
441  {
442  if(linking(symbol_table, *file_symbol_table, log.get_message_handler()))
443  {
444  return {};
445  }
446  }
447  }
448 
449  return std::move(symbol_table);
450 }
451 
455  const std::string &file_name,
456  language_filest &language_files)
457 {
458  std::unique_ptr<languaget> languagep;
459 
460  // Using '-x', the type of a file can be overridden;
461  // otherwise, it's guessed from the extension.
462 
463  if(!override_language.empty())
464  {
465  if(override_language=="c++" || override_language=="c++-header")
466  languagep = get_language_from_mode(ID_cpp);
467  else
468  languagep = get_language_from_mode(ID_C);
469  }
470  else if(file_name != "-")
471  languagep=get_language_from_filename(file_name);
472 
473  if(languagep==nullptr)
474  {
475  log.error() << "failed to figure out type of file '" << file_name << "'"
476  << messaget::eom;
477  return true;
478  }
479 
480  languagep->set_message_handler(log.get_message_handler());
481 
482  if(file_name == "-")
483  return parse_stdin(*languagep);
484 
485 #ifdef _MSC_VER
486  std::ifstream infile(widen(file_name));
487 #else
488  std::ifstream infile(file_name);
489 #endif
490 
491  if(!infile)
492  {
493  log.error() << "failed to open input file '" << file_name << "'"
494  << messaget::eom;
495  return true;
496  }
497 
498  language_filet &lf=language_files.add_file(file_name);
499  lf.language=std::move(languagep);
500 
501  if(mode==PREPROCESS_ONLY)
502  {
503  log.statistics() << "Preprocessing: " << file_name << messaget::eom;
504 
505  std::ostream *os = &std::cout;
506  std::ofstream ofs;
507 
508  if(cmdline.isset('o'))
509  {
510  ofs.open(cmdline.get_value('o'));
511  os = &ofs;
512 
513  if(!ofs.is_open())
514  {
515  log.error() << "failed to open output file '" << cmdline.get_value('o')
516  << "'" << messaget::eom;
517  return true;
518  }
519  }
520 
521  lf.language->preprocess(infile, file_name, *os);
522  }
523  else
524  {
525  log.statistics() << "Parsing: " << file_name << messaget::eom;
526 
527  if(lf.language->parse(infile, file_name))
528  {
529  log.error() << "PARSING ERROR" << messaget::eom;
530  return true;
531  }
532  }
533 
534  lf.get_modules();
535  return false;
536 }
537 
542 {
543  log.statistics() << "Parsing: (stdin)" << messaget::eom;
544 
545  if(mode==PREPROCESS_ONLY)
546  {
547  std::ostream *os = &std::cout;
548  std::ofstream ofs;
549 
550  if(cmdline.isset('o'))
551  {
552  ofs.open(cmdline.get_value('o'));
553  os = &ofs;
554 
555  if(!ofs.is_open())
556  {
557  log.error() << "failed to open output file '" << cmdline.get_value('o')
558  << "'" << messaget::eom;
559  return true;
560  }
561  }
562 
563  language.preprocess(std::cin, "", *os);
564  }
565  else
566  {
567  if(language.parse(std::cin, ""))
568  {
569  log.error() << "PARSING ERROR" << messaget::eom;
570  return true;
571  }
572  }
573 
574  return false;
575 }
576 
578  const std::string &file_name,
579  const goto_modelt &src_goto_model,
580  bool validate_goto_model,
581  message_handlert &message_handler)
582 {
583  messaget log(message_handler);
584 
586  {
587  log.status() << "Validating goto model" << messaget::eom;
588  src_goto_model.validate();
589  }
590 
591  log.statistics() << "Writing binary format object '" << file_name << "'"
592  << messaget::eom;
593 
594  // symbols
595  log.statistics() << "Symbols in table: "
596  << src_goto_model.symbol_table.symbols.size()
597  << messaget::eom;
598 
599  std::ofstream outfile(file_name, std::ios::binary);
600 
601  if(!outfile.is_open())
602  {
603  log.error() << "Error opening file '" << file_name << "'" << messaget::eom;
604  return true;
605  }
606 
607  if(write_goto_binary(outfile, src_goto_model))
608  return true;
609 
610  const auto cnt = function_body_count(src_goto_model.goto_functions);
611 
612  log.statistics() << "Functions: "
613  << src_goto_model.goto_functions.function_map.size() << "; "
614  << cnt << " have a body." << messaget::eom;
615 
616  outfile.close();
617 
618  return false;
619 }
620 
624 {
625  language_filest language_files;
626  language_files.set_message_handler(log.get_message_handler());
627 
628  if(parse(file_name, language_files))
629  return {};
630 
631  // we just typecheck one file here
632  symbol_tablet file_symbol_table;
633  if(language_files.typecheck(file_symbol_table, keep_file_local))
634  {
635  log.error() << "CONVERSION ERROR" << messaget::eom;
636  return {};
637  }
638 
639  if(language_files.final(file_symbol_table))
640  {
641  log.error() << "CONVERSION ERROR" << messaget::eom;
642  return {};
643  }
644 
645  return std::move(file_symbol_table);
646 }
647 
649 compilet::compilet(cmdlinet &_cmdline, message_handlert &mh, bool Werror)
650  : log(mh),
651  cmdline(_cmdline),
652  warning_is_fatal(Werror),
653  keep_file_local(
654  // function-local is the old name and is still in use, but is misleading
655  cmdline.isset("export-function-local-symbols") ||
656  cmdline.isset("export-file-local-symbols")),
657  file_local_mangle_suffix(
658  cmdline.isset("mangle-suffix") ? cmdline.get_value("mangle-suffix") : "")
659 {
661  echo_file_name=false;
662  wrote_object=false;
664 
665  if(cmdline.isset("export-function-local-symbols"))
666  {
667  log.warning()
668  << "The `--export-function-local-symbols` flag is deprecated. "
669  "Please use `--export-file-local-symbols` instead."
670  << messaget::eom;
671  }
672 }
673 
676 {
677  // clean up temp dirs
678 
679  for(const auto &dir : tmp_dirs)
680  delete_directory(dir);
681 }
682 
683 std::size_t compilet::function_body_count(const goto_functionst &functions)
684 {
685  std::size_t count = 0;
686 
687  for(const auto &f : functions.function_map)
688  if(f.second.body_available())
689  count++;
690 
691  return count;
692 }
693 
695 {
696  config.ansi_c.defines.push_back(
697  std::string("__GOTO_CC_VERSION__=") + CBMC_VERSION);
698 }
699 
701 {
702  symbol_table_buildert symbol_table_builder =
704 
705  goto_convert_functionst converter(
706  symbol_table_builder, log.get_message_handler());
707 
708  // the compilation may add symbols!
709 
711 
712  while(before != symbol_table_builder.symbols.size())
713  {
714  before = symbol_table_builder.symbols.size();
715 
716  typedef std::set<irep_idt> symbols_sett;
717  symbols_sett symbols;
718 
719  for(const auto &named_symbol : symbol_table_builder.symbols)
720  symbols.insert(named_symbol.first);
721 
722  // the symbol table iterators aren't stable
723  for(const auto &symbol : symbols)
724  {
725  symbol_tablet::symbolst::const_iterator s_it =
726  symbol_table_builder.symbols.find(symbol);
727  CHECK_RETURN(s_it != symbol_table_builder.symbols.end());
728 
729  if(
730  s_it->second.is_function() && !s_it->second.is_compiled() &&
731  s_it->second.value.is_not_nil())
732  {
733  log.debug() << "Compiling " << s_it->first << messaget::eom;
734  converter.convert_function(
735  s_it->first, goto_model.goto_functions.function_map[s_it->first]);
736  symbol_table_builder.get_writeable_ref(symbol).set_compiled();
737  }
738  }
739  }
740 }
741 
743 {
744  for(const auto &pair : symbol_table.symbols)
745  {
746  const irep_idt &name=pair.second.name;
747  const typet &new_type=pair.second.type;
748  if(!(has_prefix(id2string(name), CPROVER_PREFIX) && new_type.id()==ID_code))
749  continue;
750 
751  bool inserted;
752  std::map<irep_idt, symbolt>::iterator old;
753  std::tie(old, inserted)=written_macros.insert({name, pair.second});
754 
755  if(!inserted && old->second.type!=new_type)
756  {
757  log.error() << "Incompatible CPROVER macro symbol types:" << '\n'
758  << old->second.type.pretty() << "(at " << old->second.location
759  << ")\n"
760  << "and\n"
761  << new_type.pretty() << "(at " << pair.second.location << ")"
762  << messaget::eom;
763  return true;
764  }
765  }
766  return false;
767 }
bool ansi_c_entry_point(symbol_tablet &symbol_table, message_handlert &message_handler, const c_object_factory_parameterst &object_factory_parameters)
unsignedbv_typet size_type()
Definition: c_types.cpp:58
std::string get_value(char option) const
Definition: cmdline.cpp:47
virtual bool isset(char option) const
Definition: cmdline.cpp:29
argst args
Definition: cmdline.h:143
@ ASSEMBLE_ONLY
Definition: compile.h:39
@ LINK_LIBRARY
Definition: compile.h:40
@ PREPROCESS_ONLY
Definition: compile.h:37
@ COMPILE_LINK_EXECUTABLE
Definition: compile.h:42
@ COMPILE_ONLY
Definition: compile.h:38
@ COMPILE_LINK
Definition: compile.h:41
void add_compiler_specific_defines() const
Definition: compile.cpp:694
cmdlinet & cmdline
Definition: compile.h:110
bool wrote_object
Definition: compile.h:151
bool parse_stdin(languaget &)
parses a source file (low-level parsing)
Definition: compile.cpp:541
bool parse(const std::string &filename, language_filest &)
parses a source file (low-level parsing)
Definition: compile.cpp:454
std::string working_directory
Definition: compile.h:103
std::list< std::string > tmp_dirs
Definition: compile.h:106
bool echo_file_name
Definition: compile.h:34
std::string override_language
Definition: compile.h:104
std::string output_file_object
Definition: compile.h:54
bool add_input_file(const std::string &)
puts input file names into a list and does preprocessing for libraries.
Definition: compile.cpp:173
std::list< std::string > libraries
Definition: compile.h:48
bool link(optionalt< symbol_tablet > &&symbol_table)
parses object files and links them
Definition: compile.cpp:315
std::string output_directory_object
Definition: compile.h:54
std::list< std::string > object_files
Definition: compile.h:47
bool doit()
reads and source and object files, compiles and links them into goto program objects.
Definition: compile.cpp:60
std::list< std::string > source_files
Definition: compile.h:46
~compilet()
cleans up temporary files
Definition: compile.cpp:675
bool add_written_cprover_symbols(const symbol_tablet &symbol_table)
Definition: compile.cpp:742
std::string object_file_extension
Definition: compile.h:50
compilet(cmdlinet &_cmdline, message_handlert &mh, bool Werror)
constructor
Definition: compile.cpp:649
bool validate_goto_model
Definition: compile.h:35
const bool keep_file_local
Whether to keep implementations of file-local symbols.
Definition: compile.h:114
bool warning_is_fatal
Definition: compile.h:111
static std::size_t function_body_count(const goto_functionst &)
Definition: compile.cpp:683
optionalt< symbol_tablet > parse_source(const std::string &)
Parses and type checks a source file located at file_name.
Definition: compile.cpp:623
void convert_symbols(goto_modelt &)
Definition: compile.cpp:700
std::map< irep_idt, symbolt > written_macros
Definition: compile.h:144
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.
Definition: compile.cpp:214
bool find_library(const std::string &)
tries to find a library object file that matches the given library name.
Definition: compile.cpp:274
enum compilet::@3 mode
messaget log
Definition: compile.h:109
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.
Definition: compile.cpp:577
const std::string file_local_mangle_suffix
String to include in all mangled names.
Definition: compile.h:117
optionalt< symbol_tablet > compile()
Parses source files and writes object files, or keeps the symbols in the symbol_table if not compilin...
Definition: compile.cpp:372
std::list< std::string > library_paths
Definition: compile.h:45
std::string output_file_executable
Definition: compile.h:51
struct configt::ansi_ct ansi_c
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:37
Mangles the names in an entire program and its symbol table.
Definition: name_mangler.h:31
void mangle()
Mangle all file-local function symbols in the program.
Definition: name_mangler.h:49
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.
void validate(const validation_modet vm=validation_modet::INVARIANT, const goto_model_validation_optionst &goto_model_validation_options=goto_model_validation_optionst{}) const override
Check that the goto model is well-formed.
Definition: goto_model.h:98
symbol_tablet symbol_table
Symbol table.
Definition: goto_model.h:30
goto_functionst goto_functions
GOTO functions.
Definition: goto_model.h:33
std::string pretty(unsigned indent=0, unsigned max_indent=0) const
Definition: irep.cpp:495
const irep_idt & id() const
Definition: irep.h:407
language_filet & add_file(const std::string &filename)
Definition: language_file.h:77
bool typecheck(symbol_tablet &symbol_table, const bool keep_file_local=false)
bool final(symbol_table_baset &symbol_table)
std::unique_ptr< languaget > language
Definition: language_file.h:47
virtual bool preprocess(std::istream &instream, const std::string &path, std::ostream &outstream)
Definition: language.h:47
virtual bool parse(std::istream &instream, const std::string &path)=0
std::size_t get_message_count(unsigned level) const
Definition: message.h:56
Class that provides messages with a built-in verbosity 'level'.
Definition: message.h:155
mstreamt & error() const
Definition: message.h:399
mstreamt & statistics() const
Definition: message.h:419
mstreamt & warning() const
Definition: message.h:404
mstreamt & status() const
Definition: message.h:414
mstreamt & debug() const
Definition: message.h:429
message_handlert & get_message_handler()
Definition: message.h:184
virtual void set_message_handler(message_handlert &_message_handler)
Definition: message.h:179
@ M_WARNING
Definition: message.h:170
static eomt eom
Definition: message.h:297
bool remove(const irep_idt &name)
Remove a symbol from the symbol table.
symbolt & get_writeable_ref(const irep_idt &name)
Find a symbol in the symbol table for read-write access.
const symbolst & symbols
Read-only field, used to look up symbols given their names.
Author: Diffblue Ltd.
static symbol_table_buildert wrap(symbol_table_baset &base_symbol_table)
The symbol table.
Definition: symbol_table.h:14
void set_compiled()
Set the symbol's value to "compiled"; to be used once the code-typed value has been converted to a go...
Definition: symbol.h:114
The type of an expression, extends irept.
Definition: type.h:28
static file_typet detect_file_type(const std::string &file_name, message_handlert &message_handler)
Definition: compile.cpp:132
file_typet
Definition: compile.cpp:122
@ FAILED_TO_OPEN_FILE
Compile and link source and object files.
configt config
Definition: config.cpp:25
bool has_prefix(const std::string &s, const std::string &prefix)
Definition: converter.cpp:13
#define CPROVER_PREFIX
void set_current_path(const std::string &path)
Set working directory.
Definition: file_util.cpp:82
std::string get_current_working_directory()
Definition: file_util.cpp:51
void delete_directory(const std::string &path)
deletes all files in 'path' and then the directory itself
Definition: file_util.cpp:118
std::string concat_dir_file(const std::string &directory, const std::string &file_name)
Definition: file_util.cpp:159
std::string get_base_name(const std::string &in, bool strip_suffix)
cleans a filename from path and extension
Goto Programs with Functions.
const std::string & id2string(const irep_idt &d)
Definition: irep.h:49
static int8_t r
Definition: irep_hash.h:60
static std::string binary(const constant_exprt &src)
Definition: json_expr.cpp:205
Abstract interface to support a programming language.
bool linking(symbol_tablet &dest_symbol_table, symbol_tablet &new_symbol_table, message_handlert &message_handler)
Definition: linking.cpp:1444
ANSI-C Linking.
std::unique_ptr< languaget > get_language_from_filename(const std::string &filename)
Get the language corresponding to the registered file name extensions.
Definition: mode.cpp:102
std::unique_ptr< languaget > get_language_from_mode(const irep_idt &mode)
Get the language corresponding to the given mode.
Definition: mode.cpp:51
Mangle names of file-local functions to make them unique.
nonstd::optional< T > optionalt
Definition: optional.h:35
bool is_goto_binary(const std::string &filename, message_handlert &message_handler)
bool read_object_and_link(const std::string &file_name, goto_modelt &dest, message_handlert &message_handler)
reads an object file, and also updates config
Read Goto Programs.
int run(const std::string &what, const std::vector< std::string > &argv)
Definition: run.cpp:48
#define CHECK_RETURN(CONDITION)
Definition: invariant.h:495
#define UNREACHABLE
This should be used to mark dead code.
Definition: invariant.h:503
#define INITIALIZE_FUNCTION
std::list< std::string > defines
Definition: config.h:201
std::string get_temporary_directory(const std::string &name_template)
Definition: tempdir.cpp:42
std::wstring widen(const char *s)
Definition: unicode.cpp:48
void validate_goto_model(const goto_functionst &goto_functions, const validation_modet vm, const goto_model_validation_optionst validation_options)
const char * CBMC_VERSION
bool write_goto_binary(std::ostream &out, const symbol_tablet &symbol_table, const goto_functionst &goto_functions, irep_serializationt &irepconverter)
Writes a goto program to disc, using goto binary format.
Write GOTO binaries.