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
This commit is contained in:
Douglas Gregor 2009-03-31 23:19:54 +00:00
parent b160f5d36d
commit 41222823db

View File

@ -69,11 +69,13 @@ namespace llvm {
PointerUnion() {}
PointerUnion(PT1 V) {
Val.setPointer(PointerLikeTypeTraits<PT1>::getAsVoidPointer(V));
Val.setPointer(
const_cast<void *>(PointerLikeTypeTraits<PT1>::getAsVoidPointer(V)));
Val.setInt(0);
}
PointerUnion(PT2 V) {
Val.setPointer(PointerLikeTypeTraits<PT2>::getAsVoidPointer(V));
Val.setPointer(
const_cast<void *>(PointerLikeTypeTraits<PT2>::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<PT1>::getAsVoidPointer(RHS));
Val.setPointer(
const_cast<void *>(PointerLikeTypeTraits<PT1>::getAsVoidPointer(RHS)));
Val.setInt(0);
return *this;
}
const PointerUnion &operator=(const PT2 &RHS) {
Val.setPointer(PointerLikeTypeTraits<PT2>::getAsVoidPointer(RHS));
Val.setPointer(
const_cast<void *>(PointerLikeTypeTraits<PT2>::getAsVoidPointer(RHS)));
Val.setInt(1);
return *this;
}