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 
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  // clang-format off
48  std::cout << '\n' << banner_string("goto-cc", CBMC_VERSION) << '\n'
49  <<
50  "* * Copyright (C) 2006-2018 * *\n"
51  "* * Daniel Kroening, Michael Tautschnig, * *\n"
52  "* * Christoph Wintersteiger * *\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  // clang-format on
69 }
70 
73 int goto_cc_modet::main(int argc, const char **argv)
74 {
75  if(cmdline.parse(argc, argv))
76  {
77  usage_error();
78  return EX_USAGE;
79  }
80 
81  try
82  {
83  return doit();
84  }
85 
86  catch(const char *e)
87  {
88  error() << e << eom;
89  return EX_SOFTWARE;
90  }
91 
92  catch(const std::string &e)
93  {
94  error() << e << eom;
95  return EX_SOFTWARE;
96  }
97 
98  catch(int)
99  {
100  return EX_SOFTWARE;
101  }
102 
103  catch(const std::bad_alloc &)
104  {
105  error() << "Out of memory" << eom;
106  return EX_SOFTWARE;
107  }
108 }
109 
113 {
114  std::cerr << "Usage error!\n\n";
115  help();
116 }
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
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