diff options
| author | Justin Bogner <mail@justinbogner.com> | 2014-04-18 20:27:24 +0000 |
|---|---|---|
| committer | Justin Bogner <mail@justinbogner.com> | 2014-04-18 20:27:24 +0000 |
| commit | 25463f15771d18a863838d099716eba631a51b65 (patch) | |
| tree | 6d550edec81058d8801ebc509f2e74de20c18ec9 | |
| parent | be0a7ac5e85b893d8837b81440082212dc144769 (diff) | |
| download | bcm5719-llvm-25463f15771d18a863838d099716eba631a51b65.tar.gz bcm5719-llvm-25463f15771d18a863838d099716eba631a51b65.zip | |
Teach users of OnDiskHashTable to define hash_value and offset types
This paves the way to making OnDiskHashTable work with hashes that are
not 32 bits wide and to making OnDiskHashTable work very large hash
tables. The LLVM change to use these types is upcoming.
llvm-svn: 206640
| -rw-r--r-- | clang/lib/Frontend/CacheTokens.cpp | 10 | ||||
| -rw-r--r-- | clang/lib/Lex/PTHLexer.cpp | 16 | ||||
| -rw-r--r-- | clang/lib/Serialization/ASTReaderInternals.h | 17 | ||||
| -rw-r--r-- | clang/lib/Serialization/ASTWriter.cpp | 23 | ||||
| -rw-r--r-- | clang/lib/Serialization/GlobalModuleIndex.cpp | 8 |
5 files changed, 52 insertions, 22 deletions
diff --git a/clang/lib/Frontend/CacheTokens.cpp b/clang/lib/Frontend/CacheTokens.cpp index 0d4d1c4710a..bf1c968da12 100644 --- a/clang/lib/Frontend/CacheTokens.cpp +++ b/clang/lib/Frontend/CacheTokens.cpp @@ -117,7 +117,10 @@ public: typedef PTHEntry data_type; typedef const PTHEntry& data_type_ref; - static unsigned ComputeHash(PTHEntryKeyVariant V) { + typedef unsigned hash_value_type; + typedef unsigned offset_type; + + static hash_value_type ComputeHash(PTHEntryKeyVariant V) { return llvm::HashString(V.getString()); } @@ -599,7 +602,10 @@ public: typedef uint32_t data_type; typedef data_type data_type_ref; - static unsigned ComputeHash(PTHIdKey* key) { + typedef unsigned hash_value_type; + typedef unsigned offset_type; + + static hash_value_type ComputeHash(PTHIdKey* key) { return llvm::HashString(key->II->getName()); } diff --git a/clang/lib/Lex/PTHLexer.cpp b/clang/lib/Lex/PTHLexer.cpp index f30e12157fe..b888f2ed9b6 100644 --- a/clang/lib/Lex/PTHLexer.cpp +++ b/clang/lib/Lex/PTHLexer.cpp @@ -318,8 +318,10 @@ public: class PTHFileLookupCommonTrait { public: typedef std::pair<unsigned char, const char*> internal_key_type; + typedef unsigned hash_value_type; + typedef unsigned offset_type; - static unsigned ComputeHash(internal_key_type x) { + static hash_value_type ComputeHash(internal_key_type x) { return llvm::HashString(x.second); } @@ -363,13 +365,11 @@ public: class PTHStringLookupTrait { public: - typedef uint32_t - data_type; - - typedef const std::pair<const char*, unsigned> - external_key_type; - + typedef uint32_t data_type; + typedef const std::pair<const char*, unsigned> external_key_type; typedef external_key_type internal_key_type; + typedef uint32_t hash_value_type; + typedef unsigned offset_type; static bool EqualKey(const internal_key_type& a, const internal_key_type& b) { @@ -377,7 +377,7 @@ public: : false; } - static unsigned ComputeHash(const internal_key_type& a) { + static hash_value_type ComputeHash(const internal_key_type& a) { return llvm::HashString(StringRef(a.first, a.second)); } diff --git a/clang/lib/Serialization/ASTReaderInternals.h b/clang/lib/Serialization/ASTReaderInternals.h index 7f0201b916d..fdcecca4aad 100644 --- a/clang/lib/Serialization/ASTReaderInternals.h +++ b/clang/lib/Serialization/ASTReaderInternals.h @@ -46,6 +46,8 @@ public: /// particular lookup t typedef llvm::support::ulittle32_t LE32DeclID; typedef std::pair<LE32DeclID *, LE32DeclID *> data_type; + typedef unsigned hash_value_type; + typedef unsigned offset_type; /// \brief Special internal key for declaration names. /// The hash table creates keys for comparison; we do not create @@ -67,7 +69,7 @@ public: return a.Kind == b.Kind && a.Data == b.Data; } - unsigned ComputeHash(const DeclNameKey &Key) const; + hash_value_type ComputeHash(const DeclNameKey &Key) const; internal_key_type GetInternalKey(const external_key_type& Name) const; static std::pair<unsigned, unsigned> @@ -92,13 +94,14 @@ class ASTIdentifierLookupTraitBase { public: typedef StringRef external_key_type; typedef StringRef internal_key_type; - + typedef unsigned hash_value_type; + typedef unsigned offset_type; static bool EqualKey(const internal_key_type& a, const internal_key_type& b) { return a == b; } - static unsigned ComputeHash(const internal_key_type& a); + static hash_value_type ComputeHash(const internal_key_type& a); static std::pair<unsigned, unsigned> ReadKeyDataLength(const unsigned char*& d); @@ -160,6 +163,8 @@ public: typedef Selector external_key_type; typedef external_key_type internal_key_type; + typedef unsigned hash_value_type; + typedef unsigned offset_type; ASTSelectorLookupTrait(ASTReader &Reader, ModuleFile &F) : Reader(Reader), F(F) { } @@ -169,7 +174,7 @@ public: return a == b; } - static unsigned ComputeHash(Selector Sel); + static hash_value_type ComputeHash(Selector Sel); static const internal_key_type& GetInternalKey(const external_key_type& x) { return x; } @@ -211,12 +216,14 @@ public: typedef const internal_key_type &internal_key_ref; typedef HeaderFileInfo data_type; + typedef unsigned hash_value_type; + typedef unsigned offset_type; HeaderFileInfoTrait(ASTReader &Reader, ModuleFile &M, HeaderSearch *HS, const char *FrameworkStrings) : Reader(Reader), M(M), HS(HS), FrameworkStrings(FrameworkStrings) { } - static unsigned ComputeHash(internal_key_ref ikey); + static hash_value_type ComputeHash(internal_key_ref ikey); static internal_key_type GetInternalKey(const FileEntry *FE); bool EqualKey(internal_key_ref a, internal_key_ref b); diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index cb25fe6f886..d770f8df26e 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -1482,8 +1482,10 @@ namespace { typedef HeaderFileInfo data_type; typedef const data_type &data_type_ref; + typedef unsigned hash_value_type; + typedef unsigned offset_type; - static unsigned ComputeHash(key_type_ref key) { + static hash_value_type ComputeHash(key_type_ref key) { // The hash is based only on size/time of the file, so that the reader can // match even when symlinking or excess path elements ("foo/../", "../") // change the form of the name. However, complete path is still the key. @@ -1855,8 +1857,10 @@ public: typedef Data data_type; typedef const data_type &data_type_ref; + typedef unsigned hash_value_type; + typedef unsigned offset_type; - static unsigned ComputeHash(IdentID IdID) { + static hash_value_type ComputeHash(IdentID IdID) { return llvm::hash_value(IdID); } @@ -2738,9 +2742,12 @@ public: }; typedef const data_type& data_type_ref; + typedef unsigned hash_value_type; + typedef unsigned offset_type; + explicit ASTMethodPoolTrait(ASTWriter &Writer) : Writer(Writer) { } - static unsigned ComputeHash(Selector Sel) { + static hash_value_type ComputeHash(Selector Sel) { return serialization::ComputeHash(Sel); } @@ -3090,11 +3097,14 @@ public: typedef IdentID data_type; typedef data_type data_type_ref; + typedef unsigned hash_value_type; + typedef unsigned offset_type; + ASTIdentifierTableTrait(ASTWriter &Writer, Preprocessor &PP, IdentifierResolver &IdResolver, bool IsModule) : Writer(Writer), PP(PP), IdResolver(IdResolver), IsModule(IsModule) { } - static unsigned ComputeHash(const IdentifierInfo* II) { + static hash_value_type ComputeHash(const IdentifierInfo* II) { return llvm::HashString(II->getName()); } @@ -3349,9 +3359,12 @@ public: typedef DeclContext::lookup_result data_type; typedef const data_type& data_type_ref; + typedef unsigned hash_value_type; + typedef unsigned offset_type; + explicit ASTDeclContextNameLookupTrait(ASTWriter &Writer) : Writer(Writer) { } - unsigned ComputeHash(DeclarationName Name) { + hash_value_type ComputeHash(DeclarationName Name) { llvm::FoldingSetNodeID ID; ID.AddInteger(Name.getNameKind()); diff --git a/clang/lib/Serialization/GlobalModuleIndex.cpp b/clang/lib/Serialization/GlobalModuleIndex.cpp index 1649476342b..21a714999b0 100644 --- a/clang/lib/Serialization/GlobalModuleIndex.cpp +++ b/clang/lib/Serialization/GlobalModuleIndex.cpp @@ -72,12 +72,14 @@ public: typedef StringRef external_key_type; typedef StringRef internal_key_type; typedef SmallVector<unsigned, 2> data_type; + typedef unsigned hash_value_type; + typedef unsigned offset_type; static bool EqualKey(const internal_key_type& a, const internal_key_type& b) { return a == b; } - static unsigned ComputeHash(const internal_key_type& a) { + static hash_value_type ComputeHash(const internal_key_type& a) { return llvm::HashString(a); } @@ -645,8 +647,10 @@ public: typedef StringRef key_type_ref; typedef SmallVector<unsigned, 2> data_type; typedef const SmallVector<unsigned, 2> &data_type_ref; + typedef unsigned hash_value_type; + typedef unsigned offset_type; - static unsigned ComputeHash(key_type_ref Key) { + static hash_value_type ComputeHash(key_type_ref Key) { return llvm::HashString(Key); } |

