本文整理汇总了C++中cpp_get_options函数的典型用法代码示例。如果您正苦于以下问题:C++ cpp_get_options函数的具体用法?C++ cpp_get_options怎么用?C++ cpp_get_options使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cpp_get_options函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: preprocess_file
/* Preprocess and output. */
void
preprocess_file (cpp_reader *pfile)
{
/* A successful cpp_read_main_file guarantees that we can call
cpp_scan_nooutput or cpp_get_token next. */
if (flag_no_output)
{
/* Scan -included buffers, then the main file. */
while (pfile->buffer->prev)
cpp_scan_nooutput (pfile);
cpp_scan_nooutput (pfile);
}
else if (cpp_get_options (pfile)->traditional)
scan_translation_unit_trad (pfile);
else if (cpp_get_options (pfile)->directives_only
&& !cpp_get_options (pfile)->preprocessed)
scan_translation_unit_directives_only (pfile);
else
scan_translation_unit (pfile);
/* -dM command line option. Should this be elsewhere? */
if (flag_dump_macros == 'M')
cpp_forall_identifiers (pfile, dump_macro, NULL);
/* Flush any pending output. */
if (print.printed)
putc ('\n', print.outf);
}
示例2: c_common_init_options
/* Common initialization before calling option handlers. */
void
c_common_init_options (unsigned int decoded_options_count,
struct cl_decoded_option *decoded_options)
{
unsigned int i;
struct cpp_callbacks *cb;
parse_in = cpp_create_reader (c_dialect_cxx () ? CLK_GNUCXX: CLK_GNUC89,
ident_hash, line_table);
cb = cpp_get_callbacks (parse_in);
cb->error = c_cpp_error;
cpp_opts = cpp_get_options (parse_in);
cpp_opts->dollars_in_ident = DOLLARS_IN_IDENTIFIERS;
cpp_opts->objc = c_dialect_objc ();
/* Reset to avoid warnings on internal definitions. We set it just
before passing on command-line options to cpplib. */
cpp_opts->warn_dollars = 0;
deferred_opts = XNEWVEC (struct deferred_opt, decoded_options_count);
if (c_language == clk_c)
{
/* If preprocessing assembly language, accept any of the C-family
front end options since the driver may pass them through. */
for (i = 1; i < decoded_options_count; i++)
if (decoded_options[i].opt_index == OPT_lang_asm)
{
accept_all_c_family_options = true;
break;
}
}
}
示例3: init_pp_output
/* Set up the callbacks as appropriate. */
void
init_pp_output (FILE *out_stream)
{
cpp_callbacks *cb = cpp_get_callbacks (parse_in);
if (!flag_no_output)
{
cb->line_change = cb_line_change;
/* Don't emit #pragma or #ident directives if we are processing
assembly language; the assembler may choke on them. */
if (cpp_get_options (parse_in)->lang != CLK_ASM)
{
cb->ident = cb_ident;
cb->def_pragma = cb_def_pragma;
}
}
if (flag_dump_includes)
cb->include = cb_include;
if (flag_dump_macros == 'N' || flag_dump_macros == 'D')
{
cb->define = cb_define;
cb->undef = cb_undef;
}
/* Initialize the print structure. Setting print.line to -1 here is
a trick to guarantee that the first token of the file will cause
a linemarker to be output by maybe_print_line. */
print.line = (fileline) -1;
print.printed = 0;
print.prev = 0;
print.map = 0;
print.outf = out_stream;
}
示例4: c_common_init_options
/* Common initialization before parsing options. */
unsigned int
c_common_init_options (unsigned int argc, const char **argv)
{
static const unsigned int lang_flags[] = {CL_C, CL_ObjC, CL_CXX, CL_ObjCXX};
unsigned int i, result;
/* This is conditionalized only because that is the way the front
ends used to do it. Maybe this should be unconditional? */
if (c_dialect_cxx ())
{
/* By default wrap lines at 80 characters. Is getenv
("COLUMNS") preferable? */
diagnostic_line_cutoff (global_dc) = 80;
/* By default, emit location information once for every
diagnostic message. */
diagnostic_prefixing_rule (global_dc) = DIAGNOSTICS_SHOW_PREFIX_ONCE;
}
parse_in = cpp_create_reader (c_dialect_cxx () ? CLK_GNUCXX: CLK_GNUC89,
ident_hash, &line_table);
cpp_opts = cpp_get_options (parse_in);
cpp_opts->dollars_in_ident = DOLLARS_IN_IDENTIFIERS;
cpp_opts->objc = c_dialect_objc ();
/* Reset to avoid warnings on internal definitions. We set it just
before passing on command-line options to cpplib. */
cpp_opts->warn_dollars = 0;
flag_exceptions = c_dialect_cxx ();
warn_pointer_arith = c_dialect_cxx ();
warn_write_strings = c_dialect_cxx();
deferred_opts = XNEWVEC (struct deferred_opt, argc);
result = lang_flags[c_language];
if (c_language == clk_c)
{
/* If preprocessing assembly language, accept any of the C-family
front end options since the driver may pass them through. */
for (i = 1; i < argc; i++)
if (! strcmp (argv[i], "-lang-asm"))
{
result |= CL_C | CL_ObjC | CL_CXX | CL_ObjCXX;
break;
}
#ifdef CL_Fortran
for (i = 1; i < argc; i++)
if (! strcmp (argv[i], "-lang-fortran"))
{
result |= CL_Fortran;
break;
}
#endif
}
return result;
}
示例5: register_include_chains
/* Exported function to handle include chain merging, duplicate
removal, and registration with cpplib. */
void
register_include_chains (cpp_reader *pfile, const char *sysroot,
const char *iprefix, int stdinc, int cxx_stdinc,
int verbose)
{
static const char *const lang_env_vars[] =
{ "C_INCLUDE_PATH", "CPLUS_INCLUDE_PATH",
"OBJC_INCLUDE_PATH", "OBJCPLUS_INCLUDE_PATH" };
cpp_options *cpp_opts = cpp_get_options (pfile);
size_t idx = (cpp_opts->objc ? 2: 0);
if (cpp_opts->cplusplus)
idx++;
else
cxx_stdinc = false;
/* CPATH and language-dependent environment variables may add to the
include chain. */
add_env_var_paths ("CPATH", BRACKET);
add_env_var_paths (lang_env_vars[idx], SYSTEM);
target_c_incpath.extra_pre_includes (sysroot, iprefix, stdinc);
/* Finally chain on the standard directories. */
if (stdinc)
add_standard_paths (sysroot, iprefix, cxx_stdinc);
target_c_incpath.extra_includes (sysroot, iprefix, stdinc);
merge_include_chains (pfile, verbose);
cpp_set_include_chains (pfile, heads[QUOTE], heads[BRACKET],
quote_ignores_source_dir);
}
示例6: maybe_print_line
static void
maybe_print_line (source_location src_loc)
{
if (cpp_get_options (parse_in)->debug)
linemap_dump_location (line_table, src_loc,
print.outf);
maybe_print_line_1 (src_loc, print.outf);
}
示例7: print_line
static void
print_line (source_location src_loc, const char *special_flags)
{
if (cpp_get_options (parse_in)->debug)
linemap_dump_location (line_table, src_loc,
print.outf);
print_line_1 (src_loc, special_flags, print.outf);
}
示例8: arm_pragma_target_parse
/* Hook to validate the current #pragma GCC target and set the arch custom
mode state. If ARGS is NULL, then POP_TARGET is used to reset
the options. */
static bool
arm_pragma_target_parse (tree args, tree pop_target)
{
tree prev_tree = build_target_option_node (&global_options);
tree cur_tree;
struct cl_target_option *prev_opt;
struct cl_target_option *cur_opt;
if (! args)
{
cur_tree = ((pop_target) ? pop_target : target_option_default_node);
cl_target_option_restore (&global_options,
TREE_TARGET_OPTION (cur_tree));
}
else
{
cur_tree = arm_valid_target_attribute_tree (args, &global_options,
&global_options_set);
if (cur_tree == NULL_TREE)
{
cl_target_option_restore (&global_options,
TREE_TARGET_OPTION (prev_tree));
return false;
}
}
target_option_current_node = cur_tree;
arm_reset_previous_fndecl ();
/* Figure out the previous mode. */
prev_opt = TREE_TARGET_OPTION (prev_tree);
cur_opt = TREE_TARGET_OPTION (cur_tree);
gcc_assert (prev_opt);
gcc_assert (cur_opt);
if (cur_opt->x_target_flags != prev_opt->x_target_flags)
{
/* For the definitions, ensure all newly defined macros are considered
as used for -Wunused-macros. There is no point warning about the
compiler predefined macros. */
cpp_options *cpp_opts = cpp_get_options (parse_in);
unsigned char saved_warn_unused_macros = cpp_opts->warn_unused_macros;
cpp_opts->warn_unused_macros = 0;
/* Update macros. */
gcc_assert (cur_opt->x_target_flags == target_flags);
arm_cpu_builtins (parse_in);
cpp_opts->warn_unused_macros = saved_warn_unused_macros;
}
return true;
}
示例9: init_pp_output
/* Set up the callbacks as appropriate. */
void
init_pp_output (FILE *out_stream)
{
cpp_callbacks *cb = cpp_get_callbacks (parse_in);
if (!flag_no_output)
{
cb->line_change = cb_line_change;
/* Don't emit #pragma or #ident directives if we are processing
assembly language; the assembler may choke on them. */
if (cpp_get_options (parse_in)->lang != CLK_ASM)
{
cb->ident = cb_ident;
cb->def_pragma = cb_def_pragma;
}
}
if (flag_dump_includes)
cb->include = cb_include;
if (flag_pch_preprocess)
{
cb->valid_pch = c_common_valid_pch;
cb->read_pch = cb_read_pch;
}
if (flag_dump_macros == 'N' || flag_dump_macros == 'D')
{
cb->define = cb_define;
cb->undef = cb_undef;
}
if (flag_dump_macros == 'U')
{
cb->before_define = dump_queued_macros;
cb->used_define = cb_used_define;
cb->used_undef = cb_used_undef;
}
cb->has_attribute = c_common_has_attribute;
cb->get_source_date_epoch = cb_get_source_date_epoch;
cb->remap_filename = remap_macro_filename;
/* Initialize the print structure. */
print.src_line = 1;
print.printed = false;
print.prev = 0;
print.outf = out_stream;
print.first_time = 1;
print.src_file = "";
print.prev_was_system_token = false;
}
示例10: aarch64_pragma_target_parse
static bool
aarch64_pragma_target_parse (tree args, tree pop_target)
{
/* If args is not NULL then process it and setup the target-specific
information that it specifies. */
if (args)
{
if (!aarch64_process_target_attr (args, "pragma"))
return false;
aarch64_override_options_internal (&global_options);
}
/* args is NULL, restore to the state described in pop_target. */
else
{
pop_target = pop_target ? pop_target : target_option_default_node;
cl_target_option_restore (&global_options,
TREE_TARGET_OPTION (pop_target));
}
target_option_current_node
= build_target_option_node (&global_options);
aarch64_reset_previous_fndecl ();
/* For the definitions, ensure all newly defined macros are considered
as used for -Wunused-macros. There is no point warning about the
compiler predefined macros. */
cpp_options *cpp_opts = cpp_get_options (parse_in);
unsigned char saved_warn_unused_macros = cpp_opts->warn_unused_macros;
cpp_opts->warn_unused_macros = 0;
aarch64_update_cpp_builtins (parse_in);
cpp_opts->warn_unused_macros = saved_warn_unused_macros;
/* Initialize SIMD builtins if we haven't already.
Set current_target_pragma to NULL for the duration so that
the builtin initialization code doesn't try to tag the functions
being built with the attributes specified by any current pragma, thus
going into an infinite recursion. */
if (TARGET_SIMD)
{
tree saved_current_target_pragma = current_target_pragma;
current_target_pragma = NULL;
aarch64_init_simd_builtins ();
current_target_pragma = saved_current_target_pragma;
}
return true;
}
示例11: spu_cpu_cpp_builtins
void
spu_cpu_cpp_builtins (struct cpp_reader *pfile)
{
cpp_define (pfile, "__SPU__");
cpp_assert (pfile, "cpu=spu");
cpp_assert (pfile, "machine=spu");
if (spu_arch == PROCESSOR_CELLEDP)
cpp_define (pfile, "__SPU_EDP__");
if (cpp_get_options (pfile)->lang != CLK_ASM)
cpp_define (pfile, "__vector=__attribute__((__spu_vector__))");
switch (spu_ea_model)
{
case 32:
cpp_define (pfile, "__EA32__");
break;
case 64:
cpp_define (pfile, "__EA64__");
break;
default:
gcc_unreachable ();
}
if (!flag_iso && cpp_get_options (pfile)->lang != CLK_ASM)
{
/* Define this when supporting context-sensitive keywords. */
cpp_define (pfile, "__VECTOR_KEYWORD_SUPPORTED__");
cpp_define (pfile, "vector=vector");
/* Initialize vector keywords. */
__vector_keyword = get_identifier ("__vector");
C_CPP_HASHNODE (__vector_keyword)->flags |= NODE_CONDITIONAL;
vector_keyword = get_identifier ("vector");
C_CPP_HASHNODE (vector_keyword)->flags |= NODE_CONDITIONAL;
/* Enable context-sensitive macros. */
cpp_get_callbacks (pfile)->macro_to_expand = spu_macro_to_expand;
}
}
示例12: s390_pragma_target_parse
static bool
s390_pragma_target_parse (tree args, tree pop_target)
{
tree prev_tree = build_target_option_node (&global_options);
tree cur_tree;
if (! args)
cur_tree = pop_target;
else
{
cur_tree = s390_valid_target_attribute_tree (args, &global_options,
&global_options_set, true);
if (!cur_tree || cur_tree == error_mark_node)
{
cl_target_option_restore (&global_options,
TREE_TARGET_OPTION (prev_tree));
return false;
}
}
target_option_current_node = cur_tree;
s390_activate_target_options (target_option_current_node);
{
struct cl_target_option *prev_opt;
struct cl_target_option *cur_opt;
/* Figure out the previous/current differences. */
prev_opt = TREE_TARGET_OPTION (prev_tree);
cur_opt = TREE_TARGET_OPTION (cur_tree);
/* For the definitions, ensure all newly defined macros are considered
as used for -Wunused-macros. There is no point warning about the
compiler predefined macros. */
cpp_options *cpp_opts = cpp_get_options (parse_in);
unsigned char saved_warn_unused_macros = cpp_opts->warn_unused_macros;
cpp_opts->warn_unused_macros = 0;
/* Define all of the macros for new options that were just turned on. */
s390_cpu_cpp_builtins_internal (parse_in, cur_opt, prev_opt);
cpp_opts->warn_unused_macros = saved_warn_unused_macros;
}
return true;
}
示例13: c_common_init_options
/* Common initialization before calling option handlers. */
void
c_common_init_options (unsigned int decoded_options_count,
struct cl_decoded_option *decoded_options)
{
unsigned int i;
struct cpp_callbacks *cb;
g_string_concat_db
= new (ggc_alloc <string_concat_db> ()) string_concat_db ();
parse_in = cpp_create_reader (c_dialect_cxx () ? CLK_GNUCXX: CLK_GNUC89,
ident_hash, line_table);
cb = cpp_get_callbacks (parse_in);
cb->diagnostic = c_cpp_diagnostic;
cpp_opts = cpp_get_options (parse_in);
cpp_opts->dollars_in_ident = DOLLARS_IN_IDENTIFIERS;
cpp_opts->objc = c_dialect_objc ();
/* Reset to avoid warnings on internal definitions. We set it just
before passing on command-line options to cpplib. */
cpp_opts->warn_dollars = 0;
deferred_opts = XNEWVEC (struct deferred_opt, decoded_options_count);
if (c_language == clk_c)
{
/* The default for C is gnu17. */
set_std_c17 (false /* ISO */);
/* If preprocessing assembly language, accept any of the C-family
front end options since the driver may pass them through. */
for (i = 1; i < decoded_options_count; i++)
if (decoded_options[i].opt_index == OPT_lang_asm)
{
accept_all_c_family_options = true;
break;
}
}
/* Set C++ standard to C++14 if not specified on the command line. */
if (c_dialect_cxx ())
set_std_cxx14 (/*ISO*/false);
global_dc->colorize_source_p = true;
}
示例14: interpret_integer
/* Interpret TOKEN, an integer with FLAGS as classified by cpplib. */
static tree
interpret_integer (const cpp_token *token, unsigned int flags)
{
tree value, type;
enum integer_type_kind itk;
cpp_num integer;
cpp_options *options = cpp_get_options (parse_in);
integer = cpp_interpret_integer (parse_in, token, flags);
integer = cpp_num_sign_extend (integer, options->precision);
/* The type of a constant with a U suffix is straightforward. */
if (flags & CPP_N_UNSIGNED)
itk = narrowest_unsigned_type (integer.low, integer.high, flags);
else
{
/* The type of a potentially-signed integer constant varies
depending on the base it's in, the standard in use, and the
length suffixes. */
enum integer_type_kind itk_u
= narrowest_unsigned_type (integer.low, integer.high, flags);
enum integer_type_kind itk_s
= narrowest_signed_type (integer.low, integer.high, flags);
/* In both C89 and C99, octal and hex constants may be signed or
unsigned, whichever fits tighter. We do not warn about this
choice differing from the traditional choice, as the constant
is probably a bit pattern and either way will work. */
if ((flags & CPP_N_RADIX) != CPP_N_DECIMAL)
itk = MIN (itk_u, itk_s);
else
{
/* In C99, decimal constants are always signed.
In C89, decimal constants that don't fit in long have
undefined behavior; we try to make them unsigned long.
In GCC's extended C89, that last is true of decimal
constants that don't fit in long long, too. */
itk = itk_s;
if (itk_s > itk_u && itk_s > itk_long)
{
if (!flag_isoc99)
{
if (itk_u < itk_unsigned_long)
itk_u = itk_unsigned_long;
itk = itk_u;
warning (0, "this decimal constant is unsigned only in ISO C90");
}
else
warning (OPT_Wtraditional,
"this decimal constant would be unsigned in ISO C90");
}
}
}
if (itk == itk_none)
/* cpplib has already issued a warning for overflow. */
type = ((flags & CPP_N_UNSIGNED)
? widest_unsigned_literal_type_node
: widest_integer_literal_type_node);
else
type = integer_types[itk];
if (itk > itk_unsigned_long
&& (flags & CPP_N_WIDTH) != CPP_N_LARGE
&& !in_system_header && !flag_isoc99)
pedwarn ("integer constant is too large for %qs type",
(flags & CPP_N_UNSIGNED) ? "unsigned long" : "long");
value = build_int_cst_wide (type, integer.low, integer.high);
/* Convert imaginary to a complex type. */
if (flags & CPP_N_IMAGINARY)
value = build_complex (NULL_TREE, build_int_cst (type, 0), value);
return value;
}
示例15: c_common_handle_option
/* Handle switch SCODE with argument ARG. VALUE is true, unless no-
form of an -f or -W option was given. Returns 0 if the switch was
invalid, a negative number to prevent language-independent
processing in toplev.c (a hack necessary for the short-term). */
int
c_common_handle_option (size_t scode, const char *arg, int value)
{
const struct cl_option *option = &cl_options[scode];
enum opt_code code = (enum opt_code) scode;
int result = 1;
/* Prevent resetting the language standard to a C dialect when the driver
has already determined that we're looking at assembler input. */
bool preprocessing_asm_p = (cpp_get_options (parse_in)->lang == CLK_ASM);
switch (code)
{
default:
if (cl_options[code].flags & (CL_C | CL_CXX | CL_ObjC | CL_ObjCXX))
break;
#ifdef CL_Fortran
if (lang_fortran && (cl_options[code].flags & (CL_Fortran)))
break;
#endif
result = 0;
break;
case OPT__output_pch_:
pch_file = arg;
break;
case OPT_A:
defer_opt (code, arg);
break;
case OPT_C:
cpp_opts->discard_comments = 0;
break;
case OPT_CC:
cpp_opts->discard_comments = 0;
cpp_opts->discard_comments_in_macro_exp = 0;
break;
case OPT_D:
defer_opt (code, arg);
break;
case OPT_E:
flag_preprocess_only = 1;
break;
case OPT_H:
cpp_opts->print_include_names = 1;
break;
case OPT_F:
TARGET_OPTF (xstrdup (arg));
break;
case OPT_I:
if (strcmp (arg, "-"))
add_path (xstrdup (arg), BRACKET, 0, true);
else
{
if (quote_chain_split)
error ("-I- specified twice");
quote_chain_split = true;
split_quote_chain ();
inform ("obsolete option -I- used, please use -iquote instead");
}
break;
case OPT_M:
case OPT_MM:
/* When doing dependencies with -M or -MM, suppress normal
preprocessed output, but still do -dM etc. as software
depends on this. Preprocessed output does occur if -MD, -MMD
or environment var dependency generation is used. */
cpp_opts->deps.style = (code == OPT_M ? DEPS_SYSTEM: DEPS_USER);
flag_no_output = 1;
cpp_opts->inhibit_warnings = 1;
break;
case OPT_MD:
case OPT_MMD:
cpp_opts->deps.style = (code == OPT_MD ? DEPS_SYSTEM: DEPS_USER);
deps_file = arg;
break;
case OPT_MF:
deps_seen = true;
deps_file = arg;
break;
case OPT_MG:
deps_seen = true;
cpp_opts->deps.missing_files = true;
break;
//.........这里部分代码省略.........