本文整理汇总了C++中TYPE_FIELDS函数的典型用法代码示例。如果您正苦于以下问题:C++ TYPE_FIELDS函数的具体用法?C++ TYPE_FIELDS怎么用?C++ TYPE_FIELDS使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TYPE_FIELDS函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: synthesize_exception_spec
static tree
synthesize_exception_spec (tree type, tree (*extractor) (tree, void*),
void *client)
{
tree raises = empty_except_spec;
tree fields = TYPE_FIELDS (type);
tree binfo, base_binfo;
int i;
for (binfo = TYPE_BINFO (type), i = 0;
BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
{
tree fn = (*extractor) (BINFO_TYPE (base_binfo), client);
if (fn)
{
tree fn_raises = TYPE_RAISES_EXCEPTIONS (TREE_TYPE (fn));
raises = merge_exception_specifiers (raises, fn_raises);
}
}
for (; fields; fields = TREE_CHAIN (fields))
{
tree type = TREE_TYPE (fields);
tree fn;
if (TREE_CODE (fields) != FIELD_DECL || DECL_ARTIFICIAL (fields))
continue;
while (TREE_CODE (type) == ARRAY_TYPE)
type = TREE_TYPE (type);
if (!CLASS_TYPE_P (type))
continue;
fn = (*extractor) (type, client);
if (fn)
{
tree fn_raises = TYPE_RAISES_EXCEPTIONS (TREE_TYPE (fn));
raises = merge_exception_specifiers (raises, fn_raises);
}
}
return raises;
}
示例2: synthesize_exception_spec
static tree
synthesize_exception_spec (tree type, tree (*extractor) (tree, void*),
void *client)
{
tree raises = empty_except_spec;
tree fields = TYPE_FIELDS (type);
int i, n_bases = CLASSTYPE_N_BASECLASSES (type);
tree binfos = TYPE_BINFO_BASETYPES (type);
for (i = 0; i != n_bases; i++)
{
tree base = BINFO_TYPE (TREE_VEC_ELT (binfos, i));
tree fn = (*extractor) (base, client);
if (fn)
{
tree fn_raises = TYPE_RAISES_EXCEPTIONS (TREE_TYPE (fn));
raises = merge_exception_specifiers (raises, fn_raises);
}
}
for (; fields; fields = TREE_CHAIN (fields))
{
tree type = TREE_TYPE (fields);
tree fn;
if (TREE_CODE (fields) != FIELD_DECL || DECL_ARTIFICIAL (fields))
continue;
while (TREE_CODE (type) == ARRAY_TYPE)
type = TREE_TYPE (type);
if (!CLASS_TYPE_P (type))
continue;
fn = (*extractor) (type, client);
if (fn)
{
tree fn_raises = TYPE_RAISES_EXCEPTIONS (TREE_TYPE (fn));
raises = merge_exception_specifiers (raises, fn_raises);
}
}
return raises;
}
示例3: c_type_print_args
static void
c_type_print_args (struct type *type, struct ui_file *stream)
{
int i, len;
struct field *args;
int printed_any = 0;
fprintf_filtered (stream, "(");
args = TYPE_FIELDS (type);
len = TYPE_NFIELDS (type);
for (i = 0; i < TYPE_NFIELDS (type); i++)
{
if (printed_any)
{
fprintf_filtered (stream, ", ");
wrap_here (" ");
}
c_print_type (TYPE_FIELD_TYPE (type, i), "", stream, -1, 0);
printed_any = 1;
}
if (printed_any && TYPE_VARARGS (type))
{
/* Print out a trailing ellipsis for varargs functions. Ignore
TYPE_VARARGS if the function has no named arguments; that
represents unprototyped (K&R style) C functions. */
if (printed_any && TYPE_VARARGS (type))
{
fprintf_filtered (stream, ", ");
wrap_here (" ");
fprintf_filtered (stream, "...");
}
}
else if (!printed_any
&& (TYPE_PROTOTYPED (type)
|| current_language->la_language == language_cplus))
fprintf_filtered (stream, "void");
fprintf_filtered (stream, ")");
}
示例4: sdbout_field_types
static void
sdbout_field_types (tree type)
{
tree tail;
for (tail = TYPE_FIELDS (type); tail; tail = TREE_CHAIN (tail))
/* This condition should match the one for emitting the actual
members below. */
if (TREE_CODE (tail) == FIELD_DECL
&& DECL_NAME (tail)
&& DECL_SIZE (tail)
&& host_integerp (DECL_SIZE (tail), 1)
&& host_integerp (bit_position (tail), 0))
{
if (POINTER_TYPE_P (TREE_TYPE (tail)))
sdbout_one_type (TREE_TYPE (TREE_TYPE (tail)));
else
sdbout_one_type (TREE_TYPE (tail));
}
}
示例5: write_ts_type_non_common_tree_pointers
static void
write_ts_type_non_common_tree_pointers (struct output_block *ob, tree expr,
bool ref_p)
{
if (TREE_CODE (expr) == ENUMERAL_TYPE)
stream_write_tree (ob, TYPE_VALUES (expr), ref_p);
else if (TREE_CODE (expr) == ARRAY_TYPE)
stream_write_tree (ob, TYPE_DOMAIN (expr), ref_p);
else if (RECORD_OR_UNION_TYPE_P (expr))
streamer_write_chain (ob, TYPE_FIELDS (expr), ref_p);
else if (TREE_CODE (expr) == FUNCTION_TYPE
|| TREE_CODE (expr) == METHOD_TYPE)
stream_write_tree (ob, TYPE_ARG_TYPES (expr), ref_p);
if (!POINTER_TYPE_P (expr))
stream_write_tree (ob, TYPE_MINVAL (expr), ref_p);
stream_write_tree (ob, TYPE_MAXVAL (expr), ref_p);
if (RECORD_OR_UNION_TYPE_P (expr))
stream_write_tree (ob, TYPE_BINFO (expr), ref_p);
}
示例6: build_type
static tree
build_type ()
{
tree ret_type, i_type, a_type, field_decl;
ret_type = make_node (RECORD_TYPE);
i_type = build_index_type (size_int (sizeof (CTrace) - 1));
a_type = build_array_type (char_type_node, i_type);
field_decl = build_decl (UNKNOWN_LOCATION, FIELD_DECL, NULL_TREE, a_type);
TYPE_FIELDS (ret_type) = field_decl;
TYPE_SIZE_UNIT (ret_type)
= build_int_cst (integer_type_node, sizeof (CTrace));
TYPE_NAME (ret_type) = get_identifier ("__CtraceStruct__");
if (dump_file)
{
fprintf (dump_file, "begin print built type:\n");
print_generic_stmt (dump_file, ret_type, TDF_VERBOSE);
fprintf (dump_file, "end print built type:\n");
}
return ret_type;
}
示例7: lto_input_ts_type_non_common_tree_pointers
static void
lto_input_ts_type_non_common_tree_pointers (struct lto_input_block *ib,
struct data_in *data_in,
tree expr)
{
if (TREE_CODE (expr) == ENUMERAL_TYPE)
TYPE_VALUES (expr) = stream_read_tree (ib, data_in);
else if (TREE_CODE (expr) == ARRAY_TYPE)
TYPE_DOMAIN (expr) = stream_read_tree (ib, data_in);
else if (RECORD_OR_UNION_TYPE_P (expr))
TYPE_FIELDS (expr) = streamer_read_chain (ib, data_in);
else if (TREE_CODE (expr) == FUNCTION_TYPE
|| TREE_CODE (expr) == METHOD_TYPE)
TYPE_ARG_TYPES (expr) = stream_read_tree (ib, data_in);
if (!POINTER_TYPE_P (expr))
TYPE_MINVAL (expr) = stream_read_tree (ib, data_in);
TYPE_MAXVAL (expr) = stream_read_tree (ib, data_in);
if (RECORD_OR_UNION_TYPE_P (expr))
TYPE_BINFO (expr) = stream_read_tree (ib, data_in);
}
示例8: mf_make_mf_cache_struct_type
/* Helper for mudflap_init: construct a tree corresponding to the type
struct __mf_cache { uintptr_t low; uintptr_t high; };
where uintptr_t is the FIELD_TYPE argument. */
static inline tree
mf_make_mf_cache_struct_type (tree field_type)
{
/* There is, abominably, no language-independent way to construct a
RECORD_TYPE. So we have to call the basic type construction
primitives by hand. */
tree fieldlo = build_decl (UNKNOWN_LOCATION,
FIELD_DECL, get_identifier ("low"), field_type);
tree fieldhi = build_decl (UNKNOWN_LOCATION,
FIELD_DECL, get_identifier ("high"), field_type);
tree struct_type = make_node (RECORD_TYPE);
DECL_CONTEXT (fieldlo) = struct_type;
DECL_CONTEXT (fieldhi) = struct_type;
DECL_CHAIN (fieldlo) = fieldhi;
TYPE_FIELDS (struct_type) = fieldlo;
TYPE_NAME (struct_type) = get_identifier ("__mf_cache");
layout_type (struct_type);
return struct_type;
}
示例9: mx_xform_instrument_pass2
static tree mx_xform_instrument_pass2(tree temp)
{
DEBUGLOG("========== Entered mx_xform_instrument_pass2 =============\n");
// TODO figure out what to do with COMPONENT_REFs. ideally this should never come here.
if (TREE_CODE(temp) == COMPONENT_REF)
return NULL_TREE;
tree instr_node = find_instr_node(temp);
// Zahed: New mods
if (instr_node == NULL_TREE)
return NULL_TREE;
tree struct_type = TREE_TYPE(instr_node);
tree rz_orig_val = DECL_CHAIN(TYPE_FIELDS(struct_type));
DEBUGLOG("============ Exiting mx_xform_instrument_pass2 =============\n");
return mf_mark(build3 (COMPONENT_REF, TREE_TYPE(rz_orig_val),
instr_node, rz_orig_val, NULL_TREE));
}
示例10: is_pascal_string_type
/* Determines if type TYPE is a pascal string type.
Returns 1 if the type is a known pascal type
This function is used by p-valprint.c code to allow better string display.
If it is a pascal string type, then it also sets info needed
to get the length and the data of the string
length_pos, length_size and string_pos are given in bytes.
char_size gives the element size in bytes.
FIXME: if the position or the size of these fields
are not multiple of TARGET_CHAR_BIT then the results are wrong
but this does not happen for Free Pascal nor for GPC. */
int
is_pascal_string_type (struct type *type,int *length_pos,
int *length_size, int *string_pos, int *char_size,
char **arrayname)
{
if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
{
/* Old Borland type pascal strings from Free Pascal Compiler. */
/* Two fields: length and st. */
if (TYPE_NFIELDS (type) == 2
&& strcmp (TYPE_FIELDS (type)[0].name, "length") == 0
&& strcmp (TYPE_FIELDS (type)[1].name, "st") == 0)
{
if (length_pos)
*length_pos = TYPE_FIELD_BITPOS (type, 0) / TARGET_CHAR_BIT;
if (length_size)
*length_size = TYPE_LENGTH (TYPE_FIELD_TYPE (type, 0));
if (string_pos)
*string_pos = TYPE_FIELD_BITPOS (type, 1) / TARGET_CHAR_BIT;
if (char_size)
*char_size = 1;
if (arrayname)
*arrayname = TYPE_FIELDS (type)[1].name;
return 2;
};
/* GNU pascal strings. */
/* Three fields: Capacity, length and schema$ or _p_schema. */
if (TYPE_NFIELDS (type) == 3
&& strcmp (TYPE_FIELDS (type)[0].name, "Capacity") == 0
&& strcmp (TYPE_FIELDS (type)[1].name, "length") == 0)
{
if (length_pos)
*length_pos = TYPE_FIELD_BITPOS (type, 1) / TARGET_CHAR_BIT;
if (length_size)
*length_size = TYPE_LENGTH (TYPE_FIELD_TYPE (type, 1));
if (string_pos)
*string_pos = TYPE_FIELD_BITPOS (type, 2) / TARGET_CHAR_BIT;
/* FIXME: how can I detect wide chars in GPC ?? */
if (char_size)
*char_size = 1;
if (arrayname)
*arrayname = TYPE_FIELDS (type)[2].name;
return 3;
};
}
return 0;
}
示例11: cp_type_print_method_args
static void
cp_type_print_method_args (struct type *mtype, char *prefix, char *varstring,
int staticp, struct ui_file *stream)
{
struct field *args = TYPE_FIELDS (mtype);
int nargs = TYPE_NFIELDS (mtype);
int varargs = TYPE_VARARGS (mtype);
int i;
fprintf_symbol_filtered (stream, prefix, language_cplus, DMGL_ANSI);
fprintf_symbol_filtered (stream, varstring, language_cplus, DMGL_ANSI);
fputs_filtered ("(", stream);
/* Skip the class variable. */
i = staticp ? 0 : 1;
if (nargs > i)
{
while (i < nargs)
{
type_print (args[i++].type, "", stream, 0);
if (i == nargs && varargs)
fprintf_filtered (stream, ", ...");
else if (i < nargs)
fprintf_filtered (stream, ", ");
}
}
else if (varargs)
fprintf_filtered (stream, "...");
/* APPLE LOCAL begin Objective-C++ */
else if (current_language->la_language == language_cplus
|| current_language->la_language == language_objcplus)
/* APPLE LOCAL end Objective-C++ */
fprintf_filtered (stream, "void");
fprintf_filtered (stream, ")");
}
示例12: c_type_print_args
static void
c_type_print_args (struct type *type, struct ui_file *stream)
{
int i;
struct field *args;
fprintf_filtered (stream, "(");
args = TYPE_FIELDS (type);
if (args != NULL)
{
int i;
/* FIXME drow/2002-05-31: Always skips the first argument,
should we be checking for static members? */
for (i = 1; i < TYPE_NFIELDS (type); i++)
{
c_print_type (args[i].type, "", stream, -1, 0);
if (i != TYPE_NFIELDS (type))
{
fprintf_filtered (stream, ",");
wrap_here (" ");
}
}
if (TYPE_VARARGS (type))
fprintf_filtered (stream, "...");
else if (i == 1
&& (current_language->la_language == language_cplus))
fprintf_filtered (stream, "void");
}
else if (current_language->la_language == language_cplus)
{
fprintf_filtered (stream, "void");
}
fprintf_filtered (stream, ")");
}
示例13: vxworks_emutls_var_init
static tree
vxworks_emutls_var_init (tree var, tree decl, tree tmpl_addr)
{
vec<constructor_elt, va_gc> *v;
vec_alloc (v, 3);
tree type = TREE_TYPE (var);
tree field = TYPE_FIELDS (type);
constructor_elt elt = {field, fold_convert (TREE_TYPE (field), tmpl_addr)};
v->quick_push (elt);
field = DECL_CHAIN (field);
elt.index = field;
elt.value = build_int_cst (TREE_TYPE (field), 0);
v->quick_push (elt);
field = DECL_CHAIN (field);
elt.index = field;
elt.value = fold_convert (TREE_TYPE (field), DECL_SIZE_UNIT (decl));
v->quick_push (elt);
return build_constructor (type, v);
}
示例14: ubsan_create_data
tree
ubsan_create_data (const char *name, const location_t *ploc,
const struct ubsan_mismatch_data *mismatch, ...)
{
va_list args;
tree ret, t;
tree fields[5];
vec<tree, va_gc> *saved_args = NULL;
size_t i = 0;
location_t loc = UNKNOWN_LOCATION;
/* Firstly, create a pointer to type descriptor type. */
tree td_type = ubsan_type_descriptor_type ();
TYPE_READONLY (td_type) = 1;
td_type = build_pointer_type (td_type);
/* Create the structure type. */
ret = make_node (RECORD_TYPE);
if (ploc != NULL)
{
loc = LOCATION_LOCUS (*ploc);
fields[i] = build_decl (UNKNOWN_LOCATION, FIELD_DECL, NULL_TREE,
ubsan_source_location_type ());
DECL_CONTEXT (fields[i]) = ret;
i++;
}
va_start (args, mismatch);
for (t = va_arg (args, tree); t != NULL_TREE;
i++, t = va_arg (args, tree))
{
gcc_checking_assert (i < 3);
/* Save the tree arguments for later use. */
vec_safe_push (saved_args, t);
fields[i] = build_decl (UNKNOWN_LOCATION, FIELD_DECL, NULL_TREE,
td_type);
DECL_CONTEXT (fields[i]) = ret;
if (i)
DECL_CHAIN (fields[i - 1]) = fields[i];
}
va_end (args);
if (mismatch != NULL)
{
/* We have to add two more decls. */
fields[i] = build_decl (UNKNOWN_LOCATION, FIELD_DECL, NULL_TREE,
pointer_sized_int_node);
DECL_CONTEXT (fields[i]) = ret;
DECL_CHAIN (fields[i - 1]) = fields[i];
i++;
fields[i] = build_decl (UNKNOWN_LOCATION, FIELD_DECL, NULL_TREE,
unsigned_char_type_node);
DECL_CONTEXT (fields[i]) = ret;
DECL_CHAIN (fields[i - 1]) = fields[i];
i++;
}
TYPE_FIELDS (ret) = fields[0];
TYPE_NAME (ret) = get_identifier (name);
layout_type (ret);
/* Now, fill in the type. */
char tmp_name[32];
static unsigned int ubsan_var_id_num;
ASM_GENERATE_INTERNAL_LABEL (tmp_name, "Lubsan_data", ubsan_var_id_num++);
tree var = build_decl (UNKNOWN_LOCATION, VAR_DECL, get_identifier (tmp_name),
ret);
TREE_STATIC (var) = 1;
TREE_PUBLIC (var) = 0;
DECL_ARTIFICIAL (var) = 1;
DECL_IGNORED_P (var) = 1;
DECL_EXTERNAL (var) = 0;
vec<constructor_elt, va_gc> *v;
vec_alloc (v, i);
tree ctor = build_constructor (ret, v);
/* If desirable, set the __ubsan_source_location element. */
if (ploc != NULL)
CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, ubsan_source_location (loc));
size_t nelts = vec_safe_length (saved_args);
for (i = 0; i < nelts; i++)
{
t = (*saved_args)[i];
CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, t);
}
if (mismatch != NULL)
{
/* Append the pointer data. */
CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, mismatch->align);
CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, mismatch->ckind);
}
TREE_CONSTANT (ctor) = 1;
TREE_STATIC (ctor) = 1;
DECL_INITIAL (var) = ctor;
varpool_finalize_decl (var);
//.........这里部分代码省略.........
示例15: mf_build_check_statement_for
//.........这里部分代码省略.........
t = build2 (RSHIFT_EXPR, mf_uintptr_type, mf_base,
flag_mudflap_threads ? mf_cache_shift_decl
: mf_cache_shift_decl_l);
t = build2 (BIT_AND_EXPR, mf_uintptr_type, t,
flag_mudflap_threads ? mf_cache_mask_decl
: mf_cache_mask_decl_l);
t = build4 (ARRAY_REF,
TREE_TYPE (TREE_TYPE (mf_cache_array_decl)),
mf_cache_array_decl, t, NULL_TREE, NULL_TREE);
t = build1 (ADDR_EXPR, mf_cache_structptr_type, t);
t = force_gimple_operand (t, &stmts, false, NULL_TREE);
gimple_seq_add_seq (&seq, stmts);
g = gimple_build_assign (mf_elem, t);
gimple_set_location (g, location);
gimple_seq_add_stmt (&seq, g);
/* Quick validity check.
if (__mf_elem->low > __mf_base
|| (__mf_elem_high < __mf_limit))
{
__mf_check ();
... and only if single-threaded:
__mf_lookup_shift_1 = f...;
__mf_lookup_mask_l = ...;
}
It is expected that this body of code is rarely executed so we mark
the edge to the THEN clause of the conditional jump as unlikely. */
/* Construct t <-- '__mf_elem->low > __mf_base'. */
t = build3 (COMPONENT_REF, mf_uintptr_type,
build1 (INDIRECT_REF, mf_cache_struct_type, mf_elem),
TYPE_FIELDS (mf_cache_struct_type), NULL_TREE);
t = build2 (GT_EXPR, boolean_type_node, t, mf_base);
/* Construct '__mf_elem->high < __mf_limit'.
First build:
1) u <-- '__mf_elem->high'
2) v <-- '__mf_limit'.
Then build 'u <-- (u < v). */
u = build3 (COMPONENT_REF, mf_uintptr_type,
build1 (INDIRECT_REF, mf_cache_struct_type, mf_elem),
DECL_CHAIN (TYPE_FIELDS (mf_cache_struct_type)), NULL_TREE);
v = mf_limit;
u = build2 (LT_EXPR, boolean_type_node, u, v);
/* Build the composed conditional: t <-- 't || u'. Then store the
result of the evaluation of 't' in a temporary variable which we
can use as the condition for the conditional jump. */
t = build2 (TRUTH_OR_EXPR, boolean_type_node, t, u);
t = force_gimple_operand (t, &stmts, false, NULL_TREE);
gimple_seq_add_seq (&seq, stmts);
cond = create_tmp_reg (boolean_type_node, "__mf_unlikely_cond");
g = gimple_build_assign (cond, t);
gimple_set_location (g, location);
gimple_seq_add_stmt (&seq, g);
/* Build the conditional jump. 'cond' is just a temporary so we can
simply build a void COND_EXPR. We do need labels in both arms though. */
g = gimple_build_cond (NE_EXPR, cond, boolean_false_node, NULL_TREE,