[llvm-commits] [llvm] r68159 - /llvm/trunk/include/llvm/ADT/PointerUnion.h
Douglas Gregor
dgregor at apple.com
Tue Mar 31 16:19:55 PDT 2009
Author: dgregor
Date: Tue Mar 31 18:19:54 2009
New Revision: 68159
URL: http://llvm.org/viewvc/llvm-project?rev=68159&view=rev
Log:
Allow the use of pointers to const within PointerUnion.
Modified:
llvm/trunk/include/llvm/ADT/PointerUnion.h
Modified: llvm/trunk/include/llvm/ADT/PointerUnion.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/PointerUnion.h?rev=68159&r1=68158&r2=68159&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/PointerUnion.h (original)
+++ llvm/trunk/include/llvm/ADT/PointerUnion.h Tue Mar 31 18:19:54 2009
@@ -69,11 +69,13 @@
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 @@
/// 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;
}
More information about the llvm-commits
mailing list