diff options
author | Jason Merrill <merrill@gnu.org> | 1996-12-09 22:31:23 +0000 |
---|---|---|
committer | Jason Merrill <merrill@gnu.org> | 1996-12-09 22:31:23 +0000 |
commit | a94dbf2c2628c83773a1eb6c9ced1a49a3a5f45e (patch) | |
tree | 85d261767b8a92bfcd79dacffefca2f442d5cf06 /gcc/tree.c | |
parent | 19f5ce60f80423710b14e915da94b6f42ab25801 (diff) | |
download | gcc-a94dbf2c2628c83773a1eb6c9ced1a49a3a5f45e.zip gcc-a94dbf2c2628c83773a1eb6c9ced1a49a3a5f45e.tar.gz gcc-a94dbf2c2628c83773a1eb6c9ced1a49a3a5f45e.tar.bz2 |
x
From-SVN: r13258
Diffstat (limited to 'gcc/tree.c')
-rw-r--r-- | gcc/tree.c | 39 |
1 files changed, 39 insertions, 0 deletions
@@ -1268,6 +1268,45 @@ get_identifier (text) return idp; /* <-- return if created */ } +/* If an identifier with the name TEXT (a null-terminated string) has + previously been referred to, return that node; otherwise return + NULL_TREE. */ + +tree +maybe_get_identifier (text) + register char *text; +{ + register int hi; + register int i; + register tree idp; + register int len, hash_len; + + /* Compute length of text in len. */ + for (len = 0; text[len]; len++); + + /* Decide how much of that length to hash on */ + hash_len = len; + if (warn_id_clash && len > id_clash_len) + hash_len = id_clash_len; + + /* Compute hash code */ + hi = hash_len * 613 + (unsigned) text[0]; + for (i = 1; i < hash_len; i += 2) + hi = ((hi * 613) + (unsigned) (text[i])); + + hi &= (1 << HASHBITS) - 1; + hi %= MAX_HASH_TABLE; + + /* Search table for identifier */ + for (idp = hash_table[hi]; idp; idp = TREE_CHAIN (idp)) + if (IDENTIFIER_LENGTH (idp) == len + && IDENTIFIER_POINTER (idp)[0] == text[0] + && !bcmp (IDENTIFIER_POINTER (idp), text, len)) + return idp; /* <-- return if found */ + + return NULL_TREE; +} + /* Enable warnings on similar identifiers (if requested). Done after the built-in identifiers are created. */ |