Added version of BatchEmitOwnedPtrs and BatchReadOwnedPtrs that emits/reads
authorTed Kremenek <kremenek@apple.com>
Wed, 7 Nov 2007 23:18:40 +0000 (23:18 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 7 Nov 2007 23:18:40 +0000 (23:18 +0000)
an array of pointers of the same type.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43852 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Bitcode/Deserialize.h
include/llvm/Bitcode/Serialize.h

index e77c6c9fa7fd901978960fdc98749ab7989195d3..5f8e137559326faeca28403e15ea17d615bb82ae 100644 (file)
@@ -166,6 +166,18 @@ public:
     P3 = (ID3) ? SerializeTrait<T2>::Materialize(*this) : NULL;
     if (ID3 && A3) RegisterPtr(ID3,P3);
   }
+  
+  template <typename T>
+  void BatchReadOwnedPtrs(unsigned NumPtrs, T** Ptrs) {
+    llvm::SmallVector<unsigned,20> PtrIDs;
+    PtrIDs.reserve(NumPtrs);
+    
+    for (unsigned i = 0; i < NumPtrs; ++i)
+      PtrIDs.push_back(ReadInt());
+    
+    for (unsigned i = 0; i < NumPtrs; ++i)
+      Ptrs[i] = PtrIDs[i] ? SerializeTrait<T>::Materialize(*this) : NULL;
+  }
     
   
   template <typename T>
index b92d49a7ea0795b728c11fd85b9e08699aaa9b7d..24e9f60951fa1e5f44ebbb1b0745447d6610e1e3 100644 (file)
@@ -85,6 +85,15 @@ public:
     if (p4) SerializeTrait<T4>::Emit(*this,*p4);
   }
 
+  template <typename T>
+  void BatchEmitOwnedPtrs(unsigned NumPtrs, T** Ptrs) {
+    for (unsigned i = 0; i < NumPtrs; ++i)
+      EmitPtr(Ptrs[i]);
+
+    for (unsigned i = 0; i < NumPtrs; ++i)
+      if (Ptrs[i]) SerializeTrait<T>::Emit(*this,Ptrs[i]);
+  }
+  
   void FlushRecord() { if (inRecord()) EmitRecord(); }
   
   void EnterBlock(unsigned BlockID = 8, unsigned CodeLen = 3);