From 2a83bf622805e9902de2bab20def1e88b9587cb5 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Mon, 16 Mar 2015 21:48:46 +0000 Subject: [PATCH] Add testing for mismatched explicit type on a load instruction when loading from bitcode git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232424 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Bitcode/Reader/BitcodeReader.cpp | 6 +++--- .../invalid-load-mismatched-explicit-type.bc | Bin 0 -> 432 bytes test/Bitcode/invalid.test | 3 +++ 3 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 test/Bitcode/Inputs/invalid-load-mismatched-explicit-type.bc diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index a26c444c6cc..dd42bdb5804 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -3648,9 +3648,9 @@ std::error_code BitcodeReader::ParseFunctionBody(Function *F) { return EC; I = new LoadInst(Op, "", Record[OpNum+1], Align); - (void)Ty; - assert((!Ty || Ty == I->getType()) && - "Explicit type doesn't match pointee type of the first operand"); + if (Ty && Ty != I->getType()) + return Error("Explicit load type does not match pointee type of " + "pointer operand"); InstructionList.push_back(I); break; diff --git a/test/Bitcode/Inputs/invalid-load-mismatched-explicit-type.bc b/test/Bitcode/Inputs/invalid-load-mismatched-explicit-type.bc new file mode 100644 index 0000000000000000000000000000000000000000..1b8cbc75131653124fc6146d205b11c4b0fae038 GIT binary patch literal 432 zcmZ>AK5$Qwhk+rJfq{X$Nr8b0NDBiod!zD1#}h1`Yyw7>lNeigR9QJB%Qse!$+g1vY~A{SKKWfkoO3hk0-1o_@f;CpDm zpJ%}T_ygaE06t@ZBeM4tWo{_S9!iu;Gw8J5(`VfB&7NkP7G~=+A4JL$*sC+x z%`@7IfMi2^!G!jL1okow_Oc(WKx4}r+T%Ie3nki%X0%t%Xw-T4f$!Y|zOM)P-Y^s@ yFo46E%|RqY8R)M>AfE$B3$rk?GD@~EgM7{m#OwhAXGIdl3~YkIK>`$EU;qHDp?fj_ literal 0 HcmV?d00001 diff --git a/test/Bitcode/invalid.test b/test/Bitcode/invalid.test index 7eb28aa6fba..edf122b8dff 100644 --- a/test/Bitcode/invalid.test +++ b/test/Bitcode/invalid.test @@ -14,6 +14,8 @@ 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 +RUN: not llvm-dis -disable-output %p/Inputs/invalid-load-mismatched-explicit-type.bc 2>&1 | \ +RUN: FileCheck --check-prefix=MISMATCHED-EXPLICIT-LOAD %s INVALID-ENCODING: Invalid encoding BAD-ABBREV: Abbreviation starts with an Array or a Blob @@ -23,6 +25,7 @@ BAD-TYPE-TABLE-FORWARD-REF: Invalid TYPE table: Only named structs can be forwar 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 RUN: not llvm-dis -disable-output %p/Inputs/invalid-extractval-array-idx.bc 2>&1 | \ RUN: FileCheck --check-prefix=EXTRACT-ARRAY %s -- 2.34.1