StringRef: add DenseMapInfo for StringRef.
authorManman Ren <mren@apple.com>
Mon, 8 Jul 2013 19:17:48 +0000 (19:17 +0000)
committerManman Ren <mren@apple.com>
Mon, 8 Jul 2013 19:17:48 +0000 (19:17 +0000)
Remove the implementation in include/llvm/Support/YAMLTraits.h.
Added a DenseMap type DITypeHashMap in DebugInfo.h:
  DenseMap<std::pair<StringRef, unsigned>, MDNode*>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185852 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/StringRef.h
include/llvm/DebugInfo.h
include/llvm/Support/YAMLTraits.h
lib/Support/StringRef.cpp

index d013d0562325287ba39baa189f321fd72ba9c21f..c5f2632f4bef21955eea2b1bc0924540944535d6 100644 (file)
@@ -548,6 +548,14 @@ namespace llvm {
   template <typename T> struct isPodLike;
   template <> struct isPodLike<StringRef> { static const bool value = true; };
 
+  template <typename T> struct DenseMapInfo;
+  template<> struct DenseMapInfo<StringRef> {
+    static StringRef getEmptyKey() { return StringRef(); }
+    static StringRef getTombstoneKey() { return StringRef(" ", 0); }
+    static unsigned getHashValue(StringRef const val);
+    static bool isEqual(StringRef const lhs,
+                        StringRef const rhs) { return lhs.equals(rhs); }
+  };
 }
 
 #endif
index 372d367b7075ec87f41edd1def186201d898ee64..c33a21d729f1d81f7ecb923f975ef7c1c4f509be 100644 (file)
@@ -17,6 +17,7 @@
 #ifndef LLVM_DEBUGINFO_H
 #define LLVM_DEBUGINFO_H
 
+#include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
@@ -45,6 +46,9 @@ namespace llvm {
   class DIType;
   class DIObjCProperty;
 
+  /// Map from a pair <unique type name, an unsigned flag> to MDNode.
+  typedef DenseMap<std::pair<StringRef, unsigned>, MDNode*> DITypeHashMap;
+
   /// DIDescriptor - A thin wraper around MDNode to access encoded debug info.
   /// This should not be stored in a container, because the underlying MDNode
   /// may change in certain situations.
index 801868ff1f1f7d4196eea8367f3417fd8340a6d6..14cbfc23738b792c1ab6fc128344ebdceb7788f4 100644 (file)
@@ -760,15 +760,7 @@ private:
     }
     static inline bool classof(const MapHNode *) { return true; }
 
-    struct StrMappingInfo {
-      static StringRef getEmptyKey() { return StringRef(); }
-      static StringRef getTombstoneKey() { return StringRef(" ", 0); }
-      static unsigned getHashValue(StringRef const val) {
-                                                return llvm::HashString(val); }
-      static bool isEqual(StringRef const lhs,
-                          StringRef const rhs) { return lhs.equals(rhs); }
-    };
-    typedef llvm::DenseMap<StringRef, HNode*, StrMappingInfo> NameToNode;
+    typedef llvm::DenseMap<StringRef, HNode*> NameToNode;
 
     bool isValidKey(StringRef key);
 
index d7a0bfa410053389157e9673fc4275c2575be73d..c0f366cb3e50da69a8f74819c9b0509bd6c64b42 100644 (file)
@@ -11,6 +11,7 @@
 #include "llvm/ADT/APInt.h"
 #include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/OwningPtr.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/edit_distance.h"
 #include <bitset>
 
@@ -465,3 +466,7 @@ bool StringRef::getAsInteger(unsigned Radix, APInt &Result) const {
 hash_code llvm::hash_value(StringRef S) {
   return hash_combine_range(S.begin(), S.end());
 }
+
+unsigned DenseMapInfo<StringRef>::getHashValue(StringRef const val) {
+  return llvm::HashString(val);
+}