diff options
author | Chris Lattner <sabre@nondot.org> | 2005-05-05 20:57:00 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-05-05 20:57:00 +0000 |
commit | 7ddaeb448b8d01faa4c6af0e2626f07a454db7f4 (patch) | |
tree | fcd49e4844001439c3675c9cd31d8aad9a19d5fa /llvm/lib/Bytecode/Reader/Reader.cpp | |
parent | 2cc59a80667b5d05e26c9b755dcda332e4314198 (diff) | |
download | bcm5719-llvm-7ddaeb448b8d01faa4c6af0e2626f07a454db7f4.tar.gz bcm5719-llvm-7ddaeb448b8d01faa4c6af0e2626f07a454db7f4.zip |
Add some extra checks. Opaque types don't have a null marker.
llvm-svn: 21700
Diffstat (limited to 'llvm/lib/Bytecode/Reader/Reader.cpp')
-rw-r--r-- | llvm/lib/Bytecode/Reader/Reader.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/llvm/lib/Bytecode/Reader/Reader.cpp b/llvm/lib/Bytecode/Reader/Reader.cpp index 398ecfc3729..75460c66fd1 100644 --- a/llvm/lib/Bytecode/Reader/Reader.cpp +++ b/llvm/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()) |