diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2012-03-05 10:36:16 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2012-03-05 10:36:16 +0000 |
commit | 08a47fd708680fc67f8c1c80f64379b35d6f472c (patch) | |
tree | e1f39c0631cbb94822bae2d6d6955ddc7cee34aa | |
parent | 7583ccdc1f1d78e2a4b906a8ad9b55b0a1efcc4c (diff) | |
download | bcm5719-llvm-08a47fd708680fc67f8c1c80f64379b35d6f472c.tar.gz bcm5719-llvm-08a47fd708680fc67f8c1c80f64379b35d6f472c.zip |
Switch the TableGen record's string-based DenseMap key to use the new
hashing infrastructure. I wonder why we don't just use StringMap here,
and I may revisit the issue if I have time, but for now I'm just trying
to consolidate.
llvm-svn: 152023
-rw-r--r-- | llvm/lib/TableGen/Record.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp index fece0df412c..12d1b1a4c95 100644 --- a/llvm/lib/TableGen/Record.cpp +++ b/llvm/lib/TableGen/Record.cpp @@ -18,6 +18,7 @@ #include "llvm/Support/Format.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/FoldingSet.h" +#include "llvm/ADT/Hashing.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringExtras.h" @@ -29,6 +30,8 @@ using namespace llvm; // std::string wrapper for DenseMap purposes //===----------------------------------------------------------------------===// +namespace llvm { + /// TableGenStringKey - This is a wrapper for std::string suitable for /// using as a key to a DenseMap. Because there isn't a particularly /// good way to indicate tombstone or empty keys for strings, we want @@ -43,14 +46,16 @@ public: TableGenStringKey(const char *str) : data(str) {} const std::string &str() const { return data; } - + + friend hash_code hash_value(const TableGenStringKey &Value) { + using llvm::hash_value; + return hash_value(Value.str()); + } private: std::string data; }; /// Specialize DenseMapInfo for TableGenStringKey. -namespace llvm { - template<> struct DenseMapInfo<TableGenStringKey> { static inline TableGenStringKey getEmptyKey() { TableGenStringKey Empty("<<<EMPTY KEY>>>"); @@ -61,7 +66,8 @@ template<> struct DenseMapInfo<TableGenStringKey> { return Tombstone; } static unsigned getHashValue(const TableGenStringKey& Val) { - return HashString(Val.str()); + using llvm::hash_value; + return hash_value(Val); } static bool isEqual(const TableGenStringKey& LHS, const TableGenStringKey& RHS) { @@ -69,7 +75,7 @@ template<> struct DenseMapInfo<TableGenStringKey> { } }; -} +} // namespace llvm //===----------------------------------------------------------------------===// // Type implementations |