diff options
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/cp/Make-lang.in | 6 | ||||
-rw-r--r-- | gcc/cp/class.c | 18 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 11 | ||||
-rw-r--r-- | gcc/cp/tree.c | 16 |
5 files changed, 36 insertions, 25 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ab91500..5d09183 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,13 @@ +2012-10-09 Lawrence Crowl <crowl@google.com> + + * Make-lang.in (class.o): Add dependence on hash-table.h. + (tree.o): Likewise. + (semantics.o): Likewise. + * class.c (fixed_type_or_null): Change to new type-safe hash table. + * tree.c (verify_stmt_tree): Likewise. + (verify_stmt_tree_r): Likewise. + * semantics.c (struct nrv_data): Likewise. + 2012-10-09 Paolo Carlini <paolo.carlini@oracle.com> PR c++/54194 diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in index 7b1d4e6..812f3cb5 100644 --- a/gcc/cp/Make-lang.in +++ b/gcc/cp/Make-lang.in @@ -293,7 +293,7 @@ cp/typeck.o: cp/typeck.c $(CXX_TREE_H) $(TM_H) $(FLAGS_H) \ c-family/c-objc.h cp/class.o: cp/class.c $(CXX_TREE_H) $(TM_H) $(FLAGS_H) toplev.h \ $(TARGET_H) convert.h $(CGRAPH_H) dumpfile.h gt-cp-class.h \ - $(SPLAY_TREE_H) pointer-set.h + $(SPLAY_TREE_H) pointer-set.h $(HASH_TABLE_H) cp/call.o: cp/call.c $(CXX_TREE_H) $(TM_H) $(FLAGS_H) toplev.h \ $(DIAGNOSTIC_CORE_H) intl.h gt-cp-call.h convert.h $(TARGET_H) langhooks.h \ $(TIMEVAR_H) c-family/c-objc.h @@ -309,7 +309,7 @@ cp/search.o: cp/search.c $(CXX_TREE_H) $(TM_H) $(FLAGS_H) toplev.h \ intl.h cp/tree.o: cp/tree.c $(CXX_TREE_H) $(TM_H) $(FLAGS_H) \ $(TREE_INLINE_H) $(REAL_H) gt-cp-tree.h \ - $(TARGET_H) debug.h $(CGRAPH_H) $(SPLAY_TREE_H) $(GIMPLE_H) + $(TARGET_H) debug.h $(CGRAPH_H) $(SPLAY_TREE_H) $(GIMPLE_H) $(HASH_TABLE_H) cp/ptree.o: cp/ptree.c $(CXX_TREE_H) $(TM_H) cp/rtti.o: cp/rtti.c $(CXX_TREE_H) $(TM_H) $(FLAGS_H) convert.h \ $(TARGET_H) $(C_PRAGMA_H) gt-cp-rtti.h intl.h @@ -327,7 +327,7 @@ cp/repo.o: cp/repo.c $(CXX_TREE_H) $(TM_H) toplev.h $(DIAGNOSTIC_CORE_H) \ cp/semantics.o: cp/semantics.c $(CXX_TREE_H) $(TM_H) toplev.h \ $(FLAGS_H) $(RTL_H) $(TIMEVAR_H) \ $(TREE_INLINE_H) $(CGRAPH_H) $(TARGET_H) $(C_COMMON_H) $(GIMPLE_H) \ - bitmap.h gt-cp-semantics.h c-family/c-objc.h + bitmap.h gt-cp-semantics.h c-family/c-objc.h $(HASH_TABLE_H) cp/dump.o: cp/dump.c $(CXX_TREE_H) $(TM_H) $(TREE_DUMP_H) cp/optimize.o: cp/optimize.c $(CXX_TREE_H) $(TM_H) \ input.h $(PARAMS_H) debug.h $(TREE_INLINE_H) $(GIMPLE_H) \ diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 8de1423..0e77b81 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -38,6 +38,7 @@ along with GCC; see the file COPYING3. If not see #include "dumpfile.h" #include "splay-tree.h" #include "pointer-set.h" +#include "hash-table.h" /* The number of nested classes being processed. If we are not in the scope of any class, this is zero. */ @@ -6465,12 +6466,9 @@ fixed_type_or_null (tree instance, int *nonnull, int *cdtorp) else if (TREE_CODE (TREE_TYPE (instance)) == REFERENCE_TYPE) { /* We only need one hash table because it is always left empty. */ - static htab_t ht; - if (!ht) - ht = htab_create (37, - htab_hash_pointer, - htab_eq_pointer, - /*htab_del=*/NULL); + static hash_table <pointer_hash <tree_node> > ht; + if (!ht.is_created ()) + ht.create (37); /* Reference variables should be references to objects. */ if (nonnull) @@ -6482,15 +6480,15 @@ fixed_type_or_null (tree instance, int *nonnull, int *cdtorp) if (TREE_CODE (instance) == VAR_DECL && DECL_INITIAL (instance) && !type_dependent_expression_p_push (DECL_INITIAL (instance)) - && !htab_find (ht, instance)) + && !ht.find (instance)) { tree type; - void **slot; + tree_node **slot; - slot = htab_find_slot (ht, instance, INSERT); + slot = ht.find_slot (instance, INSERT); *slot = instance; type = RECUR (DECL_INITIAL (instance)); - htab_remove_elt (ht, instance); + ht.remove_elt (instance); return type; } diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 4b06f30..4beed00 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -43,6 +43,7 @@ along with GCC; see the file COPYING3. If not see #include "target.h" #include "gimple.h" #include "bitmap.h" +#include "hash-table.h" /* There routines provide a modular interface to perform many parsing operations. They may therefore be used during actual parsing, or @@ -3837,7 +3838,7 @@ struct nrv_data { tree var; tree result; - htab_t visited; + hash_table <pointer_hash <tree_node> > visited; }; /* Helper function for walk_tree, used by finalize_nrv below. */ @@ -3846,7 +3847,7 @@ static tree finalize_nrv_r (tree* tp, int* walk_subtrees, void* data) { struct nrv_data *dp = (struct nrv_data *)data; - void **slot; + tree_node **slot; /* No need to walk into types. There wouldn't be any need to walk into non-statements, except that we have to consider STMT_EXPRs. */ @@ -3885,7 +3886,7 @@ finalize_nrv_r (tree* tp, int* walk_subtrees, void* data) /* Avoid walking into the same tree more than once. Unfortunately, we can't just use walk_tree_without duplicates because it would only call us for the first occurrence of dp->var in the function body. */ - slot = htab_find_slot (dp->visited, *tp, INSERT); + slot = dp->visited.find_slot (*tp, INSERT); if (*slot) *walk_subtrees = 0; else @@ -3917,9 +3918,9 @@ finalize_nrv (tree *tp, tree var, tree result) data.var = var; data.result = result; - data.visited = htab_create (37, htab_hash_pointer, htab_eq_pointer, NULL); + data.visited.create (37); cp_walk_tree (tp, finalize_nrv_r, &data, 0); - htab_delete (data.visited); + data.visited.dispose (); } /* Create CP_OMP_CLAUSE_INFO for clause C. Returns true if it is invalid. */ diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 14ca5a9..a41337c 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -34,6 +34,7 @@ along with GCC; see the file COPYING3. If not see #include "cgraph.h" #include "splay-tree.h" #include "gimple.h" /* gimple_has_body_p */ +#include "hash-table.h" static tree bot_manip (tree *, int *, void *); static tree bot_replace (tree *, int *, void *); @@ -1918,17 +1919,18 @@ static tree verify_stmt_tree_r (tree* tp, int * /*walk_subtrees*/, void* data) { tree t = *tp; - htab_t *statements = (htab_t *) data; - void **slot; + hash_table <pointer_hash <tree_node> > *statements + = static_cast <hash_table <pointer_hash <tree_node> > *> (data); + tree_node **slot; if (!STATEMENT_CODE_P (TREE_CODE (t))) return NULL_TREE; /* If this statement is already present in the hash table, then there is a circularity in the statement tree. */ - gcc_assert (!htab_find (*statements, t)); + gcc_assert (!statements->find (t)); - slot = htab_find_slot (*statements, t, INSERT); + slot = statements->find_slot (t, INSERT); *slot = t; return NULL_TREE; @@ -1941,10 +1943,10 @@ verify_stmt_tree_r (tree* tp, int * /*walk_subtrees*/, void* data) void verify_stmt_tree (tree t) { - htab_t statements; - statements = htab_create (37, htab_hash_pointer, htab_eq_pointer, NULL); + hash_table <pointer_hash <tree_node> > statements; + statements.create (37); cp_walk_tree (&t, verify_stmt_tree_r, &statements, NULL); - htab_delete (statements); + statements.dispose (); } /* Check if the type T depends on a type with no linkage and if so, return |