[llvm-commits] [llvm] r152106 - in /llvm/trunk/include/llvm/ADT: PointerIntPair.h PointerUnion.h TinyPtrVector.h

Argyrios Kyrtzidis akyrtzi at gmail.com
Mon Mar 5 23:14:55 PST 2012


Author: akirtzidis
Date: Tue Mar  6 01:14:54 2012
New Revision: 152106

URL: http://llvm.org/viewvc/llvm-project?rev=152106&view=rev
Log:
PointerUnion::getAddrOf() does not need to be template since we can only
use the first pointer type for it. Rename it to getAddrOfPtr1().

Modified:
    llvm/trunk/include/llvm/ADT/PointerIntPair.h
    llvm/trunk/include/llvm/ADT/PointerUnion.h
    llvm/trunk/include/llvm/ADT/TinyPtrVector.h

Modified: llvm/trunk/include/llvm/ADT/PointerIntPair.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/PointerIntPair.h?rev=152106&r1=152105&r2=152106&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/PointerIntPair.h (original)
+++ llvm/trunk/include/llvm/ADT/PointerIntPair.h Tue Mar  6 01:14:54 2012
@@ -92,10 +92,14 @@
   }
 
   PointerTy const *getAddrOfPointer() const {
+    return const_cast<PointerIntPair *>(this)->getAddrOfPointer();
+  }
+
+  PointerTy *getAddrOfPointer() {
     assert(Value == reinterpret_cast<intptr_t>(getPointer()) &&
            "Can only return the address if IntBits is cleared and "
            "PtrTraits doesn't change the pointer");
-    return reinterpret_cast<PointerTy const *>(&Value);
+    return reinterpret_cast<PointerTy *>(&Value);
   }
 
   void *getOpaqueValue() const { return reinterpret_cast<void*>(Value); }

Modified: llvm/trunk/include/llvm/ADT/PointerUnion.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/PointerUnion.h?rev=152106&r1=152105&r2=152106&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/PointerUnion.h (original)
+++ llvm/trunk/include/llvm/ADT/PointerUnion.h Tue Mar  6 01:14:54 2012
@@ -142,16 +142,19 @@
       return T();
     }
 
-    /// \brief If the union is set to the first pointer type we can get an
-    /// address pointing to it.
-    template <typename T>
-    PT1 const *getAddrOf() const {
+    /// \brief If the union is set to the first pointer type get an address
+    /// pointing to it.
+    PT1 const *getAddrOfPtr1() const {
+      return const_cast<PointerUnion *>(this)->getAddrOfPtr1();
+    }
+
+    /// \brief If the union is set to the first pointer type get an address
+    /// pointing to it.
+    PT1 *getAddrOfPtr1() {
       assert(is<PT1>() && "Val is not the first pointer");
       assert(get<PT1>() == Val.getPointer() &&
          "Can't get the address because PointerLikeTypeTraits changes the ptr");
-      T const *can_only_get_address_of_first_pointer_type
-                        = reinterpret_cast<PT1 const *>(Val.getAddrOfPointer());
-      return can_only_get_address_of_first_pointer_type;
+      return (PT1 *)Val.getAddrOfPointer();
     }
     
     /// Assignment operators - Allow assigning into this union from either

Modified: llvm/trunk/include/llvm/ADT/TinyPtrVector.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/TinyPtrVector.h?rev=152106&r1=152105&r2=152106&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/TinyPtrVector.h (original)
+++ llvm/trunk/include/llvm/ADT/TinyPtrVector.h Tue Mar  6 01:14:54 2012
@@ -69,7 +69,7 @@
       return 0;
     
     if (Val.template is<EltTy>())
-      return Val.template getAddrOf<EltTy>();
+      return Val.getAddrOfPtr1();
     
     return Val.template get<VecTy *>()->begin();
 





More information about the llvm-commits mailing list