From 75652009a04b5021c21c0dbc7e5c4eb79dc1fe1d Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 25 Apr 2011 20:58:50 +0000 Subject: [PATCH] allow adding a FoldingSetNodeID to a FastFoldingSetNode, resolving PR9499, patch by Johannes Schaub! llvm-svn: 130151 --- include/llvm/ADT/FoldingSet.h | 7 +++++-- lib/Support/FoldingSet.cpp | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/llvm/ADT/FoldingSet.h b/include/llvm/ADT/FoldingSet.h index 879dbd05e17..aaa48aca908 100644 --- a/include/llvm/ADT/FoldingSet.h +++ b/include/llvm/ADT/FoldingSet.h @@ -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 inline void Add(const T& x) { FoldingSetTrait::Profile(x, *this); } @@ -641,7 +642,7 @@ public: : data(a1,a2,a3,a4,a5) {} - void Profile(FoldingSetNodeID& ID) { FoldingSetTrait::Profile(data, ID); } + void Profile(FoldingSetNodeID &ID) { FoldingSetTrait::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); + } }; //===----------------------------------------------------------------------===// diff --git a/lib/Support/FoldingSet.cpp b/lib/Support/FoldingSet.cpp index a4f80a90d6d..d2e35b8eb67 100644 --- a/lib/Support/FoldingSet.cpp +++ b/lib/Support/FoldingSet.cpp @@ -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 {