[llvm-commits] [llvm] r43357 - in /llvm/trunk: include/llvm/Bitcode/Deserialize.h include/llvm/Bitcode/Serialize.h lib/Bitcode/Reader/Deserialize.cpp lib/Bitcode/Writer/Serialize.cpp
Ted Kremenek
kremenek at apple.com
Thu Oct 25 11:42:52 PDT 2007
Author: kremenek
Date: Thu Oct 25 13:42:52 2007
New Revision: 43357
URL: http://llvm.org/viewvc/llvm-project?rev=43357&view=rev
Log:
Added special treatment of serializing NULL pointers.
Modified:
llvm/trunk/include/llvm/Bitcode/Deserialize.h
llvm/trunk/include/llvm/Bitcode/Serialize.h
llvm/trunk/lib/Bitcode/Reader/Deserialize.cpp
llvm/trunk/lib/Bitcode/Writer/Serialize.cpp
Modified: llvm/trunk/include/llvm/Bitcode/Deserialize.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/Deserialize.h?rev=43357&r1=43356&r2=43357&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Bitcode/Deserialize.h (original)
+++ llvm/trunk/include/llvm/Bitcode/Deserialize.h Thu Oct 25 13:42:52 2007
@@ -86,6 +86,10 @@
template <typename T>
inline T* ReadOwnedPtr() {
unsigned PtrId = ReadInt();
+
+ if (PtrId == 0)
+ return NULL;
+
T* x = SerializeTrait<T>::Materialize(*this);
RegisterPtr(PtrId,x);
return x;
Modified: llvm/trunk/include/llvm/Bitcode/Serialize.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/Serialize.h?rev=43357&r1=43356&r2=43357&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Bitcode/Serialize.h (original)
+++ llvm/trunk/include/llvm/Bitcode/Serialize.h Thu Oct 25 13:42:52 2007
@@ -47,7 +47,7 @@
template <typename T>
void EmitOwnedPtr(T* ptr) {
EmitPtr(ptr);
- SerializeTrait<T>::Emit(*this,*ptr);
+ if (ptr) SerializeTrait<T>::Emit(*this,*ptr);
}
void Flush() { if (inRecord()) EmitRecord(); }
Modified: llvm/trunk/lib/Bitcode/Reader/Deserialize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/Deserialize.cpp?rev=43357&r1=43356&r2=43357&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/Deserialize.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/Deserialize.cpp Thu Oct 25 13:42:52 2007
@@ -103,6 +103,11 @@
void Deserializer::ReadPtr(void*& PtrRef) {
unsigned PtrId = ReadInt();
+ if (PtrId == 0) {
+ PtrRef = NULL;
+ return;
+ }
+
BPatchEntry& E = BPatchMap[PtrId];
if (E.Ptr == NULL) {
Modified: llvm/trunk/lib/Bitcode/Writer/Serialize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/Serialize.cpp?rev=43357&r1=43356&r2=43357&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Writer/Serialize.cpp (original)
+++ llvm/trunk/lib/Bitcode/Writer/Serialize.cpp Thu Oct 25 13:42:52 2007
@@ -58,10 +58,13 @@
}
unsigned Serializer::getPtrId(void* ptr) {
+ if (!ptr)
+ return 0;
+
MapTy::iterator I = PtrMap.find(ptr);
if (I == PtrMap.end()) {
- unsigned id = PtrMap.size();
+ unsigned id = PtrMap.size()+1;
PtrMap[ptr] = id;
return id;
}
More information about the llvm-commits
mailing list