Fixed bug with inconsistent serialization/deserialization in matching

calls to BatchEmitOwnedPtrs and BatchReadOwnedPtrs.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44032 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Ted Kremenek 2007-11-13 00:13:57 +00:00
parent 553d22c29e
commit dd479dd3fe
2 changed files with 48 additions and 0 deletions

View File

@ -230,6 +230,37 @@ public:
}
}
template <typename T1, typename T2, typename T3>
void BatchReadOwnedPtrs(unsigned NumT1Ptrs, T1** Ptrs,
T2*& P2, T3*& P3,
bool A1=true, bool A2=true, bool A3=true) {
BatchIDVec.clear();
for (unsigned i = 0; i < NumT1Ptrs; ++i)
BatchIDVec.push_back(ReadPtrID());
SerializedPtrID ID2 = ReadPtrID();
SerializedPtrID ID3 = ReadPtrID();
for (unsigned i = 0; i < NumT1Ptrs; ++i) {
SerializedPtrID& PtrID = BatchIDVec[i];
T1* p = PtrID ? SerializeTrait<T1>::Materialize(*this) : NULL;
if (PtrID && A1)
RegisterPtr(PtrID,p);
Ptrs[i] = p;
}
P2 = (ID2) ? SerializeTrait<T2>::Materialize(*this) : NULL;
if (ID2 && A2) RegisterPtr(ID2,P2);
P3 = (ID3) ? SerializeTrait<T3>::Materialize(*this) : NULL;
if (ID3 && A3) RegisterPtr(ID3,P3);
}
template <typename T>
void ReadPtr(T*& PtrRef, bool AllowBackpatch = true) {
ReadUIntPtr(reinterpret_cast<uintptr_t&>(PtrRef), AllowBackpatch);

View File

@ -94,6 +94,23 @@ public:
if (Ptrs[i]) SerializeTrait<T>::Emit(*this,*Ptrs[i]);
}
template <typename T1, typename T2, typename T3>
void BatchEmitOwnedPtrs(unsigned NumT1Ptrs, T1* const * Ptrs,
T2* p2, T3* p3) {
for (unsigned i = 0; i < NumT1Ptrs; ++i)
EmitPtr(Ptrs[i]);
EmitPtr(p2);
EmitPtr(p3);
for (unsigned i = 0; i < NumT1Ptrs; ++i)
if (Ptrs[i]) SerializeTrait<T1>::Emit(*this,*Ptrs[i]);
if (p2) SerializeTrait<T2>::Emit(*this,*p2);
if (p3) SerializeTrait<T3>::Emit(*this,*p3);
}
bool isRegistered(const void* p) const;
void FlushRecord() { if (inRecord()) EmitRecord(); }