[llvm] r310507 - PointerLikeTypeTraits: class->struct & remove the base definition

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 9 11:34:21 PDT 2017


Author: dblaikie
Date: Wed Aug  9 11:34:21 2017
New Revision: 310507

URL: http://llvm.org/viewvc/llvm-project?rev=310507&view=rev
Log:
PointerLikeTypeTraits: class->struct & remove the base definition

This simplifies implementations and removing the base definition paves
the way for detecting whether a type is 'pointer like'.

Modified:
    llvm/trunk/include/llvm/ADT/PointerEmbeddedInt.h
    llvm/trunk/include/llvm/ADT/PointerIntPair.h
    llvm/trunk/include/llvm/ADT/PointerUnion.h
    llvm/trunk/include/llvm/Support/PointerLikeTypeTraits.h

Modified: llvm/trunk/include/llvm/ADT/PointerEmbeddedInt.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/PointerEmbeddedInt.h?rev=310507&r1=310506&r2=310507&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/PointerEmbeddedInt.h (original)
+++ llvm/trunk/include/llvm/ADT/PointerEmbeddedInt.h Wed Aug  9 11:34:21 2017
@@ -52,7 +52,7 @@ class PointerEmbeddedInt {
     explicit RawValueTag() = default;
   };
 
-  friend class PointerLikeTypeTraits<PointerEmbeddedInt>;
+  friend struct PointerLikeTypeTraits<PointerEmbeddedInt>;
 
   explicit PointerEmbeddedInt(uintptr_t Value, RawValueTag) : Value(Value) {}
 
@@ -80,10 +80,9 @@ public:
 // Provide pointer like traits to support use with pointer unions and sum
 // types.
 template <typename IntT, int Bits>
