30 "--print-rejected-preprocessed-source",
38 "--show-symbol-table",
39 "--show-function-table",
45 "--string-abstraction",
53 "--validate-goto-model",
55 "--export-file-local-symbols",
57 "--export-function-local-symbols",
112 "-compatibility_version",
146 "-no-integrated-cpp",
168 "-print-libgcc-file-name",
169 "-print-multi-directory",
171 "-print-search-dirs",
173 "-print-sysroot-headers-suffix",
197 "-mno-unaligned-access",
235 current_args.reserve(argc - 1);
237 for(
int i=1; i<argc; i++)
238 current_args.push_back(argv[i]);
248 const argst &args_to_parse,
251 for(argst::const_iterator it = args_to_parse.begin();
252 it != args_to_parse.end();
255 const std::string &argv_i=*it;
260 std::ifstream opts_file(argv_i.substr(1));
261 std::ostringstream all_lines;
264 while(std::getline(opts_file, line))
265 all_lines <<
' ' << line;
267 line = all_lines.str();
269 line.erase(0, line.find_first_not_of(
"\t "));
287 argst::const_iterator next=it;
301 *o!=
nullptr && !found;
307 if(next != args_to_parse.end())
316 else if(
has_prefix(argv_i, std::string(*o)+
"="))
342 std::string value=argv_i.substr(4);
352 std::size_t equal_pos=argv_i.find(
'=');
354 if(equal_pos==std::string::npos)
357 set(argv_i.substr(0, equal_pos), argv_i.substr(equal_pos+1));
366 argst::const_iterator next=it;
373 *o!=
nullptr && !found;
379 if(next != args_to_parse.end())
390 else if(
has_prefix(argv_i, std::string(*o)+
"="))
399 *o!=
nullptr && !found;
405 if(next != args_to_parse.end())
424 *o!=
nullptr && !found;
437 std::cerr <<
"Warning: uninterpreted gcc option '" << argv_i
453 argst args_from_specs;
456 arg_end!=std::string::npos;
457 arg_start=line.find_first_not_of(
"\t ", arg_end))
459 arg_end=line.find_first_of(
"\t ", arg_start);
460 args_from_specs.push_back(line.substr(arg_start, arg_end - arg_start));
469 const std::string &specs_file_name=
get_value(
"specs");
470 if(specs_file_name.empty())
473 std::ifstream specs_file(specs_file_name);
477 while(std::getline(specs_file, line))
480 line.erase(0, line.find_first_not_of(
"\t "));
486 (line==
"*link_libgcc:" ||
std::string get_value(char option) const
bool parse_arguments(const argst &args_to_parse, bool in_spec_file)
void parse_specs()
Parse GCC spec files https://gcc.gnu.org/onlinedocs/gcc/Spec-Files.html.
std::vector< std::string > argst
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 set(const std::string &opt, const char *value) override
Set option option to value.
void add_infile_arg(const std::string &arg)
static bool in_list(const char *option, const char **list)
virtual bool parse(int argc, const char **argv, const char *optstring)
Parses a commandline according to a specification given in optstring.
void add_arg(const std::string &arg)
bool has_prefix(const std::string &s, const std::string &prefix)
const char * gcc_options_with_concatenated_argument[]
const char * gcc_options_with_separated_argument[]
const char * goto_cc_options_with_separated_argument[]
const char * gcc_options_without_argument[]
const char * goto_cc_options_without_argument[]
const char * gcc_options_with_argument[]
A special command line object for the gcc-like options.
#define PRECONDITION(CONDITION)
size_t strlen(const char *s)