Add a PointerLikeTypeTraits specialization for uintptr_t
authorChris Lattner <sabre@nondot.org>
Sun, 29 Mar 2009 06:00:21 +0000 (06:00 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 29 Mar 2009 06:00:21 +0000 (06:00 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67985 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/PointerLikeTypeTraits.h

index 000919ca109ad09dcff462d39c55f8d00ce14149..c5f79ccb83567605c79de167349160b7fe89628c 100644 (file)
@@ -15,6 +15,8 @@
 #ifndef LLVM_SUPPORT_POINTERLIKETYPETRAITS_H
 #define LLVM_SUPPORT_POINTERLIKETYPETRAITS_H
 
+#include "llvm/Support/DataTypes.h"
+
 namespace llvm {
   
 /// PointerLikeTypeTraits - This is a traits object that is used to handle
@@ -55,6 +57,20 @@ public:
   }
   enum { NumLowBitsAvailable = 3 };
 };
+
+// Provide PointerLikeTypeTraits for uintptr_t.
+template<>
+class PointerLikeTypeTraits<uintptr_t> {
+public:
+  static inline void *getAsVoidPointer(uintptr_t P) {
+    return reinterpret_cast<void*>(P);
+  }
+  static inline uintptr_t getFromVoidPointer(void *P) {
+    return reinterpret_cast<uintptr_t>(P);
+  }
+  // No bits are available!
+  enum { NumLowBitsAvailable = 0 };
+};
   
 } // end namespace llvm