allow adding a FoldingSetNodeID to a FastFoldingSetNode, resolving PR9499,
authorChris Lattner <sabre@nondot.org>
Mon, 25 Apr 2011 20:58:50 +0000 (20:58 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 25 Apr 2011 20:58:50 +0000 (20:58 +0000)
patch by Johannes Schaub!

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

include/llvm/ADT/FoldingSet.h
lib/Support/FoldingSet.cpp

index 879dbd05e174e8f872e841f155651928370fb6fd..aaa48aca908eb96e60422e44ee3ba956ff64fe3b 100644 (file)
@@ -310,6 +310,7 @@ public:
   void AddInteger(unsigned long long I);
   void AddBoolean(bool B) { AddInteger(B ? 1U : 0U); }
   void AddString(StringRef String);
+  void AddNodeID(const FoldingSetNodeID &ID);
 
   template <typename T>
   inline void Add(const T& x) { FoldingSetTrait<T>::Profile(x, *this); }
@@ -641,7 +642,7 @@ public:
   : data(a1,a2,a3,a4,a5) {}
 
 
-  void Profile(FoldingSetNodeIDID) { FoldingSetTrait<T>::Profile(data, ID); }
+  void Profile(FoldingSetNodeID &ID) { FoldingSetTrait<T>::Profile(data, ID); }
 
   T& getValue() { return data; }
   const T& getValue() const { return data; }
@@ -661,7 +662,9 @@ class FastFoldingSetNode : public FoldingSetNode {
 protected:
   explicit FastFoldingSetNode(const FoldingSetNodeID &ID) : FastID(ID) {}
 public:
-  void Profile(FoldingSetNodeID& ID) const { ID = FastID; }
+  void Profile(FoldingSetNodeID& ID) const { 
+    ID.AddNodeID(FastID); 
+  }
 };
 
 //===----------------------------------------------------------------------===//
index a4f80a90d6d097fdea18e6eafbdb85e4351f6867..d2e35b8eb676d264cbf8b17d59d754ca73127c8e 100644 (file)
@@ -147,6 +147,11 @@ void FoldingSetNodeID::AddString(StringRef String) {
   Bits.push_back(V);
 }
 
+// AddNodeID - Adds the Bit data of another ID to *this.
+void FoldingSetNodeID::AddNodeID(const FoldingSetNodeID &ID) {
+  Bits.append(ID.Bits.begin(), ID.Bits.end());
+}
+
 /// ComputeHash - Compute a strong hash value for this FoldingSetNodeID, used to 
 /// lookup the node in the FoldingSetImpl.
 unsigned FoldingSetNodeID::ComputeHash() const {