aboutsummaryrefslogtreecommitdiff
path: root/gcc/c
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/c
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/c')
-rw-r--r--gcc/c/c-decl.c8
-rw-r--r--gcc/c/c-tree.h4
-rw-r--r--gcc/c/c-typeck.c6
3 files changed, 8 insertions, 10 deletions
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index e5d17b7..d4c7b1f 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -6437,7 +6437,7 @@ get_parm_info (bool ellipsis, tree expr)
{
tree decl = b->decl;
tree type = TREE_TYPE (decl);
- c_arg_tag *tag;
+ c_arg_tag tag;
const char *keyword;
switch (TREE_CODE (decl))
@@ -6511,9 +6511,9 @@ get_parm_info (bool ellipsis, tree expr)
}
}
- tag = VEC_safe_push (c_arg_tag, gc, tags, NULL);
- tag->id = b->id;
- tag->type = decl;
+ tag.id = b->id;
+ tag.type = decl;
+ VEC_safe_push (c_arg_tag, gc, tags, tag);
break;
case CONST_DECL:
diff --git a/gcc/c/c-tree.h b/gcc/c/c-tree.h
index c07d994..17fc719 100644
--- a/gcc/c/c-tree.h
+++ b/gcc/c/c-tree.h
@@ -142,8 +142,8 @@ DEF_VEC_ALLOC_O (c_expr_t, heap);
/* Append a new c_expr_t element to V. */
#define C_EXPR_APPEND(V, ELEM) \
do { \
- c_expr_t *__elem_p = VEC_safe_push (c_expr_t, gc, V, NULL); \
- *__elem_p = (ELEM); \
+ c_expr_t __elem = (ELEM); \
+ VEC_safe_push (c_expr_t, gc, V, __elem); \
} while (0)
/* A kind of type specifier. Note that this information is currently
diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index 99920ef..b5fb9c9 100644
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -7709,7 +7709,6 @@ output_init_element (tree value, tree origtype, bool strict_string, tree type,
struct obstack * braced_init_obstack)
{
tree semantic_type = NULL_TREE;
- constructor_elt *celt;
bool maybe_const = true;
bool npc;
@@ -7876,9 +7875,8 @@ output_init_element (tree value, tree origtype, bool strict_string, tree type,
/* Otherwise, output this element either to
constructor_elements or to the assembler file. */
- celt = VEC_safe_push (constructor_elt, gc, constructor_elements, NULL);
- celt->index = field;
- celt->value = value;
+ constructor_elt celt = {field, value};
+ VEC_safe_push (constructor_elt, gc, constructor_elements, celt);
/* Advance the variable that indicates sequential elements output. */
if (TREE_CODE (constructor_type) == ARRAY_TYPE)