cprover
goto_cc_mode.cpp
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Command line option container
4 
5 Author: CM Wintersteiger, 2006
6 
7 \*******************************************************************/
8 
11 
12 #include "goto_cc_mode.h"
13 
14 #include <cstdio>
15 #include <iostream>
16 
17 #ifdef _WIN32
18 #define EX_OK 0
19 #define EX_USAGE 64
20 #define EX_SOFTWARE 70
21 #else
22 #include <sysexits.h>
23 #endif
24 
25 #include <util/parse_options.h>
26 #include <util/version.h>
27 
30  goto_cc_cmdlinet &_cmdline,
31  const std::string &_base_name,
32  message_handlert &_message_handler):
33  messaget(_message_handler),
34  cmdline(_cmdline),
35  base_name(_base_name)
36 {
38 }
39 
42 {
43 }
44 
47 {
48  // clang-format off
49  std::cout << '\n' << banner_string("goto-cc", CBMC_VERSION) << '\n'
50  <<
51  "* * Copyright (C) 2006-2018 * *\n"
52  "* * Daniel Kroening, Michael Tautschnig, * *\n"
53  "* * Christoph Wintersteiger * *\n"
54  "\n";
55 
56  help_mode();
57 
58  std::cout <<
59  "Usage: Purpose:\n"
60  "\n"
61  " --verbosity # verbosity level\n"
62  " --function name set entry point to name\n"
63  " --native-compiler cmd command to invoke as preprocessor/compiler\n"
64  " --native-linker cmd command to invoke as linker\n"
65  " --native-assembler cmd command to invoke as assembler (goto-as only)\n"
66  " --print-rejected-preprocessed-source file\n"
67  " copy failing (preprocessed) source to file\n"
68  "\n";
69  // clang-format on
70 }
71 
74 int goto_cc_modet::main(int argc, const char **argv)
75 {
76  if(cmdline.parse(argc, argv))
77  {
78  usage_error();
79  return EX_USAGE;
80  }
81 
82  try
83  {
84  return doit();
85  }
86 
87  catch(const char *e)
88  {
89  error() << e << eom;
90  return EX_SOFTWARE;
91  }
92 
93  catch(const std::string &e)
94  {
95  error() << e << eom;
96  return EX_SOFTWARE;
97  }
98 
99  catch(int)
100  {
101  return EX_SOFTWARE;
102  }
103 
104  catch(const std::bad_alloc &)
105  {
106  error() << "Out of memory" << eom;
107  return EX_SOFTWARE;
108  }
109 }
110 
114 {
115  std::cerr << "Usage error!\n\n";
116  help();
117 }
virtual int main(int argc, const char **argv)
starts the compiler
static mstreamt & eom(mstreamt &m)
Definition: message.h:272
virtual void usage_error()
prints a message informing the user about incorrect options
goto_cc_cmdlinet & cmdline
Definition: goto_cc_mode.h:37
mstreamt & error() const
Definition: message.h:302
virtual bool parse(int argc, const char **argv)=0
std::string banner_string(const std::string &front_end, const std::string &version)
virtual int doit()=0
virtual void help_mode()=0
const char * CBMC_VERSION
Definition: version.cpp:1
virtual void help()
display command line help
Command line interpretation for goto-cc.
~goto_cc_modet()
constructor
goto_cc_modet(goto_cc_cmdlinet &, const std::string &_base_name, message_handlert &)
constructor