From: Douglas Gregor Date: Tue, 31 Mar 2009 23:19:54 +0000 (+0000) Subject: Allow the use of pointers to const within PointerUnion. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=41222823db11107834414a378525bb21493d3a1f;p=oota-llvm.git Allow the use of pointers to const within PointerUnion. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68159 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/ADT/PointerUnion.h b/include/llvm/ADT/PointerUnion.h index 1075711ec0c..b3baec1ff37 100644 --- a/include/llvm/ADT/PointerUnion.h +++ b/include/llvm/ADT/PointerUnion.h @@ -69,11 +69,13 @@ namespace llvm { PointerUnion() {} PointerUnion(PT1 V) { - Val.setPointer(PointerLikeTypeTraits::getAsVoidPointer(V)); + Val.setPointer( + const_cast(PointerLikeTypeTraits::getAsVoidPointer(V))); Val.setInt(0); } PointerUnion(PT2 V) { - Val.setPointer(PointerLikeTypeTraits::getAsVoidPointer(V)); + Val.setPointer( + const_cast(PointerLikeTypeTraits::getAsVoidPointer(V))); Val.setInt(1); } @@ -109,12 +111,14 @@ namespace llvm { /// Assignment operators - Allow assigning into this union from either /// pointer type, setting the discriminator to remember what it came from. const PointerUnion &operator=(const PT1 &RHS) { - Val.setPointer(PointerLikeTypeTraits::getAsVoidPointer(RHS)); + Val.setPointer( + const_cast(PointerLikeTypeTraits::getAsVoidPointer(RHS))); Val.setInt(0); return *this; } const PointerUnion &operator=(const PT2 &RHS) { - Val.setPointer(PointerLikeTypeTraits::getAsVoidPointer(RHS)); + Val.setPointer( + const_cast(PointerLikeTypeTraits::getAsVoidPointer(RHS))); Val.setInt(1); return *this; }