aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorDiego Novillo <dnovillo@google.com>2012-09-10 20:04:13 -0400
committerDiego Novillo <dnovillo@gcc.gnu.org>2012-09-10 20:04:13 -0400
commitf32682ca2516e009432be7f0dc0e4e4bfab9a944 (patch)
tree3030f0ec079f1a93f960208e432eb6f275d10a28 /gcc/cp
parentda4c5b2465322894e6d53cd14128ba21d0ff911b (diff)
downloadgcc-f32682ca2516e009432be7f0dc0e4e4bfab9a944.zip
gcc-f32682ca2516e009432be7f0dc0e4e4bfab9a944.tar.gz
gcc-f32682ca2516e009432be7f0dc0e4e4bfab9a944.tar.bz2
Remove unnecessary VEC function overloads.
Several VEC member functions that accept an element 'T' used to have two overloads: one taking 'T', the second taking 'T *'. This used to be needed because of the interface dichotomy between vectors of objects and vectors of pointers. In the past, vectors of pointers would use pass-by-value semantics, but vectors of objects would use pass-by-reference semantics. This is no longer necessary, but the distinction had remained. The main side-effect of this change is some code reduction in code that manipulates vectors of objects. For instance, - struct iterator_use *iuse; - - iuse = VEC_safe_push (iterator_use, heap, iterator_uses, NULL); - iuse->iterator = iterator; - iuse->ptr = ptr; + struct iterator_use iuse = {iterator, ptr}; + VEC_safe_push (iterator_use, heap, iterator_uses, iuse); Compile time performance was not affected. Tested on x86_64 and ppc64. Also built all-gcc on all targets using VEC routines: arm, bfin, c6x, epiphany, ia64, mips, sh, spu, and vms. 2012-09-10 Diego Novillo <dnovillo@google.com> * vec.h (vec_t::quick_push): Remove overload that accepts 'T *'. Update all users. (vec_t::safe_push): Likewise. (vec_t::quick_insert): Likewise. (vec_t::lower_bound): Likewise. (vec_t::safe_insert): Likewise. (vec_t::replace): Change second argument to 'T &'. From-SVN: r191165
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/class.c8
-rw-r--r--gcc/cp/decl.c16
-rw-r--r--gcc/cp/except.c7
-rw-r--r--gcc/cp/init.c27
-rw-r--r--gcc/cp/name-lookup.c20
-rw-r--r--gcc/cp/parser.c21
-rw-r--r--gcc/cp/pt.c2
-rw-r--r--gcc/cp/semantics.c20
8 files changed, 48 insertions, 73 deletions
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 13d9c76..7abcc7e 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -8835,11 +8835,9 @@ add_vcall_offset (tree orig_fn, tree binfo, vtbl_init_data *vid)
offset. */
if (vid->binfo == TYPE_BINFO (vid->derived))
{
- tree_pair_p elt = VEC_safe_push (tree_pair_s, gc,
- CLASSTYPE_VCALL_INDICES (vid->derived),
- NULL);
- elt->purpose = orig_fn;
- elt->value = vid->index;
+ tree_pair_s elt = {orig_fn, vid->index};
+ VEC_safe_push (tree_pair_s, gc, CLASSTYPE_VCALL_INDICES (vid->derived),
+ elt);
}
/* The next vcall offset will be found at a more negative
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index e34092d..1f33bf9 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -2639,16 +2639,16 @@ tree
declare_local_label (tree id)
{
tree decl;
- cp_label_binding *bind;
+ cp_label_binding bind;
/* Add a new entry to the SHADOWED_LABELS list so that when we leave
this scope we can restore the old value of IDENTIFIER_TYPE_VALUE. */
- bind = VEC_safe_push (cp_label_binding, gc,
- current_binding_level->shadowed_labels, NULL);
- bind->prev_value = IDENTIFIER_LABEL_VALUE (id);
+ bind.prev_value = IDENTIFIER_LABEL_VALUE (id);
decl = make_label_decl (id, /*local_p=*/1);
- bind->label = decl;
+ bind.label = decl;
+ VEC_safe_push (cp_label_binding, gc, current_binding_level->shadowed_labels,
+ bind);
return decl;
}
@@ -13782,10 +13782,8 @@ maybe_register_incomplete_var (tree var)
|| (TYPE_LANG_SPECIFIC (inner_type)
&& TYPE_BEING_DEFINED (inner_type)))
{
- incomplete_var *iv
- = VEC_safe_push (incomplete_var, gc, incomplete_vars, NULL);
- iv->decl = var;
- iv->incomplete_type = inner_type;
+ incomplete_var iv = {var, inner_type};
+ VEC_safe_push (incomplete_var, gc, incomplete_vars, iv);
}
}
}
diff --git a/gcc/cp/except.c b/gcc/cp/except.c
index ff967de..da34418 100644
--- a/gcc/cp/except.c
+++ b/gcc/cp/except.c
@@ -1249,11 +1249,8 @@ expr_noexcept_p (tree expr, tsubst_flags_t complain)
if (!DECL_INITIAL (fn))
{
/* Not defined yet; check again at EOF. */
- pending_noexcept *p
- = VEC_safe_push (pending_noexcept, gc,
- pending_noexcept_checks, NULL);
- p->fn = fn;
- p->loc = input_location;
+ pending_noexcept p = {fn, input_location};
+ VEC_safe_push (pending_noexcept, gc, pending_noexcept_checks, p);
}
else
maybe_noexcept_warning (fn);
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index 561477a..23d86d5 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -253,21 +253,21 @@ build_zero_init_1 (tree type, tree nelts, bool static_storage_p,
have an upper bound of -1. */
if (!tree_int_cst_equal (max_index, integer_minus_one_node))
{
- constructor_elt *ce;
+ constructor_elt ce;
v = VEC_alloc (constructor_elt, gc, 1);
- ce = VEC_quick_push (constructor_elt, v, NULL);
/* If this is a one element array, we just use a regular init. */
if (tree_int_cst_equal (size_zero_node, max_index))
- ce->index = size_zero_node;
+ ce.index = size_zero_node;
else
- ce->index = build2 (RANGE_EXPR, sizetype, size_zero_node,
+ ce.index = build2 (RANGE_EXPR, sizetype, size_zero_node,
max_index);
- ce->value = build_zero_init_1 (TREE_TYPE (type),
+ ce.value = build_zero_init_1 (TREE_TYPE (type),
/*nelts=*/NULL_TREE,
static_storage_p, NULL_TREE);
+ VEC_quick_push (constructor_elt, v, ce);
}
/* Build a constructor to contain the initializations. */
@@ -448,28 +448,27 @@ build_value_init_noctor (tree type, tsubst_flags_t complain)
have an upper bound of -1. */
if (!tree_int_cst_equal (max_index, integer_minus_one_node))
{
- constructor_elt *ce;
+ constructor_elt ce;
v = VEC_alloc (constructor_elt, gc, 1);
- ce = VEC_quick_push (constructor_elt, v, NULL);
/* If this is a one element array, we just use a regular init. */
if (tree_int_cst_equal (size_zero_node, max_index))
- ce->index = size_zero_node;
+ ce.index = size_zero_node;
else
- ce->index = build2 (RANGE_EXPR, sizetype, size_zero_node,
- max_index);
+ ce.index = build2 (RANGE_EXPR, sizetype, size_zero_node, max_index);
- ce->value = build_value_init (TREE_TYPE (type), complain);
+ ce.value = build_value_init (TREE_TYPE (type), complain);
+ VEC_quick_push (constructor_elt, v, ce);
- if (ce->value == error_mark_node)
+ if (ce.value == error_mark_node)
return error_mark_node;
/* We shouldn't have gotten here for anything that would need
non-trivial initialization, and gimplify_init_ctor_preeval
would need to be fixed to allow it. */
- gcc_assert (TREE_CODE (ce->value) != TARGET_EXPR
- && TREE_CODE (ce->value) != AGGR_INIT_EXPR);
+ gcc_assert (TREE_CODE (ce.value) != TARGET_EXPR
+ && TREE_CODE (ce.value) != AGGR_INIT_EXPR);
}
/* Build a constructor to contain the initializations. */
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index 9392c01..e4e9827 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -318,13 +318,9 @@ cxx_binding_free (cxx_binding *binding)
static cxx_binding *
new_class_binding (tree name, tree value, tree type, cp_binding_level *scope)
{
- cp_class_binding *cb;
- cxx_binding *binding;
-
- cb = VEC_safe_push (cp_class_binding, gc, scope->class_shadowed, NULL);
-
- cb->identifier = name;
- cb->base = binding = cxx_binding_make (value, type);
+ cp_class_binding cb = {cxx_binding_make (value, type), name};
+ cxx_binding *binding = cb.base;
+ VEC_safe_push (cp_class_binding, gc, scope->class_shadowed, cb);
binding->scope = scope;
return binding;
}
@@ -5884,16 +5880,16 @@ store_binding_p (tree id)
static void
store_binding (tree id, VEC(cxx_saved_binding,gc) **old_bindings)
{
- cxx_saved_binding *saved;
+ cxx_saved_binding saved;
gcc_checking_assert (store_binding_p (id));
IDENTIFIER_MARKED (id) = 1;
- saved = VEC_quick_push (cxx_saved_binding, *old_bindings, NULL);
- saved->identifier = id;
- saved->binding = IDENTIFIER_BINDING (id);
- saved->real_type_value = REAL_IDENTIFIER_TYPE_VALUE (id);
+ saved.identifier = id;
+ saved.binding = IDENTIFIER_BINDING (id);
+ saved.real_type_value = REAL_IDENTIFIER_TYPE_VALUE (id);
+ VEC_quick_push (cxx_saved_binding, *old_bindings, saved);
IDENTIFIER_BINDING (id) = NULL;
}
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 327ad0b..b641e08 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -590,13 +590,13 @@ cp_lexer_new_main (void)
lexer = cp_lexer_alloc ();
/* Put the first token in the buffer. */
- VEC_quick_push (cp_token, lexer->buffer, &token);
+ VEC_quick_push (cp_token, lexer->buffer, token);
/* Get the remaining tokens from the preprocessor. */
while (token.type != CPP_EOF)
{
cp_lexer_get_preprocessor_token (lexer, &token);
- VEC_safe_push (cp_token, gc, lexer->buffer, &token);
+ VEC_safe_push (cp_token, gc, lexer->buffer, token);
}
lexer->last_token = VEC_address (cp_token, lexer->buffer)
@@ -1731,11 +1731,8 @@ cp_parser_context_new (cp_parser_context* next)
static void
push_unparsed_function_queues (cp_parser *parser)
{
- VEC_safe_push (cp_unparsed_functions_entry, gc,
- parser->unparsed_queues, NULL);
- unparsed_funs_with_default_args = NULL;
- unparsed_funs_with_definitions = make_tree_vector ();
- unparsed_nsdmis = NULL;
+ cp_unparsed_functions_entry e = {NULL, make_tree_vector (), NULL};
+ VEC_safe_push (cp_unparsed_functions_entry, gc, parser->unparsed_queues, e);
}
static void
@@ -8028,7 +8025,7 @@ start_lambda_scope (tree decl)
decl = current_function_decl;
ti.t = lambda_scope;
ti.i = lambda_count;
- VEC_safe_push (tree_int, gc, lambda_scope_stack, &ti);
+ VEC_safe_push (tree_int, gc, lambda_scope_stack, ti);
if (lambda_scope != decl)
{
/* Don't reset the count if we're still in the same function. */
@@ -21758,11 +21755,9 @@ cp_parser_save_default_args (cp_parser* parser, tree decl)
probe = TREE_CHAIN (probe))
if (TREE_PURPOSE (probe))
{
- cp_default_arg_entry *entry
- = VEC_safe_push (cp_default_arg_entry, gc,
- unparsed_funs_with_default_args, NULL);
- entry->class_type = current_class_type;
- entry->decl = decl;
+ cp_default_arg_entry entry = {current_class_type, decl};
+ VEC_safe_push (cp_default_arg_entry, gc,
+ unparsed_funs_with_default_args, entry);
break;
}
}
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index a875528..768f141 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -20390,7 +20390,7 @@ append_type_to_template_for_access_check_1 (tree t,
VEC_safe_push (qualified_typedef_usage_t, gc,
TI_TYPEDEFS_NEEDING_ACCESS_CHECKING (ti),
- &typedef_usage);
+ typedef_usage);
}
/* Append TYPE_DECL to the template TEMPL.
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 642e15d..a6cdfb5 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -145,11 +145,8 @@ push_deferring_access_checks (deferring_kind deferring)
deferred_access_no_check++;
else
{
- deferred_access *ptr;
-
- ptr = VEC_safe_push (deferred_access, gc, deferred_access_stack, NULL);
- ptr->deferred_access_checks = NULL;
- ptr->deferring_access_checks_kind = deferring;
+ deferred_access e = {NULL, deferring};
+ VEC_safe_push (deferred_access, gc, deferred_access_stack, e);
}
}
@@ -243,7 +240,7 @@ pop_to_parent_deferring_access_checks (void)
}
/* Insert into parent's checks. */
VEC_safe_push (deferred_access_check, gc,
- ptr->deferred_access_checks, chk);
+ ptr->deferred_access_checks, *chk);
found:;
}
}
@@ -311,7 +308,6 @@ perform_or_defer_access_check (tree binfo, tree decl, tree diag_decl,
int i;
deferred_access *ptr;
deferred_access_check *chk;
- deferred_access_check *new_access;
/* Exit if we are in a context that no access checking is performed.
@@ -341,13 +337,9 @@ perform_or_defer_access_check (tree binfo, tree decl, tree diag_decl,
}
}
/* If not, record the check. */
- new_access =
- VEC_safe_push (deferred_access_check, gc,
- ptr->deferred_access_checks, 0);
- new_access->binfo = binfo;
- new_access->decl = decl;
- new_access->diag_decl = diag_decl;
- new_access->loc = input_location;
+ deferred_access_check new_access = {binfo, decl, diag_decl, input_location};
+ VEC_safe_push (deferred_access_check, gc, ptr->deferred_access_checks,
+ new_access);
return true;
}