[llvm-commits] [llvm] r67985 - /llvm/trunk/include/llvm/Support/PointerLikeTypeTraits.h

Chris Lattner sabre at nondot.org
Sat Mar 28 23:00:21 PDT 2009


Author: lattner
Date: Sun Mar 29 01:00:21 2009
New Revision: 67985

URL: http://llvm.org/viewvc/llvm-project?rev=67985&view=rev
Log:
Add a PointerLikeTypeTraits specialization for uintptr_t

Modified:
    llvm/trunk/include/llvm/Support/PointerLikeTypeTraits.h

Modified: llvm/trunk/include/llvm/Support/PointerLikeTypeTraits.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/PointerLikeTypeTraits.h?rev=67985&r1=67984&r2=67985&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Support/PointerLikeTypeTraits.h (original)
+++ llvm/trunk/include/llvm/Support/PointerLikeTypeTraits.h Sun Mar 29 01:00:21 2009
@@ -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 @@
   }
   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
 





More information about the llvm-commits mailing list