diff options
author | Diego Novillo <dnovillo@google.com> | 2012-11-17 21:54:30 -0500 |
---|---|---|
committer | Diego Novillo <dnovillo@gcc.gnu.org> | 2012-11-17 21:54:30 -0500 |
commit | 9771b26396c39dfaecd5a76dd359fb65d3be4cb6 (patch) | |
tree | 1b9f930d315fa3e0a5ed7fa6e27ec5bd0a3436a4 /gcc/cp/class.c | |
parent | 0f4119158064e271e48a14ce3f88a67e7baf14e0 (diff) | |
download | gcc-9771b26396c39dfaecd5a76dd359fb65d3be4cb6.zip gcc-9771b26396c39dfaecd5a76dd359fb65d3be4cb6.tar.gz gcc-9771b26396c39dfaecd5a76dd359fb65d3be4cb6.tar.bz2 |
This patch rewrites the old VEC macro-based interface into a new one based on the template class 'vec'.
This patch rewrites the old VEC macro-based interface into a new one
based on the template class 'vec'. The user-visible changes are
described in http://gcc.gnu.org/wiki/cxx-conversion/cxx-vec.
I have tested the patch pretty extensively:
- Regular bootstraps on x86_64, ppc, ia64, sparc and hppa.
- Bootstraps with --enable-checking=release
- Bootstraps with --enable-checking=gc,gcac
- Basic builds on all targets (using contrib/config-list.mk).
We no longer access the vectors via VEC_* macros. The pattern is
"VEC_operation (T, A, V, args)" becomes "V.operation (args)".
The only thing I could not do is create proper ctors and dtors for the
vec class. Since these vectors are stored in unions, we
have to keep them as PODs (C++03 does not allow non-PODs in unions).
This means that creation and destruction must be explicit. There is a
new method vec<type, allocation, layout>::create() and another vec<type,
allocation, layout>::destroy() to allocate the internal vector.
For vectors that must be pointers, there is a family of free functions
that implement the operations that need to tolerate NULL vectors.
These functions all start with the prefix 'vec_safe_'. See the wiki
page for details.
The gengtype change removes the special handling for VEC() that used
to exist in gengtype. Additionally, it allows gengtype to recognize
templates of more than one argument and introduces the concept of an
undefined type (useful for template arguments that may or may not be
types).
When a TYPE_UNDEFINED is reached, gengtype will ignore it if it
happens inside a type marked with GTY((user)). Otherwise, it will
emit an error.
Finally, gengtype rejects root types marked GTY((user)) that are not
first class pointers.
2012-11-16 Diego Novillo <dnovillo@google.com>
VEC API overhaul (http://gcc.gnu.org/wiki/cxx-conversion/cxx-vec)
* vec.c (register_overhead): Convert it into
member function of vec_prefix.
(release_overhead): Likewise.
(calculate_allocation): Likewise.
(vec_heap_free): Remove.
(vec_gc_o_reserve_1): Remove.
(vec_heap_o_reserve_1): Remove.
(vec_stack_o_reserve_1): Remove.
(vec_stack_o_reserve_exact): Remove.
(register_stack_vec): New.
(stack_vec_register_index): New.
(unregister_stack_vec): New.
(vec_assert_fail): Remove.
* vec.h: Conditionally include ggc.h. Document conditional
hackery.
Update top-level documentation.
(ALONE_VEC_CHECK_INFO): Remove.
(VEC_CHECK_INFO): Remove.
(ALONE_VEC_CHECK_DECL): Remove.
(VEC_CHECK_DECL): Remove.
(ALONE_VEC_CHECK_PASS): Remove.
(VEC_CHECK_PASS): Remove.
(VEC_ASSERT): Remove.
(vec_prefix): Add friends va_gc, va_gc_atomic, va_heap and
va_stack.
Mark fields alloc_ and num_ as protected.
(struct vec_t): Remove. Remove all function members.
(struct vl_embed): Declare.
(struct vl_ptr): Declare.
(free): Remove.
(reserve_exact): Remove.
(reserve): Remove.
(safe_splice): Remove.
(safe_push): Remove.
(safe_grow): Remove.
(safe_grow_cleared): Remove.
(safe_insert): Remove.
(DEF_VEC_I): Remove.
(DEF_VEC_ALLOC_I): Remove.
(DEF_VEC_P): Remove.
(DEF_VEC_ALLOC_P): Remove.
(DEF_VEC_O): Remove.
(DEF_VEC_ALLOC_O): Remove.
(DEF_VEC_ALLOC_P_STACK): Remove.
(DEF_VEC_ALLOC_O_STACK): Remove.
(DEF_VEC_ALLOC_I_STACK): Remove.
(DEF_VEC_A): Remove.
(DEF_VEC_ALLOC_A): Remove.
(vec_stack_p_reserve_exact_1): Remove.
(vec_stack_o_reserve): Remove.
(vec_stack_o_reserve_exact): Remove.
(VEC_length): Remove.
(VEC_empty): Remove.
(VEC_address): Remove.
(vec_address): Remove.
(VEC_last): Remove.
(VEC_index): Remove.
(VEC_iterate): Remove.
(VEC_embedded_size): Remove.
(VEC_embedded_init): Remove.
(VEC_free): Remove.
(VEC_copy): Remove.
(VEC_space): Remove.
(VEC_reserve): Remove.
(VEC_reserve_exact): Remove.
(VEC_splice): Remove.
(VEC_safe_splice): Remove.
(VEC_quick_push): Remove.
(VEC_safe_push): Remove.
(VEC_pop): Remove.
(VEC_truncate): Remove.
(VEC_safe_grow): Remove.
(VEC_replace): Remove.
(VEC_quick_insert): Remove.
(VEC_safe_insert): Remove.
(VEC_ordered_remove): Remove.
(VEC_unordered_remove): Remove.
(VEC_block_remove): Remove.
(VEC_lower_bound): Remove.
(VEC_alloc): Remove.
(VEC_qsort): Remove.
(va_heap): Declare.
(va_heap::default_layout): New typedef to vl_ptr.
(va_heap::reserve): New.
(va_heap::release): New.
(va_gc): Declare.
(va_gc::default_layout): New typedef to vl_embed.
(va_gc::reserve): New.
(va_gc::release): New.
(va_gc_atomic): Declare. Inherit from va_gc.
(va_stack): Declare.
(va_stack::default_layout): New typedef to vl_ptr.
(va_stack::alloc): New.
(va_stack::reserve): New.
(va_stack::release): New.
(register_stack_vec): Declare.
(stack_vec_register_index): Declare.
(unregister_stack_vec): Declare.
(vec<T, A = va_heap, L = typename A::default_layout>): Declare
empty vec template.
(vec<T, A, vl_embed>): Partial specialization for embedded
layout.
(vec<T, A, vl_embed>::allocated): New.
(vec<T, A, vl_embed>::length): New.
(vec<T, A, vl_embed>::is_empty): New.
(vec<T, A, vl_embed>::address): New.
(vec<T, A, vl_embed>::operator[]): New.
(vec<T, A, vl_embed>::last New.
(vec<T, A, vl_embed>::space): New.
(vec<T, A, vl_embed>::iterate): New.
(vec<T, A, vl_embed>::iterate): New.
(vec<T, A, vl_embed>::copy): New.
(vec<T, A, vl_embed>::splice): New.
(vec<T, A, vl_embed>::quick_push New.
(vec<T, A, vl_embed>::pop New.
(vec<T, A, vl_embed>::truncate): New.
(vec<T, A, vl_embed>::quick_insert): New.
(vec<T, A, vl_embed>::ordered_remove): New.
(vec<T, A, vl_embed>::unordered_remove): New.
(vec<T, A, vl_embed>::block_remove): New.
(vec<T, A, vl_embed>::qsort): New.
(vec<T, A, vl_embed>::lower_bound): New.
(vec<T, A, vl_embed>::embedded_size): New.
(vec<T, A, vl_embed>::embedded_init): New.
(vec<T, A, vl_embed>::quick_grow): New.
(vec<T, A, vl_embed>::quick_grow_cleared): New.
(vec_safe_space): New.
(vec_safe_length): New.
(vec_safe_address): New.
(vec_safe_is_empty): New.
(vec_safe_reserve): New.
(vec_safe_reserve_exact): New.
(vec_alloc): New.
(vec_free): New.
(vec_safe_grow): New.
(vec_safe_grow_cleared): New.
(vec_safe_iterate): New.
(vec_safe_push): New.
(vec_safe_insert): New.
(vec_safe_truncate): New.
(vec_safe_copy): New.
(vec_safe_splice): New.
(vec<T, A, vl_ptr>): New partial specialization for the space
efficient layout.
(vec<T, A, vl_ptr>::exists): New.
(vec<T, A, vl_ptr>::is_empty): New.
(vec<T, A, vl_ptr>::length): New.
(vec<T, A, vl_ptr>::address): New.
(vec<T, A, vl_ptr>::operator[]): New.
(vec<T, A, vl_ptr>::operator!=): New.
(vec<T, A, vl_ptr>::operator==): New.
(vec<T, A, vl_ptr>::last): New.
(vec<T, A, vl_ptr>::space): New.
(vec<T, A, vl_ptr>::iterate): New.
(vec<T, A, vl_ptr>::copy): New.
(vec<T, A, vl_ptr>::reserve): New.
(vec<T, A, vl_ptr>::reserve_exact): New.
(vec<T, A, vl_ptr>::splice): New.
(vec<T, A, vl_ptr>::safe_splice): New.
(vec<T, A, vl_ptr>::quick_push): New.
(vec<T, A, vl_ptr>::safe_push): New.
(vec<T, A, vl_ptr>::pop): New.
(vec<T, A, vl_ptr>::truncate): New.
(vec<T, A, vl_ptr>::safe_grow): New.
(vec<T, A, vl_ptr>::safe_grow_cleared): New.
(vec<T, A, vl_ptr>::quick_grow): New.
(vec<T, A, vl_ptr>::quick_grow_cleared): New.
(vec<T, A, vl_ptr>::quick_insert): New.
(vec<T, A, vl_ptr>::safe_insert): New.
(vec<T, A, vl_ptr>::ordered_remove): New.
(vec<T, A, vl_ptr>::unordered_remove): New.
(vec<T, A, vl_ptr>::block_remove): New.
(vec<T, A, vl_ptr>::qsort): New.
(vec<T, A, vl_ptr>::lower_bound): New.
(vec_stack_alloc): Define.
(FOR_EACH_VEC_SAFE_ELT): Define.
* vecir.h: Remove. Update all users.
* vecprim.h: Remove. Update all users.
Move uchar to coretypes.h.
* Makefile.in (VEC_H): Add $(GGC_H).
Remove vecir.h and vecprim.h dependencies everywhere.
2012-11-16 Diego Novillo <dnovillo@google.com>
* gengtype-lex.l (VEC): Remove.
Add characters in the set [\!\>\.-].
* gengtype-parse.c (token_names): Remove "VEC".
(require_template_declaration): Remove handling of VEC_TOKEN.
(type): Likewise.
Call create_user_defined_type when parsing GTY((user)).
* gengtype-state.c (type_lineloc): handle TYPE_UNDEFINED.
(write_state_undefined_type): New.
(write_state_type): Call write_state_undefined_type for
TYPE_UNDEFINED.
(read_state_type): Call read_state_undefined_type for
TYPE_UNDEFINED.
* gengtype.c (dbgprint_count_type_at): Handle TYPE_UNDEFINED.
(create_user_defined_type): Make extern.
(type_for_name): Factor out of resolve_typedef.
(create_undefined_type): New
(resolve_typedef): Call it when we cannot find a previous
typedef and the type is not a template.
(find_structure): Accept TYPE_UNDEFINED.
(set_gc_used_type): Add argument ALLOWED_UNDEFINED_TYPES,
default to false.
Emit an error for TYPE_UNDEFINED unless LEVEL is GC_UNUSED or
ALLOWED_UNDEFINED_TYPES is set.
Set ALLOWED_UNDEFINED_TYPES to true for TYPE_USER_STRUCT.
(filter_type_name): Accept templates with more than one
argument.
(output_mangled_typename): Handle TYPE_UNDEFINED
(walk_type): Likewise.
(write_types_process_field): Likewise.
(write_func_for_structure): If CHAIN_NEXT is set, ORIG_S
should not be a user-defined type.
(write_types_local_user_process_field): Handle TYPE_ARRAY,
TYPE_NONE and TYPE_UNDEFINED.
(write_types_local_process_field): Likewise.
(contains_scalar_p): Return 0 for TYPE_USER_STRUCT.
(write_root): Reject user-defined types that are not pointers.
Handle TYPE_NONE, TYPE_UNDEFINED, TYPE_UNION, TYPE_LANG_STRUCT
and TYPE_PARAM_STRUCT.
(output_typename): Handle TYPE_NONE, TYPE_UNDEFINED, and
TYPE_ARRAY.
(dump_typekind): Handle TYPE_UNDEFINED.
* gengtype.h (enum typekind): Add TYPE_UNDEFINED.
(create_user_defined_type): Declare.
(enum gty_token): Remove VEC_TOKEN.
2012-11-16 Diego Novillo <dnovillo@google.com>
Adjust for new vec API (http://gcc.gnu.org/wiki/cxx-conversion/cxx-vec)
* coretypes.h (uchar): Define.
* alias.c: Use new vec API in vec.h.
* asan.c: Likewise.
* attribs.c: Likewise.
* basic-block.h: Likewise.
* bb-reorder.c: Likewise.
* builtins.c: Likewise.
* calls.c: Likewise.
* cfg.c: Likewise.
* cfganal.c: Likewise.
* cfgcleanup.c: Likewise.
* cfgexpand.c: Likewise.
* cfghooks.c: Likewise.
* cfghooks.h: Likewise.
* cfgloop.c: Likewise.
* cfgloop.h: Likewise.
* cfgloopanal.c: Likewise.
* cfgloopmanip.c: Likewise.
* cfgrtl.c: Likewise.
* cgraph.c: Likewise.
* cgraph.h: Likewise.
* cgraphclones.c: Likewise.
* cgraphunit.c: Likewise.
* combine.c: Likewise.
* compare-elim.c: Likewise.
* coverage.c: Likewise.
* cprop.c: Likewise.
* data-streamer.h: Likewise.
* dbxout.c: Likewise.
* dce.c: Likewise.
* df-core.c: Likewise.
* df-problems.c: Likewise.
* df-scan.c: Likewise.
* dominance.c: Likewise.
* domwalk.c: Likewise.
* domwalk.h: Likewise.
* dse.c: Likewise.
* dwarf2cfi.c: Likewise.
* dwarf2out.c: Likewise.
* dwarf2out.h: Likewise.
* emit-rtl.c: Likewise.
* except.c: Likewise.
* except.h: Likewise.
* expr.c: Likewise.
* expr.h: Likewise.
* final.c: Likewise.
* fold-const.c: Likewise.
* function.c: Likewise.
* function.h: Likewise.
* fwprop.c: Likewise.
* gcc.c: Likewise.
* gcse.c: Likewise.
* genattr.c: Likewise.
* genattrtab.c: Likewise.
* genautomata.c: Likewise.
* genextract.c: Likewise.
* genopinit.c: Likewise
* ggc-common.c: Likewise.
* ggc.h: Likewise.
* gimple-low.c: Likewise.
* gimple-ssa-strength-reduction.c: Likewise.
* gimple-streamer-in.c: Likewise.
* gimple.c: Likewise.
* gimple.h: Likewise.
* gimplify.c: Likewise.
* graph.c: Likewise.
* graphds.c: Likewise.
* graphds.h: Likewise.
* graphite-blocking.c: Likewise.
* graphite-clast-to-gimple.c: Likewise.
* graphite-dependences.c: Likewise.
* graphite-interchange.c: Likewise.
* graphite-optimize-isl.c: Likewise.
* graphite-poly.c: Likewise.
* graphite-poly.h: Likewise.
* graphite-scop-detection.c: Likewise.
* graphite-scop-detection.h: Likewise.
* graphite-sese-to-poly.c: Likewise.
* graphite.c: Likewise.
* godump.c: Likewise.
* haifa-sched.c: Likewise.
* hw-doloop.c: Likewise.
* hw-doloop.h: Likewise.
* ifcvt.c: Likewise.
* insn-addr.h: Likewise.
* ipa-cp.c: Likewise.
* ipa-inline-analysis.c: Likewise.
* ipa-inline-transform.c: Likewise.
* ipa-inline.c: Likewise.
* ipa-inline.h: Likewise.
* ipa-prop.c: Likewise.
* ipa-prop.h: Likewise.
* ipa-pure-const.c: Likewise.
* ipa-ref-inline.h: Likewise.
* ipa-ref.c: Likewise.
* ipa-ref.h: Likewise.
* ipa-reference.c: Likewise.
* ipa-split.c: Likewise.
* ipa-utils.c: Likewise.
* ipa-utils.h: Likewise.
* ipa.c: Likewise.
* ira-build.c: Likewise.
* ira-color.c: Likewise.
* ira-emit.c: Likewise.
* ira-int.h: Likewise.
* ira.c: Likewise.
* loop-invariant.c: Likewise.
* loop-unroll.c: Likewise.
* lower-subreg.c: Likewise.
* lra-lives.c: Likewise.
* lra.c: Likewise.
* lto-cgraph.c: Likewise.
* lto-section-out.c: Likewise.
* lto-streamer-in.c: Likewise.
* lto-streamer-out.c: Likewise.
* lto-streamer.h: Likewise.
* lto-symtab.c: Likewise.
* mcf.c: Likewise.
* modulo-sched.c: Likewise.
* omp-low.c: Likewise.
* opts-common.c: Likewise.
* opts-global.c: Likewise.
* opts.c: Likewise.
* opts.h: Likewise.
* passes.c: Likewise.
* predict.c: Likewise.
* print-tree.c: Likewise.
* profile.c: Likewise.
* profile.h: Likewise.
* read-rtl.c: Likewise.
* ree.c: Likewise.
* reg-stack.c: Likewise.
* regrename.c: Likewise.
* regrename.h: Likewise.
* reload.c: Likewise.
* reload.h: Likewise.
* reload1.c: Likewise.
* rtl.h: Likewise.
* sched-deps.c: Likewise.
* sched-int.h: Likewise.
* sdbout.c: Likewise.
* sel-sched-dump.c: Likewise.
* sel-sched-ir.c: Likewise.
* sel-sched-ir.h: Likewise.
* sel-sched.c: Likewise.
* sese.c: Likewise.
* sese.h: Likewise.
* statistics.h: Likewise.
* stmt.c: Likewise.
* stor-layout.c: Likewise.
* store-motion.c: Likewise.
* tlink.c: Likewise.
* toplev.c: Likewise.
* trans-mem.c: Likewise.
* tree-browser.c: Likewise.
* tree-call-cdce.c: Likewise.
* tree-cfg.c: Likewise.
* tree-cfgcleanup.c: Likewise.
* tree-chrec.c: Likewise.
* tree-chrec.h: Likewise.
* tree-complex.c: Likewise.
* tree-data-ref.c: Likewise.
* tree-data-ref.h: Likewise.
* tree-dfa.c: Likewise.
* tree-diagnostic.c: Likewise.
* tree-dump.c: Likewise.
* tree-eh.c: Likewise.
* tree-emutls.c: Likewise.
* tree-flow.h: Likewise.
* tree-if-conv.c: Likewise.
* tree-inline.c: Likewise.
* tree-inline.h: Likewise.
* tree-into-ssa.c: Likewise.
* tree-iterator.c: Likewise.
* tree-loop-distribution.c: Likewise.
* tree-mudflap.c: Likewise.
* tree-optimize.c: Likewise.
* tree-outof-ssa.c: Likewise.
* tree-parloops.c: Likewise.
* tree-phinodes.c: Likewise.
* tree-predcom.c: Likewise.
* tree-pretty-print.c: Likewise.
* tree-scalar-evolution.c: Likewise.
* tree-sra.c: Likewise.
* tree-ssa-address.c: Likewise.
* tree-ssa-alias.c: Likewise.
* tree-ssa-ccp.c: Likewise.
* tree-ssa-coalesce.c: Likewise.
* tree-ssa-dce.c: Likewise.
* tree-ssa-dom.c: Likewise.
* tree-ssa-forwprop.c: Likewise.
* tree-ssa-live.c: Likewise.
* tree-ssa-live.h: Likewise.
* tree-ssa-loop-im.c: Likewise.
* tree-ssa-loop-ivcanon.c: Likewise.
* tree-ssa-loop-ivopts.c: Likewise.
* tree-ssa-loop-manip.c: Likewise.
* tree-ssa-loop-niter.c: Likewise.
* tree-ssa-loop-prefetch.c: Likewise.
* tree-ssa-math-opts.c: Likewise.
* tree-ssa-operands.c: Likewise.
* tree-ssa-phiopt.c: Likewise.
* tree-ssa-phiprop.c: Likewise.
* tree-ssa-pre.c: Likewise.
* tree-ssa-propagate.c: Likewise.
* tree-ssa-reassoc.c: Likewise.
* tree-ssa-sccvn.c: Likewise.
* tree-ssa-sccvn.h: Likewise.
* tree-ssa-strlen.c: Likewise.
* tree-ssa-structalias.c: Likewise.
* tree-ssa-tail-merge.c: Likewise.
* tree-ssa-threadedge.c: Likewise.
* tree-ssa-threadupdate.c: Likewise.
* tree-ssa-uncprop.c: Likewise.
* tree-ssa-uninit.c: Likewise.
* tree-ssa.c: Likewise.
* tree-ssanames.c: Likewise.
* tree-stdarg.c: Likewise.
* tree-streamer-in.c: Likewise.
* tree-streamer-out.c: Likewise.
* tree-streamer.c: Likewise.
* tree-streamer.h: Likewise.
* tree-switch-conversion.c: Likewise.
* tree-vect-data-refs.c: Likewise.
* tree-vect-generic.c: Likewise.
* tree-vect-loop-manip.c: Likewise.
* tree-vect-loop.c: Likewise.
* tree-vect-patterns.c: Likewise.
* tree-vect-slp.c: Likewise.
* tree-vect-stmts.c: Likewise.
* tree-vectorizer.c: Likewise.
* tree-vectorizer.h: Likewise.
* tree-vrp.c: Likewise.
* tree.c: Likewise.
* tree.h: Likewise.
* value-prof.c: Likewise.
* value-prof.h: Likewise.
* var-tracking.c: Likewise.
* varasm.c: Likewise.
* varpool.c: Likewise.
* vmsdbgout.c: Likewise.
* config/bfin/bfin.c: Likewise.
* config/c6x/c6x.c: Likewise.
* config/darwin.c: Likewise.
* config/i386/i386.c: Likewise.
* config/ia64/ia64.c: Likewise.
* config/mep/mep.c: Likewise.
* config/mips/mips.c: Likewise.
* config/pa/pa.c: Likewise.
* config/rs6000/rs6000-c.c: Likewise.
* config/rs6000/rs6000.c: Likewise.
* config/rx/rx.c: Likewise.
* config/spu/spu-c.c: Likewise.
* config/vms/vms.c: Likewise.
* config/vxworks.c: Likewise.
* config/epiphany/resolve-sw-modes.c: Likewise.
From-SVN: r193595
Diffstat (limited to 'gcc/cp/class.c')
-rw-r--r-- | gcc/cp/class.c | 173 |
1 files changed, 85 insertions, 88 deletions
diff --git a/gcc/cp/class.c b/gcc/cp/class.c index cdc02ae..56fe1d1 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -79,13 +79,13 @@ typedef struct vtbl_init_data_s tree rtti_binfo; /* The negative-index vtable initializers built up so far. These are in order from least negative index to most negative index. */ - VEC(constructor_elt,gc) *inits; + vec<constructor_elt, va_gc> *inits; /* The binfo for the virtual base for which we're building vcall offset initializers. */ tree vbase; /* The functions in vbase for which we have already provided vcall offsets. */ - VEC(tree,gc) *fns; + vec<tree, va_gc> *fns; /* The vtable index of the next vcall or vbase offset. */ tree index; /* Nonzero if we are building the initializer for the primary @@ -112,7 +112,7 @@ static GTY (()) tree sizeof_biggest_empty_class; /* An array of all local classes present in this translation unit, in declaration order. */ -VEC(tree,gc) *local_classes; +vec<tree, va_gc> *local_classes; static tree get_vfield_name (tree); static void finish_struct_anon (tree); @@ -137,7 +137,7 @@ static tree fixed_type_or_null (tree, int *, int *); static tree build_simple_base_path (tree expr, tree binfo); static tree build_vtbl_ref_1 (tree, tree); static void build_vtbl_initializer (tree, tree, tree, tree, int *, - VEC(constructor_elt,gc) **); + vec<constructor_elt, va_gc> **); static int count_fields (tree); static int add_fields_to_record_type (tree, struct sorted_fields_type*, int); static void insert_into_classtype_sorted_fields (tree, tree, int); @@ -175,15 +175,15 @@ static void dump_vtable (tree, tree, tree); static void dump_vtt (tree, tree); static void dump_thunk (FILE *, int, tree); static tree build_vtable (tree, tree, tree); -static void initialize_vtable (tree, VEC(constructor_elt,gc) *); +static void initialize_vtable (tree, vec<constructor_elt, va_gc> *); static void layout_nonempty_base_or_field (record_layout_info, tree, tree, splay_tree); static tree end_of_class (tree, int); static bool layout_empty_base (record_layout_info, tree, tree, splay_tree); static void accumulate_vtbl_inits (tree, tree, tree, tree, tree, - VEC(constructor_elt,gc) **); + vec<constructor_elt, va_gc> **); static void dfs_accumulate_vtbl_inits (tree, tree, tree, tree, tree, - VEC(constructor_elt,gc) **); + vec<constructor_elt, va_gc> **); static void build_rtti_vtbl_entries (tree, vtbl_init_data *); static void build_vcall_and_vbase_vtbl_entries (tree, vtbl_init_data *); static void clone_constructors_and_destructors (tree); @@ -192,7 +192,8 @@ static void update_vtable_entry_for_fn (tree, tree, tree, tree *, unsigned); static void build_ctor_vtbl_group (tree, tree); static void build_vtt (tree); static tree binfo_ctor_vtable (tree); -static void build_vtt_inits (tree, tree, VEC(constructor_elt,gc) **, tree *); +static void build_vtt_inits (tree, tree, vec<constructor_elt, va_gc> **, + tree *); static tree dfs_build_secondary_vptr_vtt_inits (tree, void *); static tree dfs_fixup_binfo_vtbls (tree, void *); static int record_subobject_offset (tree, tree, splay_tree); @@ -948,7 +949,7 @@ add_method (tree type, tree method, tree using_decl) tree overload; bool template_conv_p = false; bool conv_p; - VEC(tree,gc) *method_vec; + vec<tree, va_gc> *method_vec; bool complete_p; bool insert_p = false; tree current_fns; @@ -970,10 +971,10 @@ add_method (tree type, tree method, tree using_decl) allocate at least two (for constructors and destructors), and we're going to end up with an assignment operator at some point as well. */ - method_vec = VEC_alloc (tree, gc, 8); + vec_alloc (method_vec, 8); /* Create slots for constructors and destructors. */ - VEC_quick_push (tree, method_vec, NULL_TREE); - VEC_quick_push (tree, method_vec, NULL_TREE); + method_vec->quick_push (NULL_TREE); + method_vec->quick_push (NULL_TREE); CLASSTYPE_METHOD_VEC (type) = method_vec; } @@ -1004,7 +1005,7 @@ add_method (tree type, tree method, tree using_decl) insert_p = true; /* See if we already have an entry with this name. */ for (slot = CLASSTYPE_FIRST_CONVERSION_SLOT; - VEC_iterate (tree, method_vec, slot, m); + vec_safe_iterate (method_vec, slot, &m); ++slot) { m = OVL_CURRENT (m); @@ -1028,7 +1029,7 @@ add_method (tree type, tree method, tree using_decl) break; } } - current_fns = insert_p ? NULL_TREE : VEC_index (tree, method_vec, slot); + current_fns = insert_p ? NULL_TREE : (*method_vec)[slot]; /* Check to see if we've already got this method. */ for (fns = current_fns; fns; fns = OVL_NEXT (fns)) @@ -1175,19 +1176,19 @@ add_method (tree type, tree method, tree using_decl) /* We only expect to add few methods in the COMPLETE_P case, so just make room for one more method in that case. */ if (complete_p) - reallocated = VEC_reserve_exact (tree, gc, method_vec, 1); + reallocated = vec_safe_reserve_exact (method_vec, 1); else - reallocated = VEC_reserve (tree, gc, method_vec, 1); + reallocated = vec_safe_reserve (method_vec, 1); if (reallocated) CLASSTYPE_METHOD_VEC (type) = method_vec; - if (slot == VEC_length (tree, method_vec)) - VEC_quick_push (tree, method_vec, overload); + if (slot == method_vec->length ()) + method_vec->quick_push (overload); else - VEC_quick_insert (tree, method_vec, slot, overload); + method_vec->quick_insert (slot, overload); } else /* Replace the current slot. */ - VEC_replace (tree, method_vec, slot, overload); + (*method_vec)[slot] = overload; return true; } @@ -1953,15 +1954,15 @@ resort_type_method_vec (void* obj, gt_pointer_operator new_value, void* cookie) { - VEC(tree,gc) *method_vec = (VEC(tree,gc) *) obj; - int len = VEC_length (tree, method_vec); + vec<tree, va_gc> *method_vec = (vec<tree, va_gc> *) obj; + int len = vec_safe_length (method_vec); size_t slot; tree fn; /* The type conversion ops have to live at the front of the vec, so we can't sort them. */ for (slot = CLASSTYPE_FIRST_CONVERSION_SLOT; - VEC_iterate (tree, method_vec, slot, fn); + vec_safe_iterate (method_vec, slot, &fn); ++slot) if (!DECL_CONV_FN_P (OVL_CURRENT (fn))) break; @@ -1970,7 +1971,7 @@ resort_type_method_vec (void* obj, { resort_data.new_value = new_value; resort_data.cookie = cookie; - qsort (VEC_address (tree, method_vec) + slot, len - slot, sizeof (tree), + qsort (method_vec->address () + slot, len - slot, sizeof (tree), resort_method_name_cmp); } } @@ -1985,14 +1986,14 @@ static void finish_struct_methods (tree t) { tree fn_fields; - VEC(tree,gc) *method_vec; + vec<tree, va_gc> *method_vec; int slot, len; method_vec = CLASSTYPE_METHOD_VEC (t); if (!method_vec) return; - len = VEC_length (tree, method_vec); + len = method_vec->length (); /* Clear DECL_IN_AGGR_P for all functions. */ for (fn_fields = TYPE_METHODS (t); fn_fields; @@ -2006,12 +2007,12 @@ finish_struct_methods (tree t) /* The type conversion ops have to live at the front of the vec, so we can't sort them. */ for (slot = CLASSTYPE_FIRST_CONVERSION_SLOT; - VEC_iterate (tree, method_vec, slot, fn_fields); + method_vec->iterate (slot, &fn_fields); ++slot) if (!DECL_CONV_FN_P (OVL_CURRENT (fn_fields))) break; if (len - slot > 1) - qsort (VEC_address (tree, method_vec) + slot, + qsort (method_vec->address () + slot, len-slot, sizeof (tree), method_name_cmp); } @@ -2103,7 +2104,7 @@ typedef struct find_final_overrider_data_s { /* The candidate overriders. */ tree candidates; /* Path to most derived. */ - VEC(tree,heap) *path; + vec<tree> path; } find_final_overrider_data; /* Add the overrider along the current path to FFOD->CANDIDATES. @@ -2122,7 +2123,7 @@ dfs_find_final_overrider_1 (tree binfo, { depth--; if (dfs_find_final_overrider_1 - (VEC_index (tree, ffod->path, depth), ffod, depth)) + (ffod->path[depth], ffod, depth)) return true; } @@ -2161,8 +2162,8 @@ dfs_find_final_overrider_pre (tree binfo, void *data) find_final_overrider_data *ffod = (find_final_overrider_data *) data; if (binfo == ffod->declaring_base) - dfs_find_final_overrider_1 (binfo, ffod, VEC_length (tree, ffod->path)); - VEC_safe_push (tree, heap, ffod->path, binfo); + dfs_find_final_overrider_1 (binfo, ffod, ffod->path.length ()); + ffod->path.safe_push (binfo); return NULL_TREE; } @@ -2171,7 +2172,7 @@ static tree dfs_find_final_overrider_post (tree /*binfo*/, void *data) { find_final_overrider_data *ffod = (find_final_overrider_data *) data; - VEC_pop (tree, ffod->path); + ffod->path.pop (); return NULL_TREE; } @@ -2211,12 +2212,12 @@ find_final_overrider (tree derived, tree binfo, tree fn) ffod.fn = fn; ffod.declaring_base = binfo; ffod.candidates = NULL_TREE; - ffod.path = VEC_alloc (tree, heap, 30); + ffod.path.create (30); dfs_walk_all (derived, dfs_find_final_overrider_pre, dfs_find_final_overrider_post, &ffod); - VEC_free (tree, heap, ffod.path); + ffod.path.release (); /* If there was no winner, issue an error message. */ if (!ffod.candidates || TREE_CHAIN (ffod.candidates)) @@ -2231,11 +2232,11 @@ find_final_overrider (tree derived, tree binfo, tree fn) static tree get_vcall_index (tree fn, tree type) { - VEC(tree_pair_s,gc) *indices = CLASSTYPE_VCALL_INDICES (type); + vec<tree_pair_s, va_gc> *indices = CLASSTYPE_VCALL_INDICES (type); tree_pair_p p; unsigned ix; - FOR_EACH_VEC_ELT (tree_pair_s, indices, ix, p) + FOR_EACH_VEC_SAFE_ELT (indices, ix, p) if ((DECL_DESTRUCTOR_P (fn) && DECL_DESTRUCTOR_P (p->purpose)) || same_signature_p (fn, p->purpose)) return p->value; @@ -2589,7 +2590,7 @@ get_basefndecls (tree name, tree t) /* Find virtual functions in T with the indicated NAME. */ i = lookup_fnfields_1 (t, name); if (i != -1) - for (methods = VEC_index (tree, CLASSTYPE_METHOD_VEC (t), i); + for (methods = (*CLASSTYPE_METHOD_VEC (t))[i]; methods; methods = OVL_NEXT (methods)) { @@ -2660,13 +2661,13 @@ check_for_override (tree decl, tree ctype) static void warn_hidden (tree t) { - VEC(tree,gc) *method_vec = CLASSTYPE_METHOD_VEC (t); + vec<tree, va_gc> *method_vec = CLASSTYPE_METHOD_VEC (t); tree fns; size_t i; /* We go through each separately named virtual function. */ for (i = CLASSTYPE_FIRST_CONVERSION_SLOT; - VEC_iterate (tree, method_vec, i, fns); + vec_safe_iterate (method_vec, i, &fns); ++i) { tree fn; @@ -3704,7 +3705,7 @@ walk_subobject_offsets (tree type, if (abi_version_at_least (2) && CLASSTYPE_VBASECLASSES (type)) { unsigned ix; - VEC(tree,gc) *vbases; + vec<tree, va_gc> *vbases; /* Iterate through the virtual base classes of TYPE. In G++ 3.2, we included virtual bases in the direct base class @@ -3713,7 +3714,7 @@ walk_subobject_offsets (tree type, working with the most derived type. */ if (vbases_p) for (vbases = CLASSTYPE_VBASECLASSES (type), ix = 0; - VEC_iterate (tree, vbases, ix, binfo); ix++) + vec_safe_iterate (vbases, ix, &binfo); ix++) { r = walk_subobject_offsets (binfo, f, @@ -4221,7 +4222,7 @@ check_methods (tree t) { TYPE_POLYMORPHIC_P (t) = 1; if (DECL_PURE_VIRTUAL_P (x)) - VEC_safe_push (tree, gc, CLASSTYPE_PURE_VIRTUALS (t), x); + vec_safe_push (CLASSTYPE_PURE_VIRTUALS (t), x); } /* All user-provided destructors are non-trivial. Constructors and assignment ops are handled in @@ -5620,7 +5621,7 @@ static tree end_of_class (tree t, int include_virtuals_p) { tree result = size_zero_node; - VEC(tree,gc) *vbases; + vec<tree, va_gc> *vbases; tree binfo; tree base_binfo; tree offset; @@ -5643,7 +5644,7 @@ end_of_class (tree t, int include_virtuals_p) /* G++ 3.2 did not check indirect virtual bases. */ if (abi_version_at_least (2) && include_virtuals_p) for (vbases = CLASSTYPE_VBASECLASSES (t), i = 0; - VEC_iterate (tree, vbases, i, base_binfo); i++) + vec_safe_iterate (vbases, i, &base_binfo); i++) { offset = end_of_base (base_binfo); if (INT_CST_LT_UNSIGNED (result, offset)) @@ -5667,7 +5668,7 @@ static void warn_about_ambiguous_bases (tree t) { int i; - VEC(tree,gc) *vbases; + vec<tree, va_gc> *vbases; tree basetype; tree binfo; tree base_binfo; @@ -5690,7 +5691,7 @@ warn_about_ambiguous_bases (tree t) /* Check for ambiguous virtual bases. */ if (extra_warnings) for (vbases = CLASSTYPE_VBASECLASSES (t), i = 0; - VEC_iterate (tree, vbases, i, binfo); i++) + vec_safe_iterate (vbases, i, &binfo); i++) { basetype = BINFO_TYPE (binfo); @@ -6520,7 +6521,7 @@ finish_struct (tree t, tree attributes) CLASSTYPE_PURE_VIRTUALS (t) = NULL; for (x = TYPE_METHODS (t); x; x = DECL_CHAIN (x)) if (DECL_PURE_VIRTUAL_P (x)) - VEC_safe_push (tree, gc, CLASSTYPE_PURE_VIRTUALS (t), x); + vec_safe_push (CLASSTYPE_PURE_VIRTUALS (t), x); complete_vars (t); /* We need to add the target functions to the CLASSTYPE_METHOD_VEC if an enclosing scope is a template class, so that this function be @@ -6766,7 +6767,7 @@ init_class_processing (void) current_class_stack_size = 10; current_class_stack = XNEWVEC (struct class_stack_node, current_class_stack_size); - local_classes = VEC_alloc (tree, gc, 8); + vec_alloc (local_classes, 8); sizeof_biggest_empty_class = size_zero_node; ridpointers[(int) RID_PUBLIC] = access_public_node; @@ -7028,7 +7029,7 @@ pop_nested_class (void) int current_lang_depth (void) { - return VEC_length (tree, current_lang_base); + return vec_safe_length (current_lang_base); } /* Set global variables CURRENT_LANG_NAME to appropriate value @@ -7037,7 +7038,7 @@ current_lang_depth (void) void push_lang_context (tree name) { - VEC_safe_push (tree, gc, current_lang_base, current_lang_name); + vec_safe_push (current_lang_base, current_lang_name); if (name == lang_name_cplusplus) { @@ -7072,7 +7073,7 @@ push_lang_context (tree name) void pop_lang_context (void) { - current_lang_name = VEC_pop (tree, current_lang_base); + current_lang_name = current_lang_base->pop (); } /* Type instantiation routines. */ @@ -8051,7 +8052,7 @@ static void finish_vtbls (tree t) { tree vbase; - VEC(constructor_elt,gc) *v = NULL; + vec<constructor_elt, va_gc> *v = NULL; tree vtable = BINFO_VTABLE (TYPE_BINFO (t)); /* We lay out the primary and secondary vtables in one contiguous @@ -8075,11 +8076,11 @@ finish_vtbls (tree t) /* Initialize the vtable for BINFO with the INITS. */ static void -initialize_vtable (tree binfo, VEC(constructor_elt,gc) *inits) +initialize_vtable (tree binfo, vec<constructor_elt, va_gc> *inits) { tree decl; - layout_vtable_decl (binfo, VEC_length (constructor_elt, inits)); + layout_vtable_decl (binfo, vec_safe_length (inits)); decl = get_vtbl_decl_for_binfo (binfo); initialize_artificial_var (decl, inits); dump_vtable (BINFO_TYPE (binfo), binfo, decl); @@ -8104,7 +8105,7 @@ build_vtt (tree t) tree type; tree vtt; tree index; - VEC(constructor_elt,gc) *inits; + vec<constructor_elt, va_gc> *inits; /* Build up the initializers for the VTT. */ inits = NULL; @@ -8117,7 +8118,7 @@ build_vtt (tree t) /* Figure out the type of the VTT. */ type = build_array_of_n_type (const_ptr_type_node, - VEC_length (constructor_elt, inits)); + inits->length ()); /* Now, build the VTT object itself. */ vtt = build_vtable (t, mangle_vtt_for_type (t), type); @@ -8163,7 +8164,7 @@ typedef struct secondary_vptr_vtt_init_data_s tree index; /* Vector of initializers built up. */ - VEC(constructor_elt,gc) *inits; + vec<constructor_elt, va_gc> *inits; /* The type being constructed by this secondary VTT. */ tree type_being_constructed; @@ -8178,7 +8179,8 @@ typedef struct secondary_vptr_vtt_init_data_s vtables for the BINFO-in-T variant. */ static void -build_vtt_inits (tree binfo, tree t, VEC(constructor_elt,gc) **inits, tree *index) +build_vtt_inits (tree binfo, tree t, vec<constructor_elt, va_gc> **inits, + tree *index) { int i; tree b; @@ -8338,7 +8340,7 @@ build_ctor_vtbl_group (tree binfo, tree t) tree vtbl; tree id; tree vbase; - VEC(constructor_elt,gc) *v; + vec<constructor_elt, va_gc> *v; /* See if we've already created this construction vtable group. */ id = mangle_ctor_vtbl_for_type (t, binfo); @@ -8372,8 +8374,7 @@ build_ctor_vtbl_group (tree binfo, tree t) } /* Figure out the type of the construction vtable. */ - type = build_array_of_n_type (vtable_entry_type, - VEC_length (constructor_elt, v)); + type = build_array_of_n_type (vtable_entry_type, v->length ()); layout_type (type); TREE_TYPE (vtbl) = type; DECL_SIZE (vtbl) = DECL_SIZE_UNIT (vtbl) = NULL_TREE; @@ -8401,7 +8402,7 @@ accumulate_vtbl_inits (tree binfo, tree rtti_binfo, tree vtbl, tree t, - VEC(constructor_elt,gc) **inits) + vec<constructor_elt, va_gc> **inits) { int i; tree base_binfo; @@ -8449,7 +8450,7 @@ dfs_accumulate_vtbl_inits (tree binfo, tree rtti_binfo, tree orig_vtbl, tree t, - VEC(constructor_elt,gc) **l) + vec<constructor_elt, va_gc> **l) { tree vtbl = NULL_TREE; int ctor_vtbl_p = !SAME_BINFO_TYPE_P (BINFO_TYPE (rtti_binfo), t); @@ -8509,7 +8510,7 @@ dfs_accumulate_vtbl_inits (tree binfo, else if (!BINFO_NEW_VTABLE_MARKED (orig_binfo)) return; - n_inits = VEC_length (constructor_elt, *l); + n_inits = vec_safe_length (*l); if (!vtbl) { @@ -8535,7 +8536,7 @@ dfs_accumulate_vtbl_inits (tree binfo, BINFO_VTABLE (binfo) = tree_cons (rtti_binfo, vtbl, BINFO_VTABLE (binfo)); else if (BINFO_PRIMARY_P (binfo) && BINFO_VIRTUAL_P (binfo)) /* Throw away any unneeded intializers. */ - VEC_truncate (constructor_elt, *l, n_inits); + (*l)->truncate (n_inits); else /* For an ordinary vtable, set BINFO_VTABLE. */ BINFO_VTABLE (binfo) = vtbl; @@ -8572,13 +8573,13 @@ build_vtbl_initializer (tree binfo, tree t, tree rtti_binfo, int* non_fn_entries_p, - VEC(constructor_elt,gc) **inits) + vec<constructor_elt, va_gc> **inits) { tree v; vtbl_init_data vid; unsigned ix, jx; tree vbinfo; - VEC(tree,gc) *vbases; + vec<tree, va_gc> *vbases; constructor_elt *e; /* Initialize VID. */ @@ -8598,41 +8599,39 @@ build_vtbl_initializer (tree binfo, /* Create an array for keeping track of the functions we've processed. When we see multiple functions with the same signature, we share the vcall offsets. */ - vid.fns = VEC_alloc (tree, gc, 32); + vec_alloc (vid.fns, 32); /* Add the vcall and vbase offset entries. */ build_vcall_and_vbase_vtbl_entries (binfo, &vid); /* Clear BINFO_VTABLE_PATH_MARKED; it's set by build_vbase_offset_vtbl_entries. */ for (vbases = CLASSTYPE_VBASECLASSES (t), ix = 0; - VEC_iterate (tree, vbases, ix, vbinfo); ix++) + vec_safe_iterate (vbases, ix, &vbinfo); ix++) BINFO_VTABLE_PATH_MARKED (vbinfo) = 0; /* If the target requires padding between data entries, add that now. */ if (TARGET_VTABLE_DATA_ENTRY_DISTANCE > 1) { - int n_entries = VEC_length (constructor_elt, vid.inits); + int n_entries = vec_safe_length (vid.inits); - VEC_safe_grow (constructor_elt, gc, vid.inits, - TARGET_VTABLE_DATA_ENTRY_DISTANCE * n_entries); + vec_safe_grow (vid.inits, TARGET_VTABLE_DATA_ENTRY_DISTANCE * n_entries); /* Move data entries into their new positions and add padding after the new positions. Iterate backwards so we don't overwrite entries that we would need to process later. */ for (ix = n_entries - 1; - VEC_iterate (constructor_elt, vid.inits, ix, e); + vid.inits->iterate (ix, &e); ix--) { int j; int new_position = (TARGET_VTABLE_DATA_ENTRY_DISTANCE * ix + (TARGET_VTABLE_DATA_ENTRY_DISTANCE - 1)); - VEC_replace (constructor_elt, vid.inits, new_position, *e); + (*vid.inits)[new_position] = *e; for (j = 1; j < TARGET_VTABLE_DATA_ENTRY_DISTANCE; ++j) { - constructor_elt *f = &VEC_index (constructor_elt, vid.inits, - new_position - j); + constructor_elt *f = &(*vid.inits)[new_position - j]; f->index = NULL_TREE; f->value = build1 (NOP_EXPR, vtable_entry_type, null_pointer_node); @@ -8641,19 +8640,18 @@ build_vtbl_initializer (tree binfo, } if (non_fn_entries_p) - *non_fn_entries_p = VEC_length (constructor_elt, vid.inits); + *non_fn_entries_p = vec_safe_length (vid.inits); /* The initializers for virtual functions were built up in reverse order. Straighten them out and add them to the running list in one step. */ - jx = VEC_length (constructor_elt, *inits); - VEC_safe_grow (constructor_elt, gc, *inits, - (jx + VEC_length (constructor_elt, vid.inits))); + jx = vec_safe_length (*inits); + vec_safe_grow (*inits, jx + vid.inits->length ()); - for (ix = VEC_length (constructor_elt, vid.inits) - 1; - VEC_iterate (constructor_elt, vid.inits, ix, e); + for (ix = vid.inits->length () - 1; + vid.inits->iterate (ix, &e); ix--, jx++) - VEC_replace (constructor_elt, *inits, jx, *e); + (**inits)[jx] = *e; /* Go through all the ordinary virtual functions, building up initializers. */ @@ -9053,7 +9051,7 @@ add_vcall_offset (tree orig_fn, tree binfo, vtbl_init_data *vid) signature as FN, then we do not need a second vcall offset. Check the list of functions already present in the derived class vtable. */ - FOR_EACH_VEC_ELT (tree, vid->fns, i, derived_entry) + FOR_EACH_VEC_SAFE_ELT (vid->fns, i, derived_entry) { if (same_signature_p (derived_entry, orig_fn) /* We only use one vcall offset for virtual destructors, @@ -9069,8 +9067,7 @@ add_vcall_offset (tree orig_fn, tree binfo, vtbl_init_data *vid) if (vid->binfo == TYPE_BINFO (vid->derived)) { tree_pair_s elt = {orig_fn, vid->index}; - VEC_safe_push (tree_pair_s, gc, CLASSTYPE_VCALL_INDICES (vid->derived), - elt); + vec_safe_push (CLASSTYPE_VCALL_INDICES (vid->derived), elt); } /* The next vcall offset will be found at a more negative @@ -9079,7 +9076,7 @@ add_vcall_offset (tree orig_fn, tree binfo, vtbl_init_data *vid) ssize_int (TARGET_VTABLE_DATA_ENTRY_DISTANCE)); /* Keep track of this function. */ - VEC_safe_push (tree, gc, vid->fns, orig_fn); + vec_safe_push (vid->fns, orig_fn); if (vid->generate_vcall_entries) { |