summaryrefslogtreecommitdiff
path: root/lib/Bytecode
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-05-05 20:57:00 +0000
committerChris Lattner <sabre@nondot.org>2005-05-05 20:57:00 +0000
commitaba5ff567146339942253433f8d93b56a3bc05d7 (patch)
tree206fe869bc1fef13b582f3f6c744da0201706ed1 /lib/Bytecode
parentfd38787a8bd28e18cc0d80a6381bf8e560825a12 (diff)
downloadllvm-aba5ff567146339942253433f8d93b56a3bc05d7.tar.gz
llvm-aba5ff567146339942253433f8d93b56a3bc05d7.tar.bz2
llvm-aba5ff567146339942253433f8d93b56a3bc05d7.tar.xz
Add some extra checks. Opaque types don't have a null marker.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21700 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bytecode')
-rw-r--r--lib/Bytecode/Reader/Reader.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp
index 398ecfc372..75460c66fd 100644
--- a/lib/Bytecode/Reader/Reader.cpp
+++ b/lib/Bytecode/Reader/Reader.cpp
@@ -412,9 +412,12 @@ Value * BytecodeReader::getValue(unsigned type, unsigned oNum, bool Create) {
GlobalTyID = CompactionTypes[type-Type::FirstDerivedTyID].second;
if (hasImplicitNull(GlobalTyID)) {
- if (Num == 0)
- return Constant::getNullValue(getType(type));
- --Num;
+ const Type *Ty = getType(type);
+ if (!isa<OpaqueType>(Ty)) {
+ if (Num == 0)
+ return Constant::getNullValue(Ty);
+ --Num;
+ }
}
if (GlobalTyID < ModuleValues.size() && ModuleValues[GlobalTyID]) {
@@ -529,7 +532,7 @@ unsigned BytecodeReader::insertValue(Value *Val, unsigned type,
ValueTab[type]->push_back(Val);
- bool HasOffset = hasImplicitNull(type);
+ bool HasOffset = hasImplicitNull(type) && !isa<OpaqueType>(Val->getType());
return ValueTab[type]->size()-1 + HasOffset;
}
@@ -2141,6 +2144,9 @@ void BytecodeReader::ParseModule() {
error("Cannot find initializer value.");
}
+ if (!ConstantFwdRefs.empty())
+ error("Use of undefined constants in a module");
+
/// Make sure we pulled them all out. If we didn't then there's a declaration
/// but a missing body. That's not allowed.
if (!FunctionSignatureList.empty())