llvm.org GIT mirror llvm / 62724da
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 Ted Kremenek 12 years ago
2 changed file(s) with 27 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
239239 ReadPtr(const_cast(PtrRef), AllowBackpatch);
240240 }
241241
242
243 template
244 void ReadPtr(T*& PtrRef, const SerializedPtrID& PtrID, bool AllowBackpatch = true) {
245 ReadUIntPtr(reinterpret_cast(PtrRef), PtrID, AllowBackpatch);
246 }
247
248 template
249 void ReadPtr(const T*& PtrRef, const SerializedPtrID& PtrID,
250 bool AllowBackpatch = true) {
251
252 ReadPtr(const_cast(PtrRef), PtrID, AllowBackpatch);
253 }
254
242255 template
243256 T* ReadPtr() { T* x; ReadPtr(x,false); return x; }
244257
245 void ReadUIntPtr(uintptr_t& PtrRef, bool AllowBackpatch = true);
258 void ReadUIntPtr(uintptr_t& PtrRef, const SerializedPtrID& PtrID,
259 bool AllowBackpatch = true);
260
261 void ReadUIntPtr(uintptr_t& PtrRef, bool AllowBackpatch = true) {
262 ReadUIntPtr(PtrRef,ReadPtrID(),AllowBackpatch);
263 }
246264
247265 template
248266 T& ReadRef() {
250268 return *p;
251269 }
252270
253 void RegisterPtr(SerializedPtrID PtrId, const void* Ptr);
271 void RegisterPtr(const SerializedPtrID& PtrID, const void* Ptr);
254272
255273 void RegisterPtr(const void* Ptr) {
256274 RegisterPtr(ReadPtrID(),Ptr);
262280 }
263281
264282 template
265 void RegisterRef(SerializedPtrID PtrID, const T& x) {
283 void RegisterRef(const SerializedPtrID& PtrID, const T& x) {
266284 RegisterPtr(PtrID,&x);
267285 }
268286
323323 buff.push_back('\0');
324324 }
325325
326 void Deserializer::RegisterPtr(SerializedPtrID PtrId, const void* Ptr) {
326 void Deserializer::RegisterPtr(const SerializedPtrID& PtrId,
327 const void* Ptr) {
328
327329 MapTy::value_type& E = BPatchMap.FindAndConstruct(BPKey(PtrId));
328330
329331 assert (!HasFinalPtr(E) && "Pointer already registered.");
335337 SetPtr(E,Ptr);
336338 }
337339
338 void Deserializer::ReadUIntPtr(uintptr_t& PtrRef, bool AllowBackpatch) {
339 SerializedPtrID PtrId = ReadPtrID();
340
340 void Deserializer::ReadUIntPtr(uintptr_t& PtrRef,
341 const SerializedPtrID& PtrId,
342 bool AllowBackpatch) {
341343 if (PtrId == 0) {
342344 PtrRef = 0;
343345 return;