From 675e8cb09eefaf94db6be27dd65fb6627daae0d3 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Mon, 16 Mar 2015 21:35:48 +0000 Subject: Test bitcode parsing error-handling for incorrect explicit type (turns out I had regressed this when sinking handling of this type down into GetElementPtrInst::Create - since that asserted before the error handling was performed) llvm-svn: 232420 --- llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp') diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 143bb3dad9e..a26c444c6cc 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -3123,6 +3123,13 @@ std::error_code BitcodeReader::ParseFunctionBody(Function *F) { if (getValueTypePair(Record, OpNum, NextValueNo, BasePtr)) return Error("Invalid record"); + if (Ty && + Ty != + cast(BasePtr->getType()->getScalarType()) + ->getElementType()) + return Error( + "Explicit gep type does not match pointee type of pointer operand"); + SmallVector GEPIdx; while (OpNum != Record.size()) { Value *Op; @@ -3132,8 +3139,7 @@ std::error_code BitcodeReader::ParseFunctionBody(Function *F) { } I = GetElementPtrInst::Create(Ty, BasePtr, GEPIdx); - if (Ty && Ty != cast(I)->getSourceElementType()) - return Error("Invalid record"); + InstructionList.push_back(I); if (InBounds) cast(I)->setIsInBounds(true); -- cgit v1.2.3