Add testing for mismatched explicit type on a gep operator when loading from bitcode
authorDavid Blaikie <dblaikie@gmail.com>
Mon, 16 Mar 2015 22:03:50 +0000 (22:03 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Mon, 16 Mar 2015 22:03:50 +0000 (22:03 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232427 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Bitcode/Reader/BitcodeReader.cpp
test/Bitcode/Inputs/invalid-gep-operator-mismatched-explicit-type.bc [new file with mode: 0644]
test/Bitcode/invalid.test

index dd42bdb5804b0536b8cb982217d1c55e39e1c3ed..a95ceead54e759481976e0e1fda2111a4287d19e 100644 (file)
@@ -1973,7 +1973,8 @@ std::error_code BitcodeReader::ParseConstants() {
                                            bitc::CST_CODE_CE_INBOUNDS_GEP);
       if (PointeeType &&
           PointeeType != cast<GEPOperator>(V)->getSourceElementType())
-        return Error("Invalid record");
+        return Error("Explicit gep operator type does not match pointee type "
+                     "of pointer operand");
       break;
     }
     case bitc::CST_CODE_CE_SELECT: {  // CE_SELECT: [opval#, opval#, opval#]
diff --git a/test/Bitcode/Inputs/invalid-gep-operator-mismatched-explicit-type.bc b/test/Bitcode/Inputs/invalid-gep-operator-mismatched-explicit-type.bc
new file mode 100644 (file)
index 0000000..3af687f
Binary files /dev/null and b/test/Bitcode/Inputs/invalid-gep-operator-mismatched-explicit-type.bc differ
index edf122b8dffb25f21ce5a43319c1c0d26e5445ab..0eacb9dbbb1e8dc7855ec17f686e536e45726a0f 100644 (file)
@@ -16,6 +16,8 @@ RUN: not llvm-dis -disable-output %p/Inputs/invalid-gep-mismatched-explicit-type
 RUN:   FileCheck --check-prefix=MISMATCHED-EXPLICIT-GEP %s
 RUN: not llvm-dis -disable-output %p/Inputs/invalid-load-mismatched-explicit-type.bc 2>&1 | \
 RUN:   FileCheck --check-prefix=MISMATCHED-EXPLICIT-LOAD %s
+RUN: not llvm-dis -disable-output %p/Inputs/invalid-gep-operator-mismatched-explicit-type.bc 2>&1 | \
+RUN:   FileCheck --check-prefix=MISMATCHED-EXPLICIT-GEP-OPERATOR %s
 
 INVALID-ENCODING: Invalid encoding
 BAD-ABBREV: Abbreviation starts with an Array or a Blob
@@ -26,6 +28,7 @@ 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
 MISMATCHED-EXPLICIT-LOAD: Explicit load type does not match pointee type of pointer operand
+MISMATCHED-EXPLICIT-GEP-OPERATOR: Explicit gep operator 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