From 62724da93086e52f8b48fa4c4b06309db330b5c8 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Mon, 12 Nov 2007 19:11:15 +0000 Subject: Added versions of ReadPtr that takes an explicit SerializedPtrID. This allows clients of the Deserializer to read the pointer ID before they are ready to deserialize the object (which can mean registering a pointer reference with the backpatcher). Changed some methods that took an argument "SerializedPtrID" to "const SerializedPtrID&" (pass-by-reference). This is to accommodate a future revision of SerializedPtrID where it may be much fatter than an unsigned integer. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44021 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Bitcode/Deserialize.h | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'include/llvm/Bitcode') diff --git a/include/llvm/Bitcode/Deserialize.h b/include/llvm/Bitcode/Deserialize.h index d8e3b38f4e..f69bdffad2 100644 --- a/include/llvm/Bitcode/Deserialize.h +++ b/include/llvm/Bitcode/Deserialize.h @@ -240,10 +240,28 @@ public: ReadPtr(const_cast(PtrRef), AllowBackpatch); } + + template + void ReadPtr(T*& PtrRef, const SerializedPtrID& PtrID, bool AllowBackpatch = true) { + ReadUIntPtr(reinterpret_cast(PtrRef), PtrID, AllowBackpatch); + } + + template + void ReadPtr(const T*& PtrRef, const SerializedPtrID& PtrID, + bool AllowBackpatch = true) { + + ReadPtr(const_cast(PtrRef), PtrID, AllowBackpatch); + } + template T* ReadPtr() { T* x; ReadPtr(x,false); return x; } - void ReadUIntPtr(uintptr_t& PtrRef, bool AllowBackpatch = true); + void ReadUIntPtr(uintptr_t& PtrRef, const SerializedPtrID& PtrID, + bool AllowBackpatch = true); + + void ReadUIntPtr(uintptr_t& PtrRef, bool AllowBackpatch = true) { + ReadUIntPtr(PtrRef,ReadPtrID(),AllowBackpatch); + } template T& ReadRef() { @@ -251,7 +269,7 @@ public: return *p; } - void RegisterPtr(SerializedPtrID PtrId, const void* Ptr); + void RegisterPtr(const SerializedPtrID& PtrID, const void* Ptr); void RegisterPtr(const void* Ptr) { RegisterPtr(ReadPtrID(),Ptr); @@ -263,7 +281,7 @@ public: } template - void RegisterRef(SerializedPtrID PtrID, const T& x) { + void RegisterRef(const SerializedPtrID& PtrID, const T& x) { RegisterPtr(PtrID,&x); } -- cgit v1.2.3-70-g09d2