summaryrefslogtreecommitdiff
path: root/include/llvm/ADT/PointerIntPair.h
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-02-19 03:55:58 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-02-19 03:55:58 +0000
commit38297f5f760de604258aaa9000e5aadb43c78921 (patch)
treee9ca4a5ff9dfea50d5f7aff5e8c3d252e4268768 /include/llvm/ADT/PointerIntPair.h
parentdd6e40a4f4b131f9d5454183fa014553c9c8b44c (diff)
downloadllvm-38297f5f760de604258aaa9000e5aadb43c78921.tar.gz
llvm-38297f5f760de604258aaa9000e5aadb43c78921.tar.bz2
llvm-38297f5f760de604258aaa9000e5aadb43c78921.tar.xz
Allow getting the address of the value in a PointerUnion or PointerIntPair if one is
confident enough that he knows what he is doing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126019 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/PointerIntPair.h')
-rw-r--r--include/llvm/ADT/PointerIntPair.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/include/llvm/ADT/PointerIntPair.h b/include/llvm/ADT/PointerIntPair.h
index 64f4a7cee4..85dbba2b4a 100644
--- a/include/llvm/ADT/PointerIntPair.h
+++ b/include/llvm/ADT/PointerIntPair.h
@@ -91,6 +91,13 @@ public:
Value |= IntVal << IntShift; // Set new integer.
}
+ PointerTy const *getAddrOfPointer() const {
+ 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);
+ }
+
void *getOpaqueValue() const { return reinterpret_cast<void*>(Value); }
void setFromOpaqueValue(void *Val) { Value = reinterpret_cast<intptr_t>(Val);}