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/exception_utils.h>
26 #include <util/parse_options.h>
27 #include <util/version.h>
28 
31  goto_cc_cmdlinet &_cmdline,
32  const std::string &_base_name,
33  message_handlert &_message_handler):
34  messaget(_message_handler),
35  cmdline(_cmdline),
36  base_name(_base_name)
37 {
39 }
40 
43 {
44 }
45 
48 {
49  // clang-format off
50  std::cout << '\n' << banner_string("goto-cc", CBMC_VERSION) << '\n'
51  <<
52  "* * Copyright (C) 2006-2018 * *\n"
53  "* * Daniel Kroening, Michael Tautschnig, * *\n"
54  "* * Christoph Wintersteiger * *\n"
55  "\n";
56 
57  help_mode();
58 
59  std::cout <<
60  "Usage: Purpose:\n"
61  "\n"
62  " --verbosity # verbosity level\n"
63  " --function name set entry point to name\n"
64  " --native-compiler cmd command to invoke as preprocessor/compiler\n"
65  " --native-linker cmd command to invoke as linker\n"
66  " --native-assembler cmd command to invoke as assembler (goto-as only)\n"
67  " --print-rejected-preprocessed-source file\n"
68  " copy failing (preprocessed) source to file\n"
69  "\n";
70  // clang-format on
71 }
72 
75 int goto_cc_modet::main(int argc, const char **argv)
76 {
77  if(cmdline.parse(argc, argv))
78  {
79  usage_error();
80  return EX_USAGE;
81  }
82 
83  try
84  {
85  return doit();
86  }
87 
88  catch(const char *e)
89  {
90  error() << e << eom;
91  return EX_SOFTWARE;
92  }
93 
94  catch(const std::string &e)
95  {
96  error() << e << eom;
97  return EX_SOFTWARE;
98  }
99 
100  catch(int)
101  {
102  return EX_SOFTWARE;
103  }
104 
105  catch(const std::bad_alloc &)
106  {
107  error() << "Out of memory" << eom;
108  return EX_SOFTWARE;
109  }
110  catch(const cprover_exception_baset &e)
111  {
112  error() << e.what() << eom;
113  return EX_SOFTWARE;
114  }
115 }
116 
120 {
121  std::cerr << "Usage error!\n\n";
122  help();
123 }
virtual int main(int argc, const char **argv)
starts the compiler
virtual void usage_error()
prints a message informing the user about incorrect options
goto_cc_cmdlinet & cmdline
Definition: goto_cc_mode.h:37
Base class for exceptions thrown in the cprover project.
mstreamt & error() const
Definition: message.h:386
virtual bool parse(int argc, const char **argv)=0
Class that provides messages with a built-in verbosity &#39;level&#39;.
Definition: message.h:144
std::string banner_string(const std::string &front_end, const std::string &version)
virtual int doit()=0
virtual void help_mode()=0
static eomt eom
Definition: message.h:284
const char * CBMC_VERSION
Definition: version.cpp:1
virtual void help()
display command line help
virtual std::string what() const =0
A human readable description of what went wrong.
Command line interpretation for goto-cc.
~goto_cc_modet()
constructor
goto_cc_modet(goto_cc_cmdlinet &, const std::string &_base_name, message_handlert &)
constructor