Author: kremenek Date: Tue Nov 6 16:21:14 2007 New Revision: 43783 URL: http://llvm.org/viewvc/llvm-project?rev=43783&view=rev Log: Augmented ReadPtr and ReadOwnedPtr to control whether or not a pointer is allowed to be backpatched or can be registered with the deserializer to backpatch other pointers.
Modified: llvm/trunk/include/llvm/Bitcode/Deserialize.h llvm/trunk/lib/Bitcode/Reader/Deserialize.cpp Modified: llvm/trunk/include/llvm/Bitcode/Deserialize.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/Deserialize.h?rev=43783&r1=43782&r2=43783&view=diff ============================================================================== --- llvm/trunk/include/llvm/Bitcode/Deserialize.h (original) +++ llvm/trunk/include/llvm/Bitcode/Deserialize.h Tue Nov 6 16:21:14 2007 @@ -114,33 +114,36 @@ void ReadCStr(std::vector<char>& buff, bool isNullTerm=false); template <typename T> - inline T* ReadOwnedPtr() { + inline T* ReadOwnedPtr(bool AutoRegister = true) { unsigned PtrId = ReadInt(); if (PtrId == 0) return NULL; T* x = SerializeTrait<T>::Materialize(*this); - RegisterPtr(PtrId,x); + + if (AutoRegister) + RegisterPtr(PtrId,x); + return x; } template <typename T> - inline void ReadOwnedPtr(T*& Ptr) { - Ptr = ReadOwnedPtr<T>(); + inline void ReadOwnedPtr(T*& Ptr, bool AutoRegister = true) { + Ptr = ReadOwnedPtr<T>(AutoRegister); } template <typename T> - void ReadPtr(T*& PtrRef) { - ReadUIntPtr(reinterpret_cast<uintptr_t&>(PtrRef)); + void ReadPtr(T*& PtrRef, bool AllowBackpatch = true) { + ReadUIntPtr(reinterpret_cast<uintptr_t&>(PtrRef), AllowBackpatch); } template <typename T> - void ReadPtr(const T*& PtrRef) { - ReadPtr(const_cast<T*&>(PtrRef)); + void ReadPtr(const T*& PtrRef, bool AllowBackpatch = true) { + ReadPtr(const_cast<T*&>(PtrRef), AllowBackpatch); } - void ReadUIntPtr(uintptr_t& PtrRef); + void ReadUIntPtr(uintptr_t& PtrRef, bool AllowBackpatch = true); template <typename T> T& ReadRef() { Modified: llvm/trunk/lib/Bitcode/Reader/Deserialize.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/Deserialize.cpp?rev=43783&r1=43782&r2=43783&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Reader/Deserialize.cpp (original) +++ llvm/trunk/lib/Bitcode/Reader/Deserialize.cpp Tue Nov 6 16:21:14 2007 @@ -152,7 +152,7 @@ SetPtr(E,Ptr); } -void Deserializer::ReadUIntPtr(uintptr_t& PtrRef) { +void Deserializer::ReadUIntPtr(uintptr_t& PtrRef, bool AllowBackpatch) { unsigned PtrId = ReadInt(); if (PtrId == 0) { @@ -169,6 +169,9 @@ if (HasFinalPtr(E)) PtrRef = GetFinalPtr(E); else { + assert (AllowBackpatch && + "Client forbids backpatching for this pointer."); + // Register backpatch. Check the freelist for a BPNode. BPNode* N; _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits