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 <cbmc/version.h>
26 
29  goto_cc_cmdlinet &_cmdline,
30  const std::string &_base_name,
31  message_handlert &_message_handler):
32  messaget(_message_handler),
33  cmdline(_cmdline),
34  base_name(_base_name)
35 {
37 }
38 
41 {
42 }
43 
46 {
47  std::cout <<
48  "\n"
49  // NOLINTNEXTLINE(whitespace/line_length)
50  "* * goto-cc " CBMC_VERSION " - Copyright (C) 2006-2014 * *\n"
51  "* * Daniel Kroening, Christoph Wintersteiger * *\n"
52  "* * kroening@kroening.com * *\n"
53  "\n";
54 
55  help_mode();
56 
57  std::cout <<
58  "Usage: Purpose:\n"
59  "\n"
60  " --verbosity # verbosity level\n"
61  " --function name set entry point to name\n"
62  " --native-compiler cmd command to invoke as preprocessor/compiler\n"
63  " --native-linker cmd command to invoke as linker\n"
64  " --native-assembler cmd command to invoke as assembler (goto-as only)\n"
65  " --print-rejected-preprocessed-source file\n"
66  " copy failing (preprocessed) source to file\n"
67  "\n";
68 }
69 
72 int goto_cc_modet::main(int argc, const char **argv)
73 {
74  if(cmdline.parse(argc, argv))
75  {
76  usage_error();
77  return EX_USAGE;
78  }
79 
80  try
81  {
82  return doit();
83  }
84 
85  catch(const char *e)
86  {
87  error() << e << eom;
88  return EX_SOFTWARE;
89  }
90 
91  catch(const std::string e)
92  {
93  error() << e << eom;
94  return EX_SOFTWARE;
95  }
96 
97  catch(int)
98  {
99  return EX_SOFTWARE;
100  }
101 
102  catch(std::bad_alloc)
103  {
104  error() << "Out of memory" << eom;
105  return EX_SOFTWARE;
106  }
107 }
108 
112 {
113  std::cerr << "Usage error!\n\n";
114  help();
115 }
virtual int main(int argc, const char **argv)
starts the compiler
static mstreamt & eom(mstreamt &m)
Definition: message.h:193
virtual void usage_error()
prints a message informing the user about incorrect options
goto_cc_cmdlinet & cmdline
Definition: goto_cc_mode.h:37
virtual bool parse(int argc, const char **argv)=0
virtual int doit()=0
virtual void help_mode()=0
virtual void help()
display command line help
mstreamt & error()
Definition: message.h:223
#define CBMC_VERSION
Definition: version.h:4
Command line interpretation for goto-cc.
~goto_cc_modet()
constructor
goto_cc_modet(goto_cc_cmdlinet &, const std::string &_base_name, message_handlert &)
constructor