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