cprover
goto_cc_main.cpp
Go to the documentation of this file.
1
/*******************************************************************\
2
3
Module: GOTO-CC Main Module
4
5
Authors: Daniel Kroening, kroening@kroening.com
6
7
Date: May 2006
8
9
\*******************************************************************/
10
13
14
#include <algorithm>
15
#include <iostream>
16
17
#include <
util/unicode.h
>
18
#include <
util/get_base_name.h
>
19
20
#include "
armcc_cmdline.h
"
21
#include "
as86_cmdline.h
"
22
#include "
as_cmdline.h
"
23
#include "
bcc_cmdline.h
"
24
#include "
gcc_cmdline.h
"
25
#include "
ld_cmdline.h
"
26
#include "
ms_cl_cmdline.h
"
27
#include "
ms_link_cmdline.h
"
28
29
#include "
armcc_mode.h
"
30
#include "
as_mode.h
"
31
#include "
cw_mode.h
"
32
#include "
gcc_mode.h
"
33
#include "
ld_mode.h
"
34
#include "
ms_cl_mode.h
"
35
#include "
ms_link_mode.h
"
36
37
std::string
to_lower_string
(
const
std::string &s)
38
{
39
std::string result=s;
40
transform(result.begin(), result.end(), result.begin(), tolower);
41
return
result;
42
}
43
44
#ifdef _MSC_VER
45
int
wmain(
int
argc,
const
wchar_t
**argv_wide)
46
#else
47
int
main
(
int
argc,
const
char
**argv)
48
#endif
49
{
50
#ifdef _MSC_VER
51
auto
vec=
narrow_argv
(argc, argv_wide);
52
auto
narrow
=
to_c_str_array
(std::begin(vec), std::end(vec));
53
auto
argv=
narrow
.data();
54
#endif
55
56
if
(argv==
nullptr
|| argc<1)
57
{
58
std::cerr <<
"failed to determine base name\n"
;
59
return
1;
60
}
61
62
#ifdef _MSC_VER
63
// we do 'to_lower_string' because of Windows
64
std::string base_name=
65
to_lower_string
(
get_base_name
(argv[0],
true
));
66
#else
67
std::string base_name=
get_base_name
(argv[0],
false
);
68
#endif
69
70
if
(base_name ==
"goto-cl"
|| base_name ==
"cl"
)
71
{
72
// this is the Visual Studio CL personality
73
ms_cl_cmdlinet
cmdline;
74
cmdline.
parse_env
();
75
ms_cl_modet
ms_cl_mode(cmdline, base_name);
76
return
ms_cl_mode.
main
(argc, argv);
77
}
78
else
if
(base_name ==
"goto-link"
|| base_name ==
"link"
)
79
{
80
// this is the Visual Studio LINK personality
81
ms_link_cmdlinet
cmdline;
82
ms_link_modet
ms_link_mode(cmdline);
83
return
ms_link_mode.
main
(argc, argv);
84
}
85
else
if
(base_name==
"goto-cw"
||
86
base_name==
"goto-cw-link"
)
87
{
88
// this is the CodeWarrior personality,
89
// but we use the gcc command line interface
90
gcc_cmdlinet
cmdline;
91
cw_modet
cw_mode(cmdline, base_name);
92
return
cw_mode.
main
(argc, argv);
93
}
94
else
if
(base_name==
"goto-armcc"
||
95
base_name==
"goto-armlink"
)
96
{
97
// this is the armcc personality
98
armcc_cmdlinet
cmdline;
99
armcc_modet
armcc_mode(cmdline, base_name);
100
return
armcc_mode.
main
(argc, argv);
101
}
102
// handle GCC names like x86_64-apple-darwin14-llvm-gcc-4.2
103
// via x86_64-apple-darwin14-llvm-goto-gcc-4.2
104
else
if
(base_name==
"goto-clang"
||
105
base_name.find(
"goto-gcc"
)!=std::string::npos)
106
{
107
// this produces ELF/Mach-O "hybrid binaries",
108
// with a GCC-style command-line interface,
109
// but also disables CPROVER language extensions
110
gcc_cmdlinet
cmdline;
111
gcc_modet
gcc_mode(cmdline, base_name,
true
);
112
return
gcc_mode.
main
(argc, argv);
113
}
114
else
if
(base_name.find(
"goto-ld"
)!=std::string::npos)
115
{
116
// this simulates "ld" for linking
117
ld_cmdlinet
cmdline;
118
ld_modet
ld_mode(cmdline, base_name);
119
return
ld_mode.
main
(argc, argv);
120
}
121
else
if
(base_name.find(
"goto-bcc"
)!=std::string::npos)
122
{
123
// this simulates Bruce's C Compiler
124
bcc_cmdlinet
cmdline;
125
// bcc does not build ELF objects -- hybrid mode is used
126
// with -S only
127
gcc_modet
gcc_mode(cmdline, base_name,
true
);
128
return
gcc_mode.
main
(argc, argv);
129
}
130
else
if
(base_name.find(
"goto-as86"
)!=std::string::npos)
131
{
132
// assembler used by Bruce's C Compiler
133
as86_cmdlinet
cmdline;
134
// as86 does not build ELF objects, no hybrid binaries
135
as_modet
as_mode(cmdline, base_name,
false
);
136
return
as_mode.
main
(argc, argv);
137
}
138
else
if
(base_name.find(
"goto-as"
)!=std::string::npos)
139
{
140
// GNU assembler
141
as_cmdlinet
cmdline;
142
as_modet
as_mode(cmdline, base_name,
true
);
143
return
as_mode.
main
(argc, argv);
144
}
145
else
146
{
147
// the default personality is GCC-style
148
gcc_cmdlinet
cmdline;
149
gcc_modet
gcc_mode(cmdline, base_name,
false
);
150
return
gcc_mode.
main
(argc, argv);
151
}
152
}
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
to_lower_string
std::string to_lower_string(const std::string &s)
Definition:
goto_cc_main.cpp:37
ld_modet
Definition:
ld_mode.h:24
as86_cmdlinet
Definition:
as86_cmdline.h:21
as_modet
Definition:
as_mode.h:23
ms_link_cmdlinet
Definition:
ms_link_cmdline.h:20
bcc_cmdline.h
A special command line object for Bruce's C Compiler Author: Michael Tautschnig Date: July 2016.
gcc_cmdline.h
A special command line object for the gcc-like options.
armcc_cmdlinet
Definition:
armcc_cmdline.h:20
as_mode.h
Assembler Mode.
ld_mode.h
Base class for command line interpretation.
ms_cl_cmdlinet
Definition:
ms_cl_cmdline.h:20
armcc_mode.h
Base class for command line interpretation for CL.
to_c_str_array
std::vector< const char * > to_c_str_array(It b, It e)
Definition:
unicode.h:59
ms_cl_modet
Definition:
ms_cl_mode.h:22
ms_link_mode.h
Visual Studio Link Mode.
ms_link_cmdline.h
A special command line object for LINK options.
get_base_name.h
as_cmdlinet
Definition:
as_cmdline.h:21
ld_cmdline.h
A special command line object for the ld-like options.
narrow
output_type narrow(input_type input)
Run-time checked narrowing cast.
Definition:
narrow.h:34
as_cmdline.h
A special command line object for GNU Assembler Author: Michael Tautschnig Date: July 2016.
bcc_cmdlinet
Definition:
bcc_cmdline.h:21
armcc_modet
Definition:
armcc_mode.h:22
ms_cl_cmdlinet::parse_env
void parse_env()
Definition:
ms_cl_cmdline.cpp:103
ld_cmdlinet
Definition:
ld_cmdline.h:20
ms_link_modet
Definition:
ms_link_mode.h:22
gcc_cmdlinet
Definition:
gcc_cmdline.h:20
goto_cc_modet::main
int main(int argc, const char **argv)
starts the compiler
Definition:
goto_cc_mode.cpp:76
unicode.h
armcc_cmdline.h
A special command line object to mimic ARM's armcc.
main
int main(int argc, const char **argv)
Definition:
goto_cc_main.cpp:47
gcc_modet
Definition:
gcc_mode.h:26
cw_mode.h
Base class for command line interpretation.
narrow_argv
std::vector< std::string > narrow_argv(int argc, const wchar_t **argv_wide)
Definition:
unicode.cpp:150
ms_cl_cmdline.h
A special command line object for the gcc-like options.
as86_cmdline.h
A special command line object for as86 (of Bruce's C Compiler) Author: Michael Tautschnig Date: July ...
cw_modet
Definition:
cw_mode.h:23
ms_cl_mode.h
Visual Studio CL Mode.
gcc_mode.h
Base class for command line interpretation.
goto-cc
goto_cc_main.cpp
Generated by
1.8.20