This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[pph] Use FOR_EACH_VEC_ELT consistently (issue4673057)
- From: dnovillo at google dot com (Diego Novillo)
- To: reply at codereview dot appspotmail dot com, crowl at google dot com, gchare at google dot com, gcc-patches at gcc dot gnu dot org
- Date: Mon, 11 Jul 2011 17:44:09 -0400 (EDT)
- Subject: [pph] Use FOR_EACH_VEC_ELT consistently (issue4673057)
No functional changes. Just tidying calls to VEC_iterate.
Tested on x86_64. Committed to branch.
Diego.
* pph-streamer-in.c (pph_in_scope_chain): Replace VEC_iterate
loops with FOR_EACH_VEC_ELT.
(pph_read_file_contents): Likewise.
* pph-streamer-out.c (pph_out_tree_vec): Likewise.
(pph_out_qual_use_vec): Likewise.
(pph_out_binding_level): Likewise.
(pph_out_tree_pair_vec): Likewise.
* pph-streamer.h (pph_out_tree_VEC): Likewise.
diff --git a/gcc/cp/ChangeLog.pph b/gcc/cp/ChangeLog.pph
index f18c2f4..46794d0 100644
--- a/gcc/cp/ChangeLog.pph
+++ b/gcc/cp/ChangeLog.pph
@@ -1,4 +1,15 @@
2011-07-11 Diego Novillo <dnovillo@google.com>
+
+ * pph-streamer-in.c (pph_in_scope_chain): Replace VEC_iterate
+ loops with FOR_EACH_VEC_ELT.
+ (pph_read_file_contents): Likewise.
+ * pph-streamer-out.c (pph_out_tree_vec): Likewise.
+ (pph_out_qual_use_vec): Likewise.
+ (pph_out_binding_level): Likewise.
+ (pph_out_tree_pair_vec): Likewise.
+ * pph-streamer.h (pph_out_tree_VEC): Likewise.
+
+2011-07-11 Diego Novillo <dnovillo@google.com>
Gabriel Charette <gchare@google.com>
* pph-streamer-in.c (ALLOC_AND_REGISTER_ALTERNATE): Define.
diff --git a/gcc/cp/pph-streamer-in.c b/gcc/cp/pph-streamer-in.c
index 903cd94..b40c384 100644
--- a/gcc/cp/pph-streamer-in.c
+++ b/gcc/cp/pph-streamer-in.c
@@ -1227,22 +1227,18 @@ pph_in_scope_chain (pph_stream *stream)
chainon (cur_bindings->names, new_bindings->names);
chainon (cur_bindings->namespaces, new_bindings->namespaces);
- for (i = 0; VEC_iterate (tree, new_bindings->static_decls, i, decl); i++)
+ FOR_EACH_VEC_ELT (tree, new_bindings->static_decls, i, decl)
VEC_safe_push (tree, gc, cur_bindings->static_decls, decl);
chainon (cur_bindings->usings, new_bindings->usings);
chainon (cur_bindings->using_directives, new_bindings->using_directives);
- for (i = 0;
- VEC_iterate (cp_class_binding, new_bindings->class_shadowed, i, cb);
- i++)
+ FOR_EACH_VEC_ELT (cp_class_binding, new_bindings->class_shadowed, i, cb)
VEC_safe_push (cp_class_binding, gc, cur_bindings->class_shadowed, cb);
chainon (cur_bindings->type_shadowed, new_bindings->type_shadowed);
- for (i = 0;
- VEC_iterate (cp_label_binding, new_bindings->shadowed_labels, i, lb);
- i++)
+ FOR_EACH_VEC_ELT (cp_label_binding, new_bindings->shadowed_labels, i, lb)
VEC_safe_push (cp_label_binding, gc, cur_bindings->shadowed_labels, lb);
chainon (cur_bindings->blocks, new_bindings->blocks);
@@ -1412,14 +1408,14 @@ pph_read_file_contents (pph_stream *stream)
keyed_classes = chainon (file_keyed_classes, keyed_classes);
file_unemitted_tinfo_decls = pph_in_tree_vec (stream);
- for (i = 0; VEC_iterate (tree, file_unemitted_tinfo_decls, i, t); i++)
+ FOR_EACH_VEC_ELT (tree, file_unemitted_tinfo_decls, i, t)
VEC_safe_push (tree, gc, unemitted_tinfo_decls, t);
file_static_aggregates = pph_in_tree (stream);
static_aggregates = chainon (file_static_aggregates, static_aggregates);
/* Expand all the functions with bodies that we read from STREAM. */
- for (i = 0; VEC_iterate (tree, stream->fns_to_expand, i, fndecl); i++)
+ FOR_EACH_VEC_ELT (tree, stream->fns_to_expand, i, fndecl)
{
/* FIXME pph - This is somewhat gross. When we generated the
PPH image, the parser called expand_or_defer_fn on FNDECL,
diff --git a/gcc/cp/pph-streamer-out.c b/gcc/cp/pph-streamer-out.c
index 089bb13..f7bf739 100644
--- a/gcc/cp/pph-streamer-out.c
+++ b/gcc/cp/pph-streamer-out.c
@@ -483,7 +483,7 @@ pph_out_tree_vec (pph_stream *stream, VEC(tree,gc) *v, bool ref_p)
tree t;
pph_out_uint (stream, VEC_length (tree, v));
- for (i = 0; VEC_iterate (tree, v, i, t); i++)
+ FOR_EACH_VEC_ELT (tree, v, i, t)
pph_out_tree_or_ref (stream, t, ref_p);
}
@@ -499,7 +499,7 @@ pph_out_qual_use_vec (pph_stream *stream,
qualified_typedef_usage_t *q;
pph_out_uint (stream, VEC_length (qualified_typedef_usage_t, v));
- for (i = 0; VEC_iterate (qualified_typedef_usage_t, v, i, q); i++)
+ FOR_EACH_VEC_ELT (qualified_typedef_usage_t, v, i, q)
{
pph_out_tree_or_ref (stream, q->typedef_decl, ref_p);
pph_out_tree_or_ref (stream, q->context, ref_p);
@@ -657,13 +657,13 @@ pph_out_binding_level (pph_stream *stream, struct cp_binding_level *bl,
pph_out_chain_filtered (stream, bl->using_directives, ref_p, NO_BUILTINS);
pph_out_uint (stream, VEC_length (cp_class_binding, bl->class_shadowed));
- for (i = 0; VEC_iterate (cp_class_binding, bl->class_shadowed, i, cs); i++)
+ FOR_EACH_VEC_ELT (cp_class_binding, bl->class_shadowed, i, cs)
pph_out_class_binding (stream, cs, ref_p);
pph_out_tree_or_ref (stream, bl->type_shadowed, ref_p);
pph_out_uint (stream, VEC_length (cp_label_binding, bl->shadowed_labels));
- for (i = 0; VEC_iterate (cp_label_binding, bl->shadowed_labels, i, sl); i++)
+ FOR_EACH_VEC_ELT (cp_label_binding, bl->shadowed_labels, i, sl)
pph_out_label_binding (stream, sl, ref_p);
pph_out_chain (stream, bl->blocks, ref_p);
@@ -975,7 +975,7 @@ pph_out_tree_pair_vec (pph_stream *stream, VEC(tree_pair_s,gc) *v,
tree_pair_s *p;
pph_out_uint (stream, VEC_length (tree_pair_s, v));
- for (i = 0; VEC_iterate (tree_pair_s, v, i, p); i++)
+ FOR_EACH_VEC_ELT (tree_pair_s, v, i, p)
{
pph_out_tree_or_ref (stream, p->purpose, ref_p);
pph_out_tree_or_ref (stream, p->value, ref_p);
diff --git a/gcc/cp/pph-streamer.h b/gcc/cp/pph-streamer.h
index 8d0c024..2fe4266 100644
--- a/gcc/cp/pph-streamer.h
+++ b/gcc/cp/pph-streamer.h
@@ -267,7 +267,7 @@ pph_out_tree_VEC (pph_stream *stream, VEC(tree,gc) *v, bool ref_p)
size_t i;
size_t c = VEC_length (tree, v);
pph_out_uint (stream, c);
- for (i = 0; VEC_iterate (tree, v, i, t); i++)
+ FOR_EACH_VEC_ELT (tree, v, i, t)
{
if (flag_pph_tracer >= 1)
pph_trace_tree (stream, t, ref_p);
--
This patch is available for review at http://codereview.appspot.com/4673057