Added versions of ReadPtr that takes an explicit SerializedPtrID. This allows
authorTed Kremenek <kremenek@apple.com>
Mon, 12 Nov 2007 19:11:15 +0000 (19:11 +0000)
committerTed Kremenek <kremenek@apple.com>
Mon, 12 Nov 2007 19:11:15 +0000 (19:11 +0000)
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
lib/Bitcode/Reader/Deserialize.cpp

index d8e3b38f4e7b3b38e1bf65f7bef1de6677b3169a..f69bdffad28fd0e5ebe9e15ee8182080171c5a0f 100644 (file)
@@ -240,10 +240,28 @@ public:
     ReadPtr(const_cast<T*&>(PtrRef), AllowBackpatch);
   }
   
+  
+  template <typename T>
+  void ReadPtr(T*& PtrRef, const SerializedPtrID& PtrID, bool AllowBackpatch = true) {
+    ReadUIntPtr(reinterpret_cast<uintptr_t&>(PtrRef), PtrID, AllowBackpatch);
+  }
+  
+  template <typename T>
+  void ReadPtr(const T*& PtrRef, const SerializedPtrID& PtrID, 
+               bool AllowBackpatch = true) {
+    
+    ReadPtr(const_cast<T*&>(PtrRef), PtrID, AllowBackpatch);
+  }
+  
   template <typename T>
   T* ReadPtr() { T* x; ReadPtr<T>(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 <typename T>
   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<typename T>
-  void RegisterRef(SerializedPtrID PtrID, const T& x) {
+  void RegisterRef(const SerializedPtrID& PtrID, const T& x) {
     RegisterPtr(PtrID,&x);
   }  
   
index 2e8b4ef08c4467a9f472ab76f60a27b332480542..ea6b27a62e989330e44e693f92ac85b3a4ae24b2 100644 (file)
@@ -324,7 +324,9 @@ void Deserializer::ReadCStr(std::vector<char>& buff, bool isNullTerm) {
     buff.push_back('\0');
 }
 
-void Deserializer::RegisterPtr(SerializedPtrID PtrId, const void* Ptr) {
+void Deserializer::RegisterPtr(const SerializedPtrID& PtrId,
+                               const void* Ptr) {
+  
   MapTy::value_type& E = BPatchMap.FindAndConstruct(BPKey(PtrId));
   
   assert (!HasFinalPtr(E) && "Pointer already registered.");
@@ -336,9 +338,9 @@ void Deserializer::RegisterPtr(SerializedPtrID PtrId, const void* Ptr) {
   SetPtr(E,Ptr);
 }
 
-void Deserializer::ReadUIntPtr(uintptr_t& PtrRef, bool AllowBackpatch) {
-  SerializedPtrID PtrId = ReadPtrID();
-  
+void Deserializer::ReadUIntPtr(uintptr_t& PtrRef, 
+                               const SerializedPtrID& PtrId,
+                               bool AllowBackpatch) {  
   if (PtrId == 0) {
     PtrRef = 0;
     return;