aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2009-05-21 05:58:39 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2009-05-21 05:58:39 +0000
commitc166b8981f366dfe1ec292221548b05e69c6c384 (patch)
treea25b2f396979fd0a56ba8a76180aba734398019a /gcc/tree.c
parent40449a90d7701eb70b5ccecb0f05290d442983e9 (diff)
downloadgcc-c166b8981f366dfe1ec292221548b05e69c6c384.zip
gcc-c166b8981f366dfe1ec292221548b05e69c6c384.tar.gz
gcc-c166b8981f366dfe1ec292221548b05e69c6c384.tar.bz2
tree.c (build_tree_list_vec_stat): New function.
./: * tree.c (build_tree_list_vec_stat): New function. (ctor_to_vec): New function. (build_nt_call_vec): New function. (build_call_array): Change args to be a const pointer. (build_call_vec): New function. * tree.h (build_nt_call_vec): Declare. (build_tree_list_vec_stat): Declare. (build_tree_list_vec): Define. (build_call_array): Update declaration. (build_call_vec): Declare. (ctor_to_vec): Declare. * c-common.c (tree_vector_cache): New static variable. (make_tree_vector): New function. (release_tree_vector): New function. (make_tree_vector_single): New function. (make_tree_vector_copy): New function. * c-common.h (tree_vector_cache, make_tree_vector): Declare. (make_tree_vector_single, make_tree_vector_copy): Declare. * c-parser.c (cached_expr_list_1, cached_expr_list_2): Remove. (c_parser_expr_list): Don't manage cache here, instead call make_tree_vector. (c_parser_release_expr_list): Remove static function. (c_parser_vec_to_tree_list): Remove static function. (c_parser_attributes): Call build_tree_list_vec instead of c_parser_vec_to_tree_list. Call release_tree_vector instead of c_parser_release_expr_list. (c_parser_postfix_expression_after_primary): Likewise. (c_parser_objc_keywordexpr): Likewise. cp/: * parser.c (cp_parser_postfix_expression): Change args to a vec. Release it when done. (tree_vector): Define typedef. Define VEC functions. (cp_parser_parenthesized_expression_list): Change return type to vec. Change all callers. (cp_parser_new_expression): Change placement and initializer to vecs. Release them when done. (cp_parser_new_placement): Change return type to vec. Change all callers. (cp_parser_new_initializer): Likewise. * typeck.c (build_function_call_vec): Just call cp_build_function_call_vec. (cp_build_function_call): Just build a vec and call cp_build_function_call_vec. (cp_build_function_call_vec): New function based on old cp_build_function_call. (convert_arguments): Remove nargs and argarray parameters. Change values to a vec. Change caller. (build_x_compound_expr_from_vec): New function. (cp_build_modify_expr): Build vec to pass to build_special_member_call. * call.c (struct z_candidate): Add first_arg field. Change args field to vec. (convert_class_to_reference): Handle first argument separately. (add_candidate): Add first_arg parameter. Change args parameter to vec. Change all callers. (add_function_candidate, add_conv_candidate): Likewise. (add_template_candidate_real, add_template_candidate): Likewise. (add_template_conv_candidate): Likewise. (build_user_type_conversion_1): Handle first argument separately. (resolve_args): Change return type and parameter type to vecs. Change all callers. (perform_overload_resolution): Change args parameter to vec. Change all callers. (build_new_function_call, build_operator_new_call): Likewise. (add_candidates): Likewise. (build_op_call): New globally visible function, built from and replacing static function build_object_call. (build_new_op): Don't handle CALL_EXPR. Build vec, not tree_list, of arguments. (build_op_delete_call): Build vec to pass to cp_build_function_call_vec. (build_temp): Build vec to pass to build_special_member_call. (convert_like_real): Likewise. (perform_direct_initialization_if_possible): Likewise. (build_over_call): Handle first_arg field. Use build_call_array rather than build_call_list. (build_special_member_call): Change args parameter to vec. Change all callers. (build_new_method_call): Likewise. * init.c (expand_default_init): Change parms to vec. (build_raw_new_expr): Change placement and init to vecs. Change all callers. (build_new_1, build_new): Likewise. * class.c (resolve_address_of_overloaded_function): Build array to pass to fn_type_unification. * pt.c (tsubst_copy_and_build): For NEW_EXPR build vecs to pass to build_new. For CALL_EXPR create a vec rather than a tree_list; expand a pack if necessary. (fn_type_unification): Change args parameter to const tree *. Add nargs parameter. Change all callers. (type_unification_real): Likewise. (unify): Build array to pass to type_unification_real. (get_bindings): Build array to pass to fn_type_unification. (any_type_dependent_arguments_p): Change args parameter to a vec. Change all callers. (make_args_non_dependent): Renamed from build_non_dependent_args. Change return type to void. Change parameter type to vec. Change all callers. (do_auto_deduction): Pass an array to type_unification_real. * semantics.c (perform_koenig_lookup): Change args to vec. Change all callers. (finish_call_expr): Change args to vec. Change all callers. Call build_op_call instead of passing CALL_EXPR to build_new_op. (cxx_omp_create_clause_info): Allocate vec to pass to build_special_member_call. * decl2.c (build_offset_ref_call_from_tree): Change args parameter to vec. Change all callers. * name-lookup.c (lookup_function_nonclass): Likewise. (struct arg_lookup): Change args to vec. (arg_assoc_namespace): Handle args as a vec. (arg_assoc_args_vec): New static function. (lookup_arg_dependent): Change args parameter to vec. Change all callers. * method.c (do_build_assign_ref): Allocate vec to pass to build_special_member_call. * except.c (build_throw): Likewise. * typeck2.c (build_functional_cast): Likewise. * cvt.c (ocp_convert): Likewise. * tree.c (build_min_non_dep_call_vec): Change last parameter to vec. Change all callers. * cp-tree.h: Update declarations. * name-lookup.h: Update declarations. objc/: * objc-act.c (objc_generate_cxx_ctor_or_dtor): Pass NULL rather than NULL_TREE to build_special_member_call. From-SVN: r147759
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c70
1 files changed, 69 insertions, 1 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index 92f16e7..b1ab5a5 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -1827,6 +1827,23 @@ build_tree_list_stat (tree parm, tree value MEM_STAT_DECL)
return t;
}
+/* Build a chain of TREE_LIST nodes from a vector. */
+
+tree
+build_tree_list_vec_stat (const VEC(tree,gc) *vec MEM_STAT_DECL)
+{
+ tree ret = NULL_TREE;
+ tree *pp = &ret;
+ unsigned int i;
+ tree t;
+ for (i = 0; VEC_iterate (tree, vec, i, t); ++i)
+ {
+ *pp = build_tree_list_stat (NULL, t PASS_MEM_STAT);
+ pp = &TREE_CHAIN (*pp);
+ }
+ return ret;
+}
+
/* Return a newly created TREE_LIST node whose
purpose and value fields are PURPOSE and VALUE
and whose TREE_CHAIN is CHAIN. */
@@ -1870,6 +1887,22 @@ ctor_to_list (tree ctor)
return list;
}
+
+/* Return the values of the elements of a CONSTRUCTOR as a vector of
+ trees. */
+
+VEC(tree,gc) *
+ctor_to_vec (tree ctor)
+{
+ VEC(tree, gc) *vec = VEC_alloc (tree, gc, CONSTRUCTOR_NELTS (ctor));
+ unsigned int ix;
+ tree val;
+
+ FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (ctor), ix, val)
+ VEC_quick_push (tree, vec, val);
+
+ return vec;
+}
/* Return the size nominally occupied by an object of type TYPE
when it resides in memory. The value is measured in units of bytes,
@@ -3483,6 +3516,23 @@ build_nt_call_list (tree fn, tree arglist)
CALL_EXPR_ARG (t, i) = TREE_VALUE (arglist);
return t;
}
+
+/* Similar to build_nt, but for creating a CALL_EXPR object with a
+ tree VEC. */
+
+tree
+build_nt_call_vec (tree fn, VEC(tree,gc) *args)
+{
+ tree ret, t;
+ unsigned int ix;
+
+ ret = build_vl_exp (CALL_EXPR, VEC_length (tree, args) + 3);
+ CALL_EXPR_FN (ret) = fn;
+ CALL_EXPR_STATIC_CHAIN (ret) = NULL_TREE;
+ for (ix = 0; VEC_iterate (tree, args, ix, t); ++ix)
+ CALL_EXPR_ARG (ret, ix) = t;
+ return ret;
+}
/* Create a DECL_... node of code CODE, name NAME and data type TYPE.
We do NOT enter this node in any sort of symbol table.
@@ -8240,7 +8290,7 @@ build_call_valist (tree return_type, tree fn, int nargs, va_list args)
which are specified as a tree array ARGS. */
tree
-build_call_array (tree return_type, tree fn, int nargs, tree *args)
+build_call_array (tree return_type, tree fn, int nargs, const tree *args)
{
tree t;
int i;
@@ -8255,6 +8305,24 @@ build_call_array (tree return_type, tree fn, int nargs, tree *args)
return t;
}
+/* Like build_call_array, but takes a VEC. */
+
+tree
+build_call_vec (tree return_type, tree fn, VEC(tree,gc) *args)
+{
+ tree ret, t;
+ unsigned int ix;
+
+ ret = build_vl_exp (CALL_EXPR, VEC_length (tree, args) + 3);
+ TREE_TYPE (ret) = return_type;
+ CALL_EXPR_FN (ret) = fn;
+ CALL_EXPR_STATIC_CHAIN (ret) = NULL_TREE;
+ for (ix = 0; VEC_iterate (tree, args, ix, t); ++ix)
+ CALL_EXPR_ARG (ret, ix) = t;
+ process_call_operands (ret);
+ return ret;
+}
+
/* Returns true if it is possible to prove that the index of
an array access REF (an ARRAY_REF expression) falls into the