diff --git a/llvm/include/llvm/ADT/FoldingSet.h b/llvm/include/llvm/ADT/FoldingSet.h --- a/llvm/include/llvm/ADT/FoldingSet.h +++ b/llvm/include/llvm/ADT/FoldingSet.h @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -299,13 +300,23 @@ return static_cast(hash_combine_range(Data, Data + Size)); } - bool operator==(FoldingSetNodeIDRef) const; + bool operator==(const FoldingSetNodeIDRef &RHS) const { + if (Size != RHS.Size) + return false; + return memcmp(Data, RHS.Data, Size * sizeof(*Data)) == 0; + } - bool operator!=(FoldingSetNodeIDRef RHS) const { return !(*this == RHS); } + bool operator!=(const FoldingSetNodeIDRef &RHS) const { + return !(*this == RHS); + } /// Used to compare the "ordering" of two nodes as defined by the /// profiled bits and their ordering defined by memcmp(). - bool operator<(FoldingSetNodeIDRef) const; + bool operator<(const FoldingSetNodeIDRef &RHS) const { + if (Size != RHS.Size) + return Size < RHS.Size; + return memcmp(Data, RHS.Data, Size * sizeof(*Data)) < 0; + } const unsigned *getData() const { return Data; } size_t getSize() const { return Size; } @@ -372,16 +383,24 @@ } /// operator== - Used to compare two nodes to each other. - bool operator==(const FoldingSetNodeID &RHS) const; - bool operator==(const FoldingSetNodeIDRef RHS) const; + bool operator==(const FoldingSetNodeID &RHS) const { + return *this == FoldingSetNodeIDRef(RHS.Bits.data(), RHS.Bits.size()); + } + bool operator==(const FoldingSetNodeIDRef RHS) const { + return FoldingSetNodeIDRef(Bits.data(), Bits.size()) == RHS; + } bool operator!=(const FoldingSetNodeID &RHS) const { return !(*this == RHS); } bool operator!=(const FoldingSetNodeIDRef RHS) const { return !(*this ==RHS);} /// Used to compare the "ordering" of two nodes as defined by the /// profiled bits and their ordering defined by memcmp(). - bool operator<(const FoldingSetNodeID &RHS) const; - bool operator<(const FoldingSetNodeIDRef RHS) const; + bool operator<(const FoldingSetNodeID &RHS) const { + return *this < FoldingSetNodeIDRef(RHS.Bits.data(), RHS.Bits.size()); + } + bool operator<(const FoldingSetNodeIDRef RHS) const { + return FoldingSetNodeIDRef(Bits.data(), Bits.size()) < RHS; + } /// Intern - Copy this node's data to a memory region allocated from the /// given allocator and return a FoldingSetNodeIDRef describing the diff --git a/llvm/lib/Support/FoldingSet.cpp b/llvm/lib/Support/FoldingSet.cpp --- a/llvm/lib/Support/FoldingSet.cpp +++ b/llvm/lib/Support/FoldingSet.cpp @@ -21,22 +21,6 @@ #include using namespace llvm; -//===----------------------------------------------------------------------===// -// FoldingSetNodeIDRef Implementation - -bool FoldingSetNodeIDRef::operator==(FoldingSetNodeIDRef RHS) const { - if (Size != RHS.Size) return false; - return memcmp(Data, RHS.Data, Size*sizeof(*Data)) == 0; -} - -/// Used to compare the "ordering" of two nodes as defined by the -/// profiled bits and their ordering defined by memcmp(). -bool FoldingSetNodeIDRef::operator<(FoldingSetNodeIDRef RHS) const { - if (Size != RHS.Size) - return Size < RHS.Size; - return memcmp(Data, RHS.Data, Size*sizeof(*Data)) < 0; -} - //===----------------------------------------------------------------------===// // FoldingSetNodeID Implementation @@ -103,28 +87,6 @@ Bits.append(ID.Bits.begin(), ID.Bits.end()); } -/// operator== - Used to compare two nodes to each other. -/// -bool FoldingSetNodeID::operator==(const FoldingSetNodeID &RHS) const { - return *this == FoldingSetNodeIDRef(RHS.Bits.data(), RHS.Bits.size()); -} - -/// operator== - Used to compare two nodes to each other. -/// -bool FoldingSetNodeID::operator==(FoldingSetNodeIDRef RHS) const { - return FoldingSetNodeIDRef(Bits.data(), Bits.size()) == RHS; -} - -/// Used to compare the "ordering" of two nodes as defined by the -/// profiled bits and their ordering defined by memcmp(). -bool FoldingSetNodeID::operator<(const FoldingSetNodeID &RHS) const { - return *this < FoldingSetNodeIDRef(RHS.Bits.data(), RHS.Bits.size()); -} - -bool FoldingSetNodeID::operator<(FoldingSetNodeIDRef RHS) const { - return FoldingSetNodeIDRef(Bits.data(), Bits.size()) < RHS; -} - /// Intern - Copy this node's data to a memory region allocated from the /// given allocator and return a FoldingSetNodeIDRef describing the /// interned data.