29 "--print-rejected-preprocessed-source",
36 "--show-symbol-table",
37 "--show-function-table",
43 "--string-abstraction",
106 "-compatibility_version",
138 "-no-integrated-cpp",
160 "-print-libgcc-file-name",
161 "-print-multi-directory",
163 "-print-search-dirs",
165 "-print-sysroot-headers-suffix",
188 "-mno-unaligned-access",
225 args.reserve(argc-1);
227 for(
int i=1; i<argc; i++)
228 args.push_back(argv[i]);
241 for(argst::const_iterator it=
args.begin();
245 const std::string &argv_i=*it;
250 std::ifstream opts_file(argv_i.substr(1));
253 while(std::getline(opts_file, line))
256 line.erase(0, line.find_first_not_of(
"\t "));
275 argst::const_iterator next=it;
289 *o!=
nullptr && !found;
304 else if(
has_prefix(argv_i, std::string(*o)+
"="))
307 set(*o, argv_i.substr(strlen(*o)+1));
330 std::string value=argv_i.substr(4);
340 std::size_t equal_pos=argv_i.find(
'=');
342 if(equal_pos==std::string::npos)
345 set(argv_i.substr(0, equal_pos), argv_i.substr(equal_pos+1));
354 argst::const_iterator next=it;
361 *o!=
nullptr && !found;
378 else if(
has_prefix(argv_i, std::string(*o)+
"="))
381 set(*o, argv_i.substr(strlen(*o)+1));
387 *o!=
nullptr && !found;
406 set(*o, argv_i.substr(strlen(*o)));
412 *o!=
nullptr && !found;
418 set(*o, argv_i.substr(strlen(*o)));
425 std::cerr <<
"Warning: uninterpreted gcc option '" << argv_i
438 assert(!line.empty());
439 assert(line[0]!=
' ' && line[0]!=
'\t');
444 arg_end!=std::string::npos;
445 arg_start=line.find_first_not_of(
"\t ", arg_end))
447 arg_end=line.find_first_of(
"\t ", arg_start);
448 args.push_back(line.substr(arg_start, arg_end-arg_start));
457 const std::string &specs_file_name=
get_value(
"specs");
458 if(specs_file_name.empty())
461 std::ifstream specs_file(specs_file_name);
465 while(std::getline(specs_file, line))
468 line.erase(0, line.find_first_not_of(
"\t "));
474 (line==
"*link_libgcc:" ||
bool parse_arguments(const argst &args, bool in_spec_file)
A special command line object for the gcc-like options.
virtual bool parse(int, const char **)
parses the command line options into a cmdlinet
std::string get_value(char option) const
unsignedbv_typet size_type()
const char * gcc_options_without_argument[]
const char * goto_cc_options_without_argument[]
std::vector< std::string > argst
const char * goto_cc_options_with_separated_argument[]
const char * gcc_options_with_argument[]
static bool in_list(const char *option, const char **list)
void add_arg(const std::string &arg)
bool has_prefix(const std::string &s, const std::string &prefix)
void set(const std::string &opt, const std::string &value)
const char * gcc_options_with_separated_argument[]
void parse_specs()
Parse GCC spec files https://gcc.gnu.org/onlinedocs/gcc/Spec-Files.html.
void parse_specs_line(const std::string &line, bool in_spec_file)
Parse GCC spec files https://gcc.gnu.org/onlinedocs/gcc/Spec-Files.html.
void add_infile_arg(const std::string &arg)
const char * gcc_options_with_concatenated_argument[]