/* Add code: static gcov* __gcov_indirect_call_counters; // pointer to actual counter static void* __gcov_indirect_call_callee; // actual callee address */ static void init_ic_make_global_vars (void) { tree gcov_type_ptr; ptr_void = build_pointer_type (void_type_node); ic_void_ptr_var = build_decl (UNKNOWN_LOCATION, VAR_DECL, get_identifier ("__gcov_indirect_call_callee"), ptr_void); TREE_STATIC (ic_void_ptr_var) = 1; TREE_PUBLIC (ic_void_ptr_var) = 0; DECL_ARTIFICIAL (ic_void_ptr_var) = 1; DECL_INITIAL (ic_void_ptr_var) = NULL; if (targetm.have_tls) DECL_TLS_MODEL (ic_void_ptr_var) = decl_default_tls_model (ic_void_ptr_var); varpool_finalize_decl (ic_void_ptr_var); varpool_mark_needed_node (varpool_node (ic_void_ptr_var)); gcov_type_ptr = build_pointer_type (get_gcov_type ()); ic_gcov_type_ptr_var = build_decl (UNKNOWN_LOCATION, VAR_DECL, get_identifier ("__gcov_indirect_call_counters"), gcov_type_ptr); TREE_STATIC (ic_gcov_type_ptr_var) = 1; TREE_PUBLIC (ic_gcov_type_ptr_var) = 0; DECL_ARTIFICIAL (ic_gcov_type_ptr_var) = 1; DECL_INITIAL (ic_gcov_type_ptr_var) = NULL; if (targetm.have_tls) DECL_TLS_MODEL (ic_gcov_type_ptr_var) = decl_default_tls_model (ic_gcov_type_ptr_var); varpool_finalize_decl (ic_gcov_type_ptr_var); varpool_mark_needed_node (varpool_node (ic_gcov_type_ptr_var)); }
bool i386_pe_type_dllexport_p (tree decl) { gcc_assert (TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == FUNCTION_DECL); /* Avoid exporting compiler-generated default dtors and copy ctors. The only artificial methods that need to be exported are virtual and non-virtual thunks. */ if (TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE && DECL_ARTIFICIAL (decl) && !DECL_THUNK_P (decl)) return false; return true; }
bool is_gimple_reg (tree t) { var_ann_t ann; if (TREE_CODE (t) == SSA_NAME) t = SSA_NAME_VAR (t); if (!is_gimple_variable (t)) return false; if (!is_gimple_reg_type (TREE_TYPE (t))) return false; /* A volatile decl is not acceptable because we can't reuse it as needed. We need to copy it into a temp first. */ if (TREE_THIS_VOLATILE (t)) return false; /* We define "registers" as things that can be renamed as needed, which with our infrastructure does not apply to memory. */ if (needs_to_live_in_memory (t)) return false; /* Hard register variables are an interesting case. For those that are call-clobbered, we don't know where all the calls are, since we don't (want to) take into account which operations will turn into libcalls at the rtl level. For those that are call-saved, we don't currently model the fact that calls may in fact change global hard registers, nor do we examine ASM_CLOBBERS at the tree level, and so miss variable changes that might imply. All around, it seems safest to not do too much optimization with these at the tree level at all. We'll have to rely on the rtl optimizers to clean this up, as there we've got all the appropriate bits exposed. */ if (TREE_CODE (t) == VAR_DECL && DECL_HARD_REGISTER (t)) return false; /* Complex values must have been put into ssa form. That is, no assignments to the individual components. */ if (TREE_CODE (TREE_TYPE (t)) == COMPLEX_TYPE) return DECL_COMPLEX_GIMPLE_REG_P (t); /* Some compiler temporaries are created to be used exclusively in virtual operands (currently memory tags and sub-variables). These variables should never be considered GIMPLE registers. */ if (DECL_ARTIFICIAL (t) && (ann = var_ann (t)) != NULL) return ann->mem_tag_kind == NOT_A_TAG; return true; }
static void unpack_ts_decl_common_value_fields (struct bitpack_d *bp, tree expr) { DECL_MODE (expr) = bp_unpack_machine_mode (bp); DECL_NONLOCAL (expr) = (unsigned) bp_unpack_value (bp, 1); DECL_VIRTUAL_P (expr) = (unsigned) bp_unpack_value (bp, 1); DECL_IGNORED_P (expr) = (unsigned) bp_unpack_value (bp, 1); DECL_ABSTRACT_P (expr) = (unsigned) bp_unpack_value (bp, 1); DECL_ARTIFICIAL (expr) = (unsigned) bp_unpack_value (bp, 1); DECL_USER_ALIGN (expr) = (unsigned) bp_unpack_value (bp, 1); DECL_PRESERVE_P (expr) = (unsigned) bp_unpack_value (bp, 1); DECL_EXTERNAL (expr) = (unsigned) bp_unpack_value (bp, 1); DECL_GIMPLE_REG_P (expr) = (unsigned) bp_unpack_value (bp, 1); DECL_ALIGN (expr) = (unsigned) bp_unpack_var_len_unsigned (bp); #ifdef ACCEL_COMPILER if (DECL_ALIGN (expr) > targetm.absolute_biggest_alignment) DECL_ALIGN (expr) = targetm.absolute_biggest_alignment; #endif if (TREE_CODE (expr) == LABEL_DECL) { EH_LANDING_PAD_NR (expr) = (int) bp_unpack_var_len_unsigned (bp); /* Always assume an initial value of -1 for LABEL_DECL_UID to force gimple_set_bb to recreate label_to_block_map. */ LABEL_DECL_UID (expr) = -1; } if (TREE_CODE (expr) == FIELD_DECL) { DECL_PACKED (expr) = (unsigned) bp_unpack_value (bp, 1); DECL_NONADDRESSABLE_P (expr) = (unsigned) bp_unpack_value (bp, 1); expr->decl_common.off_align = bp_unpack_value (bp, 8); } if (TREE_CODE (expr) == VAR_DECL) { DECL_HAS_DEBUG_EXPR_P (expr) = (unsigned) bp_unpack_value (bp, 1); DECL_NONLOCAL_FRAME (expr) = (unsigned) bp_unpack_value (bp, 1); } if (TREE_CODE (expr) == RESULT_DECL || TREE_CODE (expr) == PARM_DECL || TREE_CODE (expr) == VAR_DECL) { DECL_BY_REFERENCE (expr) = (unsigned) bp_unpack_value (bp, 1); if (TREE_CODE (expr) == VAR_DECL || TREE_CODE (expr) == PARM_DECL) DECL_HAS_VALUE_EXPR_P (expr) = (unsigned) bp_unpack_value (bp, 1); } }
tree copy_var_decl (tree var, tree name, tree type) { tree copy = build_decl (DECL_SOURCE_LOCATION (var), VAR_DECL, name, type); TREE_ADDRESSABLE (copy) = TREE_ADDRESSABLE (var); TREE_THIS_VOLATILE (copy) = TREE_THIS_VOLATILE (var); DECL_GIMPLE_REG_P (copy) = DECL_GIMPLE_REG_P (var); DECL_ARTIFICIAL (copy) = DECL_ARTIFICIAL (var); DECL_IGNORED_P (copy) = DECL_IGNORED_P (var); DECL_CONTEXT (copy) = DECL_CONTEXT (var); TREE_NO_WARNING (copy) = TREE_NO_WARNING (var); TREE_USED (copy) = 1; DECL_SEEN_IN_BIND_EXPR_P (copy) = 1; DECL_ATTRIBUTES (copy) = DECL_ATTRIBUTES (var); if (DECL_USER_ALIGN (var)) { SET_DECL_ALIGN (copy, DECL_ALIGN (var)); DECL_USER_ALIGN (copy) = 1; } return copy; }
static void push_eh_info () { tree decl, fn = call_eh_info (); /* Remember the pointer to the current exception info; it won't change during this catch block. */ decl = build_decl (VAR_DECL, get_identifier ("__exception_info"), TREE_TYPE (fn)); DECL_ARTIFICIAL (decl) = 1; DECL_INITIAL (decl) = fn; decl = pushdecl (decl); cp_finish_decl (decl, fn, NULL_TREE, 0); }
/* Helper for mudflap_init: construct a decl with the given category, name, and type, mark it an external reference, and pushdecl it. */ static inline tree mf_make_builtin (enum tree_code category, const char *name, tree type) { tree decl = mf_mark (build_decl (UNKNOWN_LOCATION, category, get_identifier (name), type)); TREE_PUBLIC (decl) = 1; DECL_EXTERNAL (decl) = 1; lang_hooks.decls.pushdecl (decl); /* The decl was declared by the compiler. */ DECL_ARTIFICIAL (decl) = 1; /* And we don't want debug info for it. */ DECL_IGNORED_P (decl) = 1; return decl; }
tree start_var_decl (tree type, const char *name) { tree var = build_decl (input_location, VAR_DECL, get_identifier (name), type); TREE_STATIC (var) = 1; DECL_INITIAL (var) = error_mark_node; /* A real initializer is coming... */ DECL_IGNORED_P (var) = 1; DECL_ARTIFICIAL (var) = 1; DECL_CONTEXT (var) = NULL_TREE; #ifdef OBJCPLUS DECL_THIS_STATIC (var) = 1; /* squash redeclaration errors */ #endif return var; }
void mudflap_enqueue_decl (tree obj) { if (mf_marked_p (obj)) return; /* We don't need to process variable decls that are internally generated extern. If we did, we'd end up with warnings for them during mudflap_finish_file (). That would confuse the user, since the text would refer to variables that don't show up in the user's source code. */ if (DECL_P (obj) && DECL_EXTERNAL (obj) && DECL_ARTIFICIAL (obj)) return; VEC_safe_push (tree, gc, deferred_static_decls, obj); }
static tree build_exception_object_var (void) { tree decl = DECL_FUNCTION_EXC_OBJ (current_function_decl); if (decl == NULL) { decl = build_decl (DECL_SOURCE_LOCATION (current_function_decl), VAR_DECL, get_identifier ("#exc_obj"), ptr_type_node); DECL_IGNORED_P (decl) = 1; DECL_ARTIFICIAL (decl) = 1; DECL_FUNCTION_EXC_OBJ (current_function_decl) = decl; pushdecl_function_level (decl); } return decl; }
static void execute_mudflap_function_decls (void) { /* Don't instrument functions such as the synthetic constructor built during mudflap_finish_file. */ if (mf_marked_p (current_function_decl) || DECL_ARTIFICIAL (current_function_decl)) return; push_gimplify_context (); mf_xform_decls (DECL_SAVED_TREE (current_function_decl), DECL_ARGUMENTS (current_function_decl)); pop_gimplify_context (NULL); }
static void pack_ts_decl_common_value_fields (struct bitpack_d *bp, tree expr) { bp_pack_enum (bp, machine_mode, MAX_MACHINE_MODE, DECL_MODE (expr)); bp_pack_value (bp, DECL_NONLOCAL (expr), 1); bp_pack_value (bp, DECL_VIRTUAL_P (expr), 1); bp_pack_value (bp, DECL_IGNORED_P (expr), 1); bp_pack_value (bp, DECL_ABSTRACT (expr), 1); bp_pack_value (bp, DECL_ARTIFICIAL (expr), 1); bp_pack_value (bp, DECL_USER_ALIGN (expr), 1); bp_pack_value (bp, DECL_PRESERVE_P (expr), 1); bp_pack_value (bp, DECL_EXTERNAL (expr), 1); bp_pack_value (bp, DECL_GIMPLE_REG_P (expr), 1); bp_pack_var_len_unsigned (bp, DECL_ALIGN (expr)); if (TREE_CODE (expr) == LABEL_DECL) { /* Note that we do not write LABEL_DECL_UID. The reader will always assume an initial value of -1 so that the label_to_block_map is recreated by gimple_set_bb. */ bp_pack_value (bp, DECL_ERROR_ISSUED (expr), 1); bp_pack_var_len_unsigned (bp, EH_LANDING_PAD_NR (expr)); } if (TREE_CODE (expr) == FIELD_DECL) { bp_pack_value (bp, DECL_PACKED (expr), 1); bp_pack_value (bp, DECL_NONADDRESSABLE_P (expr), 1); bp_pack_value (bp, expr->decl_common.off_align, 8); } if (TREE_CODE (expr) == VAR_DECL) { bp_pack_value (bp, DECL_HAS_DEBUG_EXPR_P (expr), 1); bp_pack_value (bp, DECL_NONLOCAL_FRAME (expr), 1); } if (TREE_CODE (expr) == RESULT_DECL || TREE_CODE (expr) == PARM_DECL || TREE_CODE (expr) == VAR_DECL) { bp_pack_value (bp, DECL_BY_REFERENCE (expr), 1); if (TREE_CODE (expr) == VAR_DECL || TREE_CODE (expr) == PARM_DECL) bp_pack_value (bp, DECL_HAS_VALUE_EXPR_P (expr), 1); } }
static tree make_alias_for_thunk (tree function) { tree alias; char buf[256]; #if defined (TARGET_IS_PE_COFF) if (DECL_ONE_ONLY (function)) return function; #endif ASM_GENERATE_INTERNAL_LABEL (buf, "LTHUNK", thunk_labelno); thunk_labelno++; alias = build_decl (FUNCTION_DECL, get_identifier (buf), TREE_TYPE (function)); DECL_LANG_SPECIFIC (alias) = DECL_LANG_SPECIFIC (function); cxx_dup_lang_specific_decl (alias); DECL_CONTEXT (alias) = NULL; TREE_READONLY (alias) = TREE_READONLY (function); TREE_THIS_VOLATILE (alias) = TREE_THIS_VOLATILE (function); TREE_PUBLIC (alias) = 0; DECL_INTERFACE_KNOWN (alias) = 1; DECL_NOT_REALLY_EXTERN (alias) = 1; DECL_THIS_STATIC (alias) = 1; DECL_SAVED_FUNCTION_DATA (alias) = NULL; DECL_DESTRUCTOR_P (alias) = 0; DECL_CONSTRUCTOR_P (alias) = 0; DECL_CLONED_FUNCTION (alias) = NULL_TREE; DECL_EXTERNAL (alias) = 0; DECL_ARTIFICIAL (alias) = 1; DECL_NO_STATIC_CHAIN (alias) = 1; DECL_PENDING_INLINE_P (alias) = 0; DECL_INLINE (alias) = 0; DECL_DECLARED_INLINE_P (alias) = 0; DECL_DEFERRED_FN (alias) = 0; DECL_USE_TEMPLATE (alias) = 0; DECL_TEMPLATE_INSTANTIATED (alias) = 0; DECL_TEMPLATE_INFO (alias) = NULL; DECL_INITIAL (alias) = error_mark_node; TREE_ADDRESSABLE (alias) = 1; TREE_USED (alias) = 1; SET_DECL_ASSEMBLER_NAME (alias, DECL_NAME (alias)); TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (alias)) = 1; if (!flag_syntax_only) assemble_alias (alias, DECL_ASSEMBLER_NAME (function)); return alias; }
static void unpack_ts_decl_common_value_fields (struct bitpack_d *bp, tree expr) { DECL_MODE (expr) = bp_unpack_enum (bp, machine_mode, MAX_MACHINE_MODE); DECL_NONLOCAL (expr) = (unsigned) bp_unpack_value (bp, 1); DECL_VIRTUAL_P (expr) = (unsigned) bp_unpack_value (bp, 1); DECL_IGNORED_P (expr) = (unsigned) bp_unpack_value (bp, 1); DECL_ABSTRACT (expr) = (unsigned) bp_unpack_value (bp, 1); DECL_ARTIFICIAL (expr) = (unsigned) bp_unpack_value (bp, 1); DECL_USER_ALIGN (expr) = (unsigned) bp_unpack_value (bp, 1); DECL_PRESERVE_P (expr) = (unsigned) bp_unpack_value (bp, 1); DECL_DEBUG_EXPR_IS_FROM (expr) = (unsigned) bp_unpack_value (bp, 1); DECL_EXTERNAL (expr) = (unsigned) bp_unpack_value (bp, 1); DECL_GIMPLE_REG_P (expr) = (unsigned) bp_unpack_value (bp, 1); DECL_ALIGN (expr) = (unsigned) bp_unpack_var_len_unsigned (bp); if (TREE_CODE (expr) == LABEL_DECL) { DECL_ERROR_ISSUED (expr) = (unsigned) bp_unpack_value (bp, 1); EH_LANDING_PAD_NR (expr) = (int) bp_unpack_var_len_unsigned (bp); /* Always assume an initial value of -1 for LABEL_DECL_UID to force gimple_set_bb to recreate label_to_block_map. */ LABEL_DECL_UID (expr) = -1; } if (TREE_CODE (expr) == FIELD_DECL) { DECL_PACKED (expr) = (unsigned) bp_unpack_value (bp, 1); DECL_NONADDRESSABLE_P (expr) = (unsigned) bp_unpack_value (bp, 1); expr->decl_common.off_align = bp_unpack_value (bp, 8); } if (TREE_CODE (expr) == VAR_DECL) DECL_NONLOCAL_FRAME (expr) = (unsigned) bp_unpack_value (bp, 1); if (TREE_CODE (expr) == RESULT_DECL || TREE_CODE (expr) == PARM_DECL || TREE_CODE (expr) == VAR_DECL) { DECL_BY_REFERENCE (expr) = (unsigned) bp_unpack_value (bp, 1); if (TREE_CODE (expr) == VAR_DECL || TREE_CODE (expr) == PARM_DECL) DECL_HAS_VALUE_EXPR_P (expr) = (unsigned) bp_unpack_value (bp, 1); } }
static unsigned int execute_mudflap_function_ops (void) { struct gimplify_ctx gctx; DEBUGLOG("Zahed: entering LBC pass2\n"); //return; /* Don't instrument functions such as the synthetic constructor built during mudflap_finish_file. */ if (mf_marked_p (current_function_decl) || DECL_ARTIFICIAL (current_function_decl)) return 0; push_gimplify_context (&gctx); mf_xform_statements (); pop_gimplify_context (NULL); return 0; }
static tree get_real_ref_rhs (tree expr) { switch (TREE_CODE (expr)) { case SSA_NAME: { /* Given a self-assign statement, say foo.x = foo.x, the IR (after SSA) looks like: D.1797_14 = foo.x; foo.x ={v} D.1797_14; So if the rhs EXPR is an SSA_NAME of a temp variable, e.g. D.1797_14, we need to grab the rhs of its SSA def statement (i.e. foo.x). */ tree vdecl = SSA_NAME_VAR (expr); if ((!vdecl || DECL_ARTIFICIAL (vdecl)) && !gimple_nop_p (SSA_NAME_DEF_STMT (expr))) { gimple def_stmt = SSA_NAME_DEF_STMT (expr); /* We are only interested in an assignment with a single rhs operand because if it is not, the original assignment will not possibly be a self-assignment. */ if (gimple_assign_single_p (def_stmt)) return get_real_ref_rhs (gimple_assign_rhs1 (def_stmt)); else return NULL_TREE; } else return vdecl; } case VAR_DECL: case PARM_DECL: case FIELD_DECL: case COMPONENT_REF: case MEM_REF: case ARRAY_REF: return expr; default: return NULL_TREE; } }
static tree check_noexcept_r (tree *tp, int * /*walk_subtrees*/, void * /*data*/) { tree t = *tp; enum tree_code code = TREE_CODE (t); if ((code == CALL_EXPR && CALL_EXPR_FN (t)) || code == AGGR_INIT_EXPR) { /* We can only use the exception specification of the called function for determining the value of a noexcept expression; we can't use TREE_NOTHROW, as it might have a different value in another translation unit, creating ODR problems. We could use TREE_NOTHROW (t) for !TREE_PUBLIC fns, though... */ tree fn = (code == AGGR_INIT_EXPR ? AGGR_INIT_EXPR_FN (t) : CALL_EXPR_FN (t)); tree type = TREE_TYPE (fn); gcc_assert (POINTER_TYPE_P (type)); type = TREE_TYPE (type); STRIP_NOPS (fn); if (TREE_CODE (fn) == ADDR_EXPR) fn = TREE_OPERAND (fn, 0); if (TREE_CODE (fn) == FUNCTION_DECL) { /* We do use TREE_NOTHROW for ABI internals like __dynamic_cast, and for C library functions known not to throw. */ if (DECL_EXTERN_C_P (fn) && (DECL_ARTIFICIAL (fn) || nothrow_libfn_p (fn))) return TREE_NOTHROW (fn) ? NULL_TREE : fn; /* A call to a constexpr function is noexcept if the call is a constant expression. */ if (DECL_DECLARED_CONSTEXPR_P (fn) && is_sub_constant_expr (t)) return NULL_TREE; } if (!TYPE_NOTHROW_P (type)) return fn; } return NULL_TREE; }
void compile_resource_data (const char *name, const char *buffer, int length) { tree rtype, field = NULL_TREE, data_type, rinit, data, decl; char buf[60]; data_type = build_prim_array_type (unsigned_byte_type_node, strlen (name) + length); rtype = make_node (RECORD_TYPE); PUSH_FIELD (rtype, field, "name_length", unsigned_int_type_node); PUSH_FIELD (rtype, field, "resource_length", unsigned_int_type_node); PUSH_FIELD (rtype, field, "data", data_type); FINISH_RECORD (rtype); START_RECORD_CONSTRUCTOR (rinit, rtype); PUSH_FIELD_VALUE (rinit, "name_length", build_int_cst (NULL_TREE, strlen (name))); PUSH_FIELD_VALUE (rinit, "resource_length", build_int_cst (NULL_TREE, length)); data = build_string (strlen(name) + length, buffer); TREE_TYPE (data) = data_type; PUSH_FIELD_VALUE (rinit, "data", data); FINISH_RECORD_CONSTRUCTOR (rinit); TREE_CONSTANT (rinit) = 1; TREE_INVARIANT (rinit) = 1; /* Generate a unique-enough identifier. */ sprintf (buf, "_Jr%d", ++Jr_count); decl = build_decl (VAR_DECL, get_identifier (buf), rtype); TREE_STATIC (decl) = 1; DECL_ARTIFICIAL (decl) = 1; DECL_IGNORED_P (decl) = 1; TREE_READONLY (decl) = 1; TREE_THIS_VOLATILE (decl) = 0; DECL_INITIAL (decl) = rinit; layout_decl (decl, 0); pushdecl (decl); rest_of_decl_compilation (decl, global_bindings_p (), 0); make_decl_rtl (decl); assemble_variable (decl, 1, 0, 0); resources = tree_cons (NULL_TREE, decl, resources); }
static tree build_trivial_generic_function () { auto_vec <tree> param_types; tree fndecl = make_fndecl (integer_type_node, "test_fn", param_types); ASSERT_TRUE (fndecl != NULL); /* Populate the function. */ tree retval = build_decl (UNKNOWN_LOCATION, RESULT_DECL, NULL_TREE, integer_type_node); DECL_ARTIFICIAL (retval) = 1; DECL_IGNORED_P (retval) = 1; DECL_RESULT (fndecl) = retval; /* Create a BIND_EXPR, and within it, a statement list. */ tree stmt_list = alloc_stmt_list (); tree_stmt_iterator stmt_iter = tsi_start (stmt_list); tree block = make_node (BLOCK); tree bind_expr = build3 (BIND_EXPR, void_type_node, NULL, stmt_list, block); tree modify_retval = build2 (MODIFY_EXPR, integer_type_node, retval, build_int_cst (integer_type_node, 42)); tree return_stmt = build1 (RETURN_EXPR, integer_type_node, modify_retval); tsi_link_after (&stmt_iter, return_stmt, TSI_CONTINUE_LINKING); DECL_INITIAL (fndecl) = block; /* how to add to function? the following appears to be how to set the body of a fndecl: */ DECL_SAVED_TREE(fndecl) = bind_expr; /* Ensure that locals appear in the debuginfo. */ BLOCK_VARS (block) = BIND_EXPR_VARS (bind_expr); return fndecl; }
static void finish_unit_callback (void *gcc_data, void *user_data) { if (fake_var == NULL) { printf ("fake_var not created \n"); return; } if (TREE_CODE (fake_var) != VAR_DECL) { printf ("fake_var not a VAR_DECL \n"); return; } if (TREE_CODE (TREE_TYPE (fake_var)) != INTEGER_TYPE) { printf ("fake_var not INTEGER_TYPE \n"); return; } if (DECL_ARTIFICIAL (fake_var) == 0) { printf ("fake_var not ARTIFICIAL \n"); return; } }
void compile_resource_data (const char *name, const char *buffer, int length) { tree rtype, field = NULL_TREE, data_type, rinit, data, decl; VEC(constructor_elt,gc) *v = NULL; data_type = build_prim_array_type (unsigned_byte_type_node, strlen (name) + length); rtype = make_node (RECORD_TYPE); PUSH_FIELD (input_location, rtype, field, "name_length", unsigned_int_type_node); PUSH_FIELD (input_location, rtype, field, "resource_length", unsigned_int_type_node); PUSH_FIELD (input_location, rtype, field, "data", data_type); FINISH_RECORD (rtype); START_RECORD_CONSTRUCTOR (v, rtype); PUSH_FIELD_VALUE (v, "name_length", build_int_cst (NULL_TREE, strlen (name))); PUSH_FIELD_VALUE (v, "resource_length", build_int_cst (NULL_TREE, length)); data = build_string (strlen(name) + length, buffer); TREE_TYPE (data) = data_type; PUSH_FIELD_VALUE (v, "data", data); FINISH_RECORD_CONSTRUCTOR (rinit, v, rtype); TREE_CONSTANT (rinit) = 1; decl = build_decl (input_location, VAR_DECL, java_mangle_resource_name (name), rtype); TREE_STATIC (decl) = 1; TREE_PUBLIC (decl) = 1; java_hide_decl (decl); DECL_ARTIFICIAL (decl) = 1; DECL_IGNORED_P (decl) = 1; TREE_READONLY (decl) = 1; TREE_THIS_VOLATILE (decl) = 0; DECL_INITIAL (decl) = rinit; layout_decl (decl, 0); pushdecl (decl); rest_of_decl_compilation (decl, global_bindings_p (), 0); varpool_finalize_decl (decl); VEC_safe_push (tree, gc, resources, decl); }
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; }
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; }
static void warn_self_assign (gimple stmt) { tree rhs, lhs; /* Check assigment statement. */ if (gimple_assign_single_p (stmt)) { rhs = get_real_ref_rhs (gimple_assign_rhs1 (stmt)); if (!rhs) return; lhs = gimple_assign_lhs (stmt); if (TREE_CODE (lhs) == SSA_NAME) { lhs = SSA_NAME_VAR (lhs); if (!lhs || DECL_ARTIFICIAL (lhs)) return; } compare_and_warn (stmt, lhs, rhs); } /* Check overloaded operator '=' (if enabled). */ else if (check_operator_eq && is_gimple_call (stmt)) { tree fdecl = gimple_call_fndecl (stmt); if (fdecl && (DECL_NAME (fdecl) == maybe_get_identifier ("operator="))) { /* If 'operator=' takes reference operands, the arguments will be ADDR_EXPR trees. In this case, just remove the address-taken operator before we compare the lhs and rhs. */ lhs = gimple_call_arg (stmt, 0); if (TREE_CODE (lhs) == ADDR_EXPR) lhs = TREE_OPERAND (lhs, 0); rhs = gimple_call_arg (stmt, 1); if (TREE_CODE (rhs) == ADDR_EXPR) rhs = TREE_OPERAND (rhs, 0); compare_and_warn (stmt, lhs, rhs); } } }
static bool cp_ubsan_maybe_instrument_member_access (tree stmt, cp_ubsan_check_member_access_data *ucmd) { if (DECL_ARTIFICIAL (TREE_OPERAND (stmt, 1))) return false; tree base = TREE_OPERAND (stmt, 0); if (!cp_ubsan_instrument_vptr_p (TREE_TYPE (base))) return false; cp_walk_tree (&base, cp_ubsan_check_member_access_r, ucmd, ucmd->pset); base = cp_ubsan_instrument_vptr (EXPR_LOCATION (stmt), base, TREE_TYPE (base), false, UBSAN_MEMBER_ACCESS); TREE_OPERAND (stmt, 0) = build_fold_indirect_ref_loc (EXPR_LOCATION (stmt), base); return true; }
static void build_one_array (gimple swtch, int num, tree arr_index_type, gimple phi, tree tidx) { tree array_type, ctor, decl, value_type, name, fetch; gimple load; gimple_stmt_iterator gsi; gcc_assert (info.default_values[num]); value_type = TREE_TYPE (info.default_values[num]); array_type = build_array_type (value_type, arr_index_type); ctor = build_constructor (array_type, info.constructors[num]); TREE_CONSTANT (ctor) = true; decl = build_decl (VAR_DECL, NULL_TREE, array_type); TREE_STATIC (decl) = 1; DECL_INITIAL (decl) = ctor; DECL_NAME (decl) = create_tmp_var_name ("CSWTCH"); DECL_ARTIFICIAL (decl) = 1; TREE_CONSTANT (decl) = 1; add_referenced_var (decl); varpool_mark_needed_node (varpool_node (decl)); varpool_finalize_decl (decl); mark_sym_for_renaming (decl); name = make_ssa_name (SSA_NAME_VAR (PHI_RESULT (phi)), NULL); info.target_inbound_names[num] = name; fetch = build4 (ARRAY_REF, value_type, decl, tidx, NULL_TREE, NULL_TREE); load = gimple_build_assign (name, fetch); SSA_NAME_DEF_STMT (name) = load; gsi = gsi_for_stmt (swtch); gsi_insert_before (&gsi, load, GSI_SAME_STMT); mark_symbols_for_renaming (load); info.arr_ref_last = load; }
static void lower_gimple_return (gimple_stmt_iterator *gsi, struct lower_data *data) { gimple stmt = gsi_stmt (*gsi); gimple t; int i; return_statements_t tmp_rs; /* Match this up with an existing return statement that's been created. */ for (i = data->return_statements.length () - 1; i >= 0; i--) { tmp_rs = data->return_statements[i]; if (gimple_return_retval (stmt) == gimple_return_retval (tmp_rs.stmt)) { /* Remove the line number from the representative return statement. It now fills in for many such returns. Failure to remove this will result in incorrect results for coverage analysis. */ gimple_set_location (tmp_rs.stmt, UNKNOWN_LOCATION); goto found; } } /* Not found. Create a new label and record the return statement. */ tmp_rs.label = create_artificial_label (cfun->function_end_locus); tmp_rs.stmt = stmt; data->return_statements.safe_push (tmp_rs); /* Generate a goto statement and remove the return statement. */ found: /* When not optimizing, make sure user returns are preserved. */ if (!optimize && gimple_has_location (stmt)) DECL_ARTIFICIAL (tmp_rs.label) = 0; t = gimple_build_goto (tmp_rs.label); gimple_set_location (t, gimple_location (stmt)); gimple_set_block (t, gimple_block (stmt)); gsi_insert_before (gsi, t, GSI_SAME_STMT); gsi_remove (gsi, false); }
tree make_alias_for (tree target, tree newid) { tree alias = build_decl (DECL_SOURCE_LOCATION (target), TREE_CODE (target), newid, TREE_TYPE (target)); DECL_LANG_SPECIFIC (alias) = DECL_LANG_SPECIFIC (target); cxx_dup_lang_specific_decl (alias); DECL_CONTEXT (alias) = NULL; TREE_READONLY (alias) = TREE_READONLY (target); TREE_THIS_VOLATILE (alias) = TREE_THIS_VOLATILE (target); TREE_PUBLIC (alias) = 0; DECL_INTERFACE_KNOWN (alias) = 1; if (DECL_LANG_SPECIFIC (alias)) { DECL_NOT_REALLY_EXTERN (alias) = 1; DECL_USE_TEMPLATE (alias) = 0; DECL_TEMPLATE_INFO (alias) = NULL; } DECL_EXTERNAL (alias) = 0; DECL_ARTIFICIAL (alias) = 1; DECL_TEMPLATE_INSTANTIATED (alias) = 0; if (TREE_CODE (alias) == FUNCTION_DECL) { DECL_SAVED_FUNCTION_DATA (alias) = NULL; DECL_DESTRUCTOR_P (alias) = 0; DECL_CONSTRUCTOR_P (alias) = 0; DECL_PENDING_INLINE_P (alias) = 0; DECL_DECLARED_INLINE_P (alias) = 0; DECL_INITIAL (alias) = error_mark_node; DECL_ARGUMENTS (alias) = copy_list (DECL_ARGUMENTS (target)); } else TREE_STATIC (alias) = 1; TREE_ADDRESSABLE (alias) = 1; TREE_USED (alias) = 1; SET_DECL_ASSEMBLER_NAME (alias, DECL_NAME (alias)); TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (alias)) = 1; return alias; }
static void execute_mudflap_function_ops (void) { /* Don't instrument functions such as the synthetic constructor built during mudflap_finish_file. */ if (mf_marked_p (current_function_decl) || DECL_ARTIFICIAL (current_function_decl)) return; push_gimplify_context (); /* In multithreaded mode, don't cache the lookup cache parameters. */ if (! flag_mudflap_threads) mf_decl_cache_locals (); mf_xform_derefs (); if (! flag_mudflap_threads) mf_decl_clear_locals (); pop_gimplify_context (NULL); }
static tree associated_type (tree decl) { tree t = NULL_TREE; /* In the C++ frontend, DECL_CONTEXT for a method doesn't actually refer to the containing class. So we look at the 'this' arg. */ if (TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE) { /* Artificial methods are not affected by the import/export status of their class unless they are COMDAT. Implicit copy ctor's and dtor's are not affected by class status but virtual and non-virtual thunks are. */ if (!DECL_ARTIFICIAL (decl) || DECL_COMDAT (decl)) t = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl))))); } else if (DECL_CONTEXT (decl) && TYPE_P (DECL_CONTEXT (decl))) t = DECL_CONTEXT (decl); return t; }