Implement constant pointers, and null specifically in the parser, bytecode writer, and
bytecode reader.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@668 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Bytecode/Reader/ConstantReader.cpp b/lib/Bytecode/Reader/ConstantReader.cpp
index baa367d..ae206da 100644
--- a/lib/Bytecode/Reader/ConstantReader.cpp
+++ b/lib/Bytecode/Reader/ConstantReader.cpp
@@ -250,7 +250,7 @@
}
case Type::StructTyID: {
- const StructType *ST = (const StructType*)Ty;
+ const StructType *ST = Ty->castStructType();
const StructType::ElementTypes &ET = ST->getElementTypes();
vector<ConstPoolVal *> Elements;
@@ -267,6 +267,17 @@
break;
}
+ case Type::PointerTyID: {
+ const PointerType *PT = Ty->castPointerType();
+ unsigned SubClass;
+ if (read_vbr(Buf, EndBuf, SubClass)) return failure(true);
+ if (SubClass != 0) return failure(true);
+
+
+ V = ConstPoolPointer::getNullPointer(PT);
+ break;
+ }
+
default:
cerr << __FILE__ << ":" << __LINE__
<< ": Don't know how to deserialize constant value of type '"
diff --git a/lib/Bytecode/Writer/ConstantWriter.cpp b/lib/Bytecode/Writer/ConstantWriter.cpp
index 24ceaec..dde47d5 100644
--- a/lib/Bytecode/Writer/ConstantWriter.cpp
+++ b/lib/Bytecode/Writer/ConstantWriter.cpp
@@ -141,6 +141,11 @@
break;
}
+ case Type::PointerTyID: {
+ output_vbr((unsigned)0, Out);
+ break;
+ }
+
case Type::FloatTyID: { // Floating point types...
float Tmp = (float)((const ConstPoolFP*)CPV)->getValue();
output_data(&Tmp, &Tmp+1, Out);