diff options
author | Ted Kremenek <kremenek@apple.com> | 2012-09-08 04:25:29 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2012-09-08 04:25:29 +0000 |
commit | 0b3e805e4bc8a183429f49946a338ad67a7f6cd1 (patch) | |
tree | dd84712c8dd1c2772e744c10e553fa0fbab784b4 /llvm/lib/Support/FoldingSet.cpp | |
parent | 2f9cc0425101db67c73c4f2f4b63eb79aacc89ee (diff) | |
download | bcm5719-llvm-0b3e805e4bc8a183429f49946a338ad67a7f6cd1.tar.gz bcm5719-llvm-0b3e805e4bc8a183429f49946a338ad67a7f6cd1.zip |
Add operator< for FoldingSetNodeID.
llvm-svn: 163454
Diffstat (limited to 'llvm/lib/Support/FoldingSet.cpp')
-rw-r--r-- | llvm/lib/Support/FoldingSet.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/lib/Support/FoldingSet.cpp b/llvm/lib/Support/FoldingSet.cpp index c6282c6ab2a..4d489a88e55 100644 --- a/llvm/lib/Support/FoldingSet.cpp +++ b/llvm/lib/Support/FoldingSet.cpp @@ -38,6 +38,14 @@ bool FoldingSetNodeIDRef::operator==(FoldingSetNodeIDRef RHS) const { 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 @@ -152,6 +160,16 @@ 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. |