diff options
Diffstat (limited to 'gcc/objc')
-rw-r--r-- | gcc/objc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/objc/Make-lang.in | 4 | ||||
-rw-r--r-- | gcc/objc/objc-act.c | 33 |
3 files changed, 28 insertions, 16 deletions
diff --git a/gcc/objc/ChangeLog b/gcc/objc/ChangeLog index e8ef7bb..575d473 100644 --- a/gcc/objc/ChangeLog +++ b/gcc/objc/ChangeLog @@ -1,3 +1,10 @@ +2012-10-01 Lawrence Crowl <crowl@google.com> + + * Make-lang.in (OBJC_OBJS): Add dependence on hash-table.o. + (objc-act.o): Add dependence on hash-table.h. + * objc-act.c (objc_detect_field_duplicates): Change to new type-safe + hash table. + 2012-06-29 Steven Bosscher <steven@gcc.gnu.org> * Make-ang.in: Adjust for move of C front-end files. diff --git a/gcc/objc/Make-lang.in b/gcc/objc/Make-lang.in index 05ddec6..bdc35e5 100644 --- a/gcc/objc/Make-lang.in +++ b/gcc/objc/Make-lang.in @@ -50,7 +50,7 @@ START_HDRS = $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) $(C_TREE_H) \ objc-warn = $(STRICT_WARN) # Language-specific object files for Objective C. -OBJC_OBJS = objc/objc-lang.o objc/objc-act.o \ +OBJC_OBJS = objc/objc-lang.o objc/objc-act.o hash-table.o \ objc/objc-runtime-shared-support.o \ objc/objc-gnu-runtime-abi-01.o \ objc/objc-next-runtime-abi-01.o \ @@ -127,7 +127,7 @@ objc/objc-act.o : objc/objc-act.c \ $(START_HDRS) \ $(GGC_H) $(DIAGNOSTIC_CORE_H) $(FLAGS_H) input.h \ toplev.h $(FUNCTION_H) debug.h $(LANGHOOKS_DEF_H) \ - $(HASHTAB_H) $(GIMPLE_H) \ + $(HASH_TABLE_H) $(GIMPLE_H) \ $(C_PRAGMA_H) $(C_TARGET_H) \ objc/objc-encoding.h \ objc/objc-map.h \ diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index caa16c7..cf0cc84 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -51,7 +51,7 @@ along with GCC; see the file COPYING3. If not see #include "intl.h" #include "cgraph.h" #include "tree-iterator.h" -#include "hashtab.h" +#include "hash-table.h" #include "langhooks-def.h" /* Different initialization, code gen and meta data generation for each runtime. */ @@ -3824,18 +3824,23 @@ objc_get_class_ivars (tree class_name) allows us to store keys in the hashtable, without values (it looks more like a set). So, we store the DECLs, but define equality as DECLs having the same name, and hash as the hash of the name. */ -static hashval_t -hash_instance_variable (const PTR p) + +struct decl_name_hash : typed_noop_remove <tree_node> +{ + typedef tree_node T; + static inline hashval_t hash (const T *); + static inline bool equal (const T *, const T *); +}; + +inline hashval_t +decl_name_hash::hash (const T *q) { - const_tree q = (const_tree)p; return (hashval_t) ((intptr_t)(DECL_NAME (q)) >> 3); } -static int -eq_instance_variable (const PTR p1, const PTR p2) +inline bool +decl_name_hash::equal (const T *a, const T *b) { - const_tree a = (const_tree)p1; - const_tree b = (const_tree)p2; return DECL_NAME (a) == DECL_NAME (b); } @@ -3916,8 +3921,8 @@ objc_detect_field_duplicates (bool check_superclasses_only) { /* First, build the hashtable by putting all the instance variables of superclasses in it. */ - htab_t htab = htab_create (37, hash_instance_variable, - eq_instance_variable, NULL); + hash_table <decl_name_hash> htab; + htab.create (37); tree interface; for (interface = lookup_interface (CLASS_SUPER_NAME (objc_interface_context)); @@ -3930,7 +3935,7 @@ objc_detect_field_duplicates (bool check_superclasses_only) { if (DECL_NAME (ivar) != NULL_TREE) { - void **slot = htab_find_slot (htab, ivar, INSERT); + tree_node **slot = htab.find_slot (ivar, INSERT); /* Do not check for duplicate instance variables in superclasses. Errors have already been generated. */ @@ -3950,7 +3955,7 @@ objc_detect_field_duplicates (bool check_superclasses_only) { if (DECL_NAME (ivar) != NULL_TREE) { - tree duplicate_ivar = (tree)(htab_find (htab, ivar)); + tree duplicate_ivar = htab.find (ivar); if (duplicate_ivar != HTAB_EMPTY_ENTRY) { error_at (DECL_SOURCE_LOCATION (ivar), @@ -3977,7 +3982,7 @@ objc_detect_field_duplicates (bool check_superclasses_only) { if (DECL_NAME (ivar) != NULL_TREE) { - void **slot = htab_find_slot (htab, ivar, INSERT); + tree_node **slot = htab.find_slot (ivar, INSERT); if (*slot) { tree duplicate_ivar = (tree)(*slot); @@ -3994,7 +3999,7 @@ objc_detect_field_duplicates (bool check_superclasses_only) } } } - htab_delete (htab); + htab.dispose (); return true; } } |