aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/ADT
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-03-29 00:18:42 +0000
committerChris Lattner <sabre@nondot.org>2009-03-29 00:18:42 +0000
commit4d4177b9b3ab634e852be1c0a7565a4ec1c7df93 (patch)
tree87d420c9bd60a8dbdc5385d6ad00154fec678959 /include/llvm/ADT
parent352f3e5d3783d0b27f5898f7c6a6c4fb5262b602 (diff)
downloadexternal_llvm-4d4177b9b3ab634e852be1c0a7565a4ec1c7df93.zip
external_llvm-4d4177b9b3ab634e852be1c0a7565a4ec1c7df93.tar.gz
external_llvm-4d4177b9b3ab634e852be1c0a7565a4ec1c7df93.tar.bz2
teach SmallPtrSet that PointerIntPair is "basically a pointer".
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67970 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT')
-rw-r--r--include/llvm/ADT/PointerIntPair.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/include/llvm/ADT/PointerIntPair.h b/include/llvm/ADT/PointerIntPair.h
index 8b47619..9225929 100644
--- a/include/llvm/ADT/PointerIntPair.h
+++ b/include/llvm/ADT/PointerIntPair.h
@@ -21,6 +21,8 @@ namespace llvm {
template<typename T>
struct DenseMapInfo;
+template<typename>
+class PointerLikeTypeInfo;
/// PointerIntPair - This class implements a pair of a pointer and small
/// integer. It is designed to represent this in the space required by one
@@ -62,6 +64,10 @@ public:
void *getOpaqueValue() const { return reinterpret_cast<void*>(Value); }
void setFromOpaqueValue(void *Val) { Value = reinterpret_cast<intptr_t>(Val);}
+ static PointerIntPair getFromOpaqueValue(void *V) {
+ PointerIntPair P; P.setFromOpaqueValue(V); return P;
+ }
+
bool operator==(const PointerIntPair &RHS) const {return Value == RHS.Value;}
bool operator!=(const PointerIntPair &RHS) const {return Value != RHS.Value;}
bool operator<(const PointerIntPair &RHS) const {return Value < RHS.Value;}
@@ -89,5 +95,19 @@ struct DenseMapInfo<PointerIntPair<PointerTy, IntBits, IntType> > {
static bool isPod() { return true; }
};
+// Teach SmallPtrSet that PointerIntPair is "basically a pointer".
+template<typename PointerTy, unsigned IntBits, typename IntType>
+class PointerLikeTypeInfo<PointerIntPair<PointerTy, IntBits, IntType> > {
+public:
+ static inline void *
+ getAsVoidPointer(const PointerIntPair<PointerTy, IntBits, IntType> &P) {
+ return P.getOpaqueValue();
+ }
+ static inline PointerIntPair<PointerTy, IntBits, IntType>
+ getFromVoidPointer(void *P) {
+ return PointerIntPair<PointerTy, IntBits, IntType>::getFromOpaqueValue(P);
+ }
+};
+
} // end namespace llvm
#endif