<div dir="ltr">Hi everyone. There's a little bug in PointerIntPair::setInt and ::setPointerAndInt where it assumes that the IntType of the container is implicitly convertible to intptr_t, preventing PointerIntPair from being used with an enum class as the IntType member of the pair. Here's a small patch to fix it. Let me know if you see any problems with this change. Thanks!<div>
<br></div><div>-Joe<br><div><br></div><div><div><div>===================================================================</div><div>--- include/llvm/ADT/PointerIntPair.h<span class="" style="white-space:pre">       </span>(revision 178549)</div>
<div>+++ include/llvm/ADT/PointerIntPair.h<span class="" style="white-space:pre">       </span>(working copy)</div><div>@@ -85,7 +85,7 @@</div><div>   }</div><div> </div><div>   void setInt(IntType Int) {</div><div>-    intptr_t IntVal = Int;</div>
<div>+    intptr_t IntVal = static_cast<intptr_t>(Int);</div><div>     assert(IntVal < (1 << IntBits) && "Integer too large for field");</div><div>     </div><div>     // Preserve all bits other than the ones we are updating.</div>
<div>@@ -106,7 +106,7 @@</div><div>       = reinterpret_cast<intptr_t>(PtrTraits::getAsVoidPointer(Ptr));</div><div>     assert((PtrVal & ((1 << PtrTraits::NumLowBitsAvailable)-1)) == 0 &&</div><div>
            "Pointer is not sufficiently aligned");</div><div>-    intptr_t IntVal = Int;</div><div>+    intptr_t IntVal = static_cast<intptr_t>(Int);</div><div>     assert(IntVal < (1 << IntBits) && "Integer too large for field");</div>
<div> </div><div>     Value = PtrVal | (IntVal << IntShift);</div></div></div></div><div><br></div></div>