[llvm] r232420 - Test bitcode parsing error-handling for incorrect explicit type
David Blaikie
dblaikie at gmail.com
Mon Mar 16 14:35:48 PDT 2015
Author: dblaikie
Date: Mon Mar 16 16:35:48 2015
New Revision: 232420
URL: http://llvm.org/viewvc/llvm-project?rev=232420&view=rev
Log:
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)
Added:
llvm/trunk/test/Bitcode/Inputs/invalid-gep-mismatched-explicit-type.bc
Modified:
llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/trunk/test/Bitcode/invalid.test
Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=232420&r1=232419&r2=232420&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Mon Mar 16 16:35:48 2015
@@ -3123,6 +3123,13 @@ std::error_code BitcodeReader::ParseFunc
if (getValueTypePair(Record, OpNum, NextValueNo, BasePtr))
return Error("Invalid record");
+ if (Ty &&
+ Ty !=
+ cast<SequentialType>(BasePtr->getType()->getScalarType())
+ ->getElementType())
+ return Error(
+ "Explicit gep type does not match pointee type of pointer operand");
+
SmallVector<Value*, 16> GEPIdx;
while (OpNum != Record.size()) {
Value *Op;
@@ -3132,8 +3139,7 @@ std::error_code BitcodeReader::ParseFunc
}
I = GetElementPtrInst::Create(Ty, BasePtr, GEPIdx);
- if (Ty && Ty != cast<GetElementPtrInst>(I)->getSourceElementType())
- return Error("Invalid record");
+
InstructionList.push_back(I);
if (InBounds)
cast<GetElementPtrInst>(I)->setIsInBounds(true);
Added: llvm/trunk/test/Bitcode/Inputs/invalid-gep-mismatched-explicit-type.bc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/Inputs/invalid-gep-mismatched-explicit-type.bc?rev=232420&view=auto
==============================================================================
Binary files llvm/trunk/test/Bitcode/Inputs/invalid-gep-mismatched-explicit-type.bc (added) and llvm/trunk/test/Bitcode/Inputs/invalid-gep-mismatched-explicit-type.bc Mon Mar 16 16:35:48 2015 differ
Modified: llvm/trunk/test/Bitcode/invalid.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/invalid.test?rev=232420&r1=232419&r2=232420&view=diff
==============================================================================
--- llvm/trunk/test/Bitcode/invalid.test (original)
+++ llvm/trunk/test/Bitcode/invalid.test Mon Mar 16 16:35:48 2015
@@ -12,6 +12,8 @@ RUN: not llvm-dis -disable-output %p/Inp
RUN: FileCheck --check-prefix=BAD-BITWIDTH %s
RUN: not llvm-dis -disable-output %p/Inputs/invalid-align.bc 2>&1 | \
RUN: FileCheck --check-prefix=BAD-ALIGN %s
+RUN: not llvm-dis -disable-output %p/Inputs/invalid-gep-mismatched-explicit-type.bc 2>&1 | \
+RUN: FileCheck --check-prefix=MISMATCHED-EXPLICIT-GEP %s
INVALID-ENCODING: Invalid encoding
BAD-ABBREV: Abbreviation starts with an Array or a Blob
@@ -20,6 +22,7 @@ BAD-ABBREV-NUMBER: Invalid abbrev number
BAD-TYPE-TABLE-FORWARD-REF: Invalid TYPE table: Only named structs can be forward referenced
BAD-BITWIDTH: Bitwidth for integer type out of range
BAD-ALIGN: Invalid alignment value
+MISMATCHED-EXPLICIT-GEP: Explicit gep type does not match pointee type of pointer operand
RUN: not llvm-dis -disable-output %p/Inputs/invalid-extractval-array-idx.bc 2>&1 | \
RUN: FileCheck --check-prefix=EXTRACT-ARRAY %s
More information about the llvm-commits
mailing list