diff options
author | Chris Lattner <sabre@nondot.org> | 2003-09-05 18:25:29 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-09-05 18:25:29 +0000 |
commit | 5bea411ad288ea6f25ac296ae2d75a4bfab8bf98 (patch) | |
tree | 4699d1ba8fc30fc24f9e6eac8fb7cde90804c724 /lib/Bytecode | |
parent | f3c333e36f576a846a6023da4253eaa8577709ff (diff) |
Fix reading of invoke instrs
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8365 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bytecode')
-rw-r--r-- | lib/Bytecode/Reader/InstructionReader.cpp | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/lib/Bytecode/Reader/InstructionReader.cpp b/lib/Bytecode/Reader/InstructionReader.cpp index c0bccd4c4f..4ce940db99 100644 --- a/lib/Bytecode/Reader/InstructionReader.cpp +++ b/lib/Bytecode/Reader/InstructionReader.cpp @@ -223,19 +223,19 @@ bool BytecodeParser::ParseInstruction(const unsigned char *&Buf, } case Instruction::Call: { - Value *M = getValue(Raw.Ty, Raw.Arg1); - if (M == 0) return true; + Value *F = getValue(Raw.Ty, Raw.Arg1); + if (F == 0) return true; // Check to make sure we have a pointer to method type - const PointerType *PTy = dyn_cast<PointerType>(M->getType()); + const PointerType *PTy = dyn_cast<PointerType>(F->getType()); if (PTy == 0) return true; - const FunctionType *MTy = dyn_cast<FunctionType>(PTy->getElementType()); - if (MTy == 0) return true; + const FunctionType *FTy = dyn_cast<FunctionType>(PTy->getElementType()); + if (FTy == 0) return true; std::vector<Value *> Params; - const FunctionType::ParamTypes &PL = MTy->getParamTypes(); + const FunctionType::ParamTypes &PL = FTy->getParamTypes(); - if (!MTy->isVarArg()) { + if (!FTy->isVarArg()) { FunctionType::ParamTypes::const_iterator It = PL.begin(); switch (Raw.NumOperands) { @@ -252,8 +252,8 @@ bool BytecodeParser::ParseInstruction(const unsigned char *&Buf, std::vector<unsigned> &args = *Raw.VarArgs; for (unsigned i = 0; i < args.size(); i++) { if (It == PL.end()) return true; - // TODO: Check getValue for null! Params.push_back(getValue(*It++, args[i])); + if (Params.back() == 0) return true; } } delete Raw.VarArgs; @@ -279,26 +279,26 @@ bool BytecodeParser::ParseInstruction(const unsigned char *&Buf, } } - Res = new CallInst(M, Params); + Res = new CallInst(F, Params); return false; } case Instruction::Invoke: { - Value *M = getValue(Raw.Ty, Raw.Arg1); - if (M == 0) return true; + Value *F = getValue(Raw.Ty, Raw.Arg1); + if (F == 0) return true; // Check to make sure we have a pointer to method type - const PointerType *PTy = dyn_cast<PointerType>(M->getType()); + const PointerType *PTy = dyn_cast<PointerType>(F->getType()); if (PTy == 0) return true; - const FunctionType *MTy = dyn_cast<FunctionType>(PTy->getElementType()); - if (MTy == 0) return true; + const FunctionType *FTy = dyn_cast<FunctionType>(PTy->getElementType()); + if (FTy == 0) return true; std::vector<Value *> Params; - const FunctionType::ParamTypes &PL = MTy->getParamTypes(); + const FunctionType::ParamTypes &PL = FTy->getParamTypes(); std::vector<unsigned> &args = *Raw.VarArgs; BasicBlock *Normal, *Except; - if (!MTy->isVarArg()) { + if (!FTy->isVarArg()) { if (Raw.NumOperands < 3) return true; Normal = cast<BasicBlock>(getValue(Type::LabelTy, Raw.Arg2)); @@ -310,28 +310,29 @@ bool BytecodeParser::ParseInstruction(const unsigned char *&Buf, FunctionType::ParamTypes::const_iterator It = PL.begin(); for (unsigned i = 1; i < args.size(); i++) { if (It == PL.end()) return true; - // TODO: Check getValue for null! Params.push_back(getValue(*It++, args[i])); + if (Params.back() == 0) return true; } if (It != PL.end()) return true; } } else { if (args.size() < 4) return true; - + if (getType(args[0]) != Type::LabelTy || + getType(args[2]) != Type::LabelTy) return true; Normal = cast<BasicBlock>(getValue(Type::LabelTy, args[1])); - Except = cast<BasicBlock>(getValue(Type::LabelTy, args[2])); + Except = cast<BasicBlock>(getValue(Type::LabelTy, args[3])); if ((args.size() & 1) != 0) return true; // Must be pairs of type/value for (unsigned i = 4; i < args.size(); i+=2) { - // TODO: Check getValue for null! - Params.push_back(getValue(getType(args[i]), args[i+1])); + Params.push_back(getValue(getType(args[i]), args[i+1])); + if (Params.back() == 0) return true; } } if (Raw.NumOperands > 3) delete Raw.VarArgs; - Res = new InvokeInst(M, Normal, Except, Params); + Res = new InvokeInst(F, Normal, Except, Params); return false; } case Instruction::Malloc: |