diff options
author | David Majnemer <david.majnemer@gmail.com> | 2015-02-11 07:43:58 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2015-02-11 07:43:58 +0000 |
commit | 300745351f73b949d9a2d336efe9c349a5f278cc (patch) | |
tree | 89310221bef68a9fef174f3da2695b79489c4949 /llvm/lib/AsmParser/LLParser.cpp | |
parent | 19b51054afaa565efa85022dc233eee4deadc0d6 (diff) | |
download | bcm5719-llvm-300745351f73b949d9a2d336efe9c349a5f278cc.tar.gz bcm5719-llvm-300745351f73b949d9a2d336efe9c349a5f278cc.zip |
AsmParser: Don't crash when insertvalue has bad operands
llvm-svn: 228813
Diffstat (limited to 'llvm/lib/AsmParser/LLParser.cpp')
-rw-r--r-- | llvm/lib/AsmParser/LLParser.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index 25b2a315023..adf4c9073ab 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -4951,8 +4951,13 @@ int LLParser::ParseInsertValue(Instruction *&Inst, PerFunctionState &PFS) { if (!Val0->getType()->isAggregateType()) return Error(Loc0, "insertvalue operand must be aggregate type"); - if (!ExtractValueInst::getIndexedType(Val0->getType(), Indices)) + Type *IndexedType = ExtractValueInst::getIndexedType(Val0->getType(), Indices); + if (!IndexedType) return Error(Loc0, "invalid indices for insertvalue"); + if (IndexedType != Val1->getType()) + return Error(Loc1, "insertvalue operand and field disagree in type: '" + + getTypeString(Val1->getType()) + "' instead of '" + + getTypeString(IndexedType) + "'"); Inst = InsertValueInst::Create(Val0, Val1, Indices); return AteExtraComma ? InstExtraComma : InstNormal; } |