-class PointerLikeTypeTraits<PointerEmbeddedInt<IntT, Bits>> {
+struct PointerLikeTypeTraits<PointerEmbeddedInt<IntT, Bits>> {
   using T = PointerEmbeddedInt<IntT, Bits>;
 
-public:
   static inline void *getAsVoidPointer(const T &P) {
     return reinterpret_cast<void *>(P.Value);
   }

Modified: llvm/trunk/include/llvm/ADT/PointerIntPair.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/PointerIntPair.h?rev=310507&r1=310506&r2=310507&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/PointerIntPair.h (original)
+++ llvm/trunk/include/llvm/ADT/PointerIntPair.h Wed Aug  9 11:34:21 2017
@@ -201,9 +201,8 @@ struct DenseMapInfo<PointerIntPair<Point
 // Teach SmallPtrSet that PointerIntPair is "basically a pointer".
 template <typename PointerTy, unsigned IntBits, typename IntType,
           typename PtrTraits>
-class PointerLikeTypeTraits<
+struct PointerLikeTypeTraits<
     PointerIntPair<PointerTy, IntBits, IntType, PtrTraits>> {
-public:
   static inline void *
   getAsVoidPointer(const PointerIntPair<PointerTy, IntBits, IntType> &P) {
     return P.getOpaqueValue();

Modified: llvm/trunk/include/llvm/ADT/PointerUnion.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/PointerUnion.h?rev=310507&r1=310506&r2=310507&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/PointerUnion.h (original)
+++ llvm/trunk/include/llvm/ADT/PointerUnion.h Wed Aug  9 11:34:21 2017
@@ -207,8 +207,7 @@ bool operator<(PointerUnion<PT1, PT2> lh
 // Teach SmallPtrSet that PointerUnion is "basically a pointer", that has
 // # low bits available = min(PT1bits,PT2bits)-1.
 template <typename PT1, typename PT2>
-class PointerLikeTypeTraits<PointerUnion<PT1, PT2>> {
-public:
+struct PointerLikeTypeTraits<PointerUnion<PT1, PT2>> {
   static inline void *getAsVoidPointer(const PointerUnion<PT1, PT2> &P) {
     return P.getOpaqueValue();
   }
@@ -328,8 +327,7 @@ public:
 // Teach SmallPtrSet that PointerUnion3 is "basically a pointer", that has
 // # low bits available = min(PT1bits,PT2bits,PT2bits)-2.
 template <typename PT1, typename PT2, typename PT3>
-class PointerLikeTypeTraits<PointerUnion3<PT1, PT2, PT3>> {
-public:
+struct PointerLikeTypeTraits<PointerUnion3<PT1, PT2, PT3>> {
   static inline void *getAsVoidPointer(const PointerUnion3<PT1, PT2, PT3> &P) {
     return P.getOpaqueValue();
   }
@@ -435,8 +433,7 @@ public:
 // Teach SmallPtrSet that PointerUnion4 is "basically a pointer", that has
 // # low bits available = min(PT1bits,PT2bits,PT2bits)-2.
 template <typename PT1, typename PT2, typename PT3, typename PT4>
-class PointerLikeTypeTraits<PointerUnion4<PT1, PT2, PT3, PT4>> {
-public:
+struct PointerLikeTypeTraits<PointerUnion4<PT1, PT2, PT3, PT4>> {
   static inline void *
   getAsVoidPointer(const PointerUnion4<PT1, PT2, PT3, PT4> &P) {
     return P.getOpaqueValue();

Modified: llvm/trunk/include/llvm/Support/PointerLikeTypeTraits.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/PointerLikeTypeTraits.h?rev=310507&r1=310506&r2=310507&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/PointerLikeTypeTraits.h (original)
+++ llvm/trunk/include/llvm/Support/PointerLikeTypeTraits.h Wed Aug  9 11:34:21 2017
@@ -22,11 +22,7 @@ namespace llvm {
 
 /// A traits type that is used to handle pointer types and things that are just
 /// wrappers for pointers as a uniform entity.
-template <typename T> class PointerLikeTypeTraits {
-  // getAsVoidPointer
-  // getFromVoidPointer
-  // getNumLowBitsAvailable
-};
+template <typename T> struct PointerLikeTypeTraits;
 
 namespace detail {
 /// A tiny meta function to compute the log2 of a compile time constant.
@@ -37,16 +33,14 @@ template <> struct ConstantLog2<1> : std
 }
 
 // Provide PointerLikeTypeTraits for non-cvr pointers.
-template <typename T> class PointerLikeTypeTraits<T *> {
-public:
+template <typename T> struct PointerLikeTypeTraits<T *> {
   static inline void *getAsVoidPointer(T *P) { return P; }
   static inline T *getFromVoidPointer(void *P) { return static_cast<T *>(P); }
 
   enum { NumLowBitsAvailable = detail::ConstantLog2<alignof(T)>::value };
 };
 
-template <> class PointerLikeTypeTraits<void *> {
-public:
+template <> struct PointerLikeTypeTraits<void *> {
   static inline void *getAsVoidPointer(void *P) { return P; }
   static inline void *getFromVoidPointer(void *P) { return P; }
 
@@ -61,10 +55,9 @@ public:
 };
 
 // Provide PointerLikeTypeTraits for const things.
-template <typename T> class PointerLikeTypeTraits<const T> {
+template <typename T> struct PointerLikeTypeTraits<const T> {
   typedef PointerLikeTypeTraits<T> NonConst;
 
-public:
   static inline const void *getAsVoidPointer(const T P) {
     return NonConst::getAsVoidPointer(P);
   }
@@ -75,10 +68,9 @@ public:
 };
 
 // Provide PointerLikeTypeTraits for const pointers.
-template <typename T> class PointerLikeTypeTraits<const T *> {
+template <typename T> struct PointerLikeTypeTraits<const T *> {
   typedef PointerLikeTypeTraits<T *> NonConst;
 
-public:
   static inline const void *getAsVoidPointer(const T *P) {
     return NonConst::getAsVoidPointer(const_cast<T *>(P));
   }
@@ -89,8 +81,7 @@ public:
 };
 
 // Provide PointerLikeTypeTraits for uintptr_t.
-template <> class PointerLikeTypeTraits<uintptr_t> {
-public:
+template <> struct PointerLikeTypeTraits<uintptr_t> {
   static inline void *getAsVoidPointer(uintptr_t P) {
     return reinterpret_cast<void *>(P);
   }




More information about the llvm-commits mailing list