From 712d00bc64b9172e0d740d8126db08103ff845d3 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Mon, 16 Mar 2015 22:03:50 +0000 Subject: [PATCH] Add testing for mismatched explicit type on a gep operator when loading from bitcode git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232427 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Bitcode/Reader/BitcodeReader.cpp | 3 ++- ...valid-gep-operator-mismatched-explicit-type.bc | Bin 0 -> 492 bytes test/Bitcode/invalid.test | 3 +++ 3 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 test/Bitcode/Inputs/invalid-gep-operator-mismatched-explicit-type.bc diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index dd42bdb5804..a95ceead54e 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -1973,7 +1973,8 @@ std::error_code BitcodeReader::ParseConstants() { bitc::CST_CODE_CE_INBOUNDS_GEP); if (PointeeType && PointeeType != cast(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 index 0000000000000000000000000000000000000000..3af687f056f98ad1b5f8576f3798bac8dcdff0d2 GIT binary patch literal 492 zcmZ>AK5$Qwhk>Djfq{X$Nr8b0NDBiod!zD1#}h1`Yyw7>lNeigR9QJBup z_*FanyoK5TW(>t+0$&(!fbu!gGgBddvyl8c}9B?kZfo#n9yF3 zz+R@oUiO0(Xl!{ydpt*bp+tMpjP}YIjXLi>@V$G$_w@kZ8-_v!1_oxJf7k?K#2iFI xlz~i!L&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