aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Bitcode
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2007-10-25 18:42:52 +0000
committerTed Kremenek <kremenek@apple.com>2007-10-25 18:42:52 +0000
commitf40b60369225926751fbe090505d0c4b0a3119b1 (patch)
treee1972402ad068ba4e4afdadc92bcf991e4901669 /lib/Bitcode
parent695b4b96a7e10ccd986e81cde59f5f167b96e20c (diff)
downloadexternal_llvm-f40b60369225926751fbe090505d0c4b0a3119b1.zip
external_llvm-f40b60369225926751fbe090505d0c4b0a3119b1.tar.gz
external_llvm-f40b60369225926751fbe090505d0c4b0a3119b1.tar.bz2
Added special treatment of serializing NULL pointers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43357 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bitcode')
-rw-r--r--lib/Bitcode/Reader/Deserialize.cpp5
-rw-r--r--lib/Bitcode/Writer/Serialize.cpp5
2 files changed, 9 insertions, 1 deletions
diff --git a/lib/Bitcode/Reader/Deserialize.cpp b/lib/Bitcode/Reader/Deserialize.cpp
index febb2d7..d1d6ef0 100644
--- a/lib/Bitcode/Reader/Deserialize.cpp
+++ b/lib/Bitcode/Reader/Deserialize.cpp
@@ -103,6 +103,11 @@ void Deserializer::RegisterPtr(unsigned PtrId,void* Ptr) {
void Deserializer::ReadPtr(void*& PtrRef) {
unsigned PtrId = ReadInt();
+ if (PtrId == 0) {
+ PtrRef = NULL;
+ return;
+ }
+
BPatchEntry& E = BPatchMap[PtrId];
if (E.Ptr == NULL) {
diff --git a/lib/Bitcode/Writer/Serialize.cpp b/lib/Bitcode/Writer/Serialize.cpp
index fbe1d10..a1d7320 100644
--- a/lib/Bitcode/Writer/Serialize.cpp
+++ b/lib/Bitcode/Writer/Serialize.cpp
@@ -58,10 +58,13 @@ void Serializer::EmitCStr(const char* s) {
}
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;
}