[llvm-branch-commits] [llvm-branch] r133595 - /llvm/branches/type-system-rewrite/lib/AsmParser/LLParser.cpp
Chris Lattner
sabre at nondot.org
Tue Jun 21 18:35:40 PDT 2011
Author: lattner
Date: Tue Jun 21 20:35:40 2011
New Revision: 133595
URL: http://llvm.org/viewvc/llvm-project?rev=133595&view=rev
Log:
diagnose type mismatchs in 'ret' in the asmparser with a nice error instead of barfing in the verifier.
Modified:
llvm/branches/type-system-rewrite/lib/AsmParser/LLParser.cpp
Modified: llvm/branches/type-system-rewrite/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/type-system-rewrite/lib/AsmParser/LLParser.cpp?rev=133595&r1=133594&r2=133595&view=diff
==============================================================================
--- llvm/branches/type-system-rewrite/lib/AsmParser/LLParser.cpp (original)
+++ llvm/branches/type-system-rewrite/lib/AsmParser/LLParser.cpp Tue Jun 21 20:35:40 2011
@@ -2961,11 +2961,18 @@
/// ::= 'ret' void (',' !dbg, !1)*
/// ::= 'ret' TypeAndValue (',' !dbg, !1)*
bool LLParser::ParseRet(Instruction *&Inst, BasicBlock *BB,
- PerFunctionState &PFS) {
+ PerFunctionState &PFS) {
+ SMLoc TypeLoc = Lex.getLoc();
Type *Ty = 0;
if (ParseType(Ty, true /*void allowed*/)) return true;
+ Type *ResType = PFS.getFunction().getReturnType();
+
if (Ty->isVoidTy()) {
+ if (!ResType->isVoidTy())
+ return Error(TypeLoc, "value doesn't match function result type '" +
+ getTypeString(ResType) + "'");
+
Inst = ReturnInst::Create(Context);
return false;
}
@@ -2973,6 +2980,10 @@
Value *RV;
if (ParseValue(Ty, RV, PFS)) return true;
+ if (ResType != RV->getType())
+ return Error(TypeLoc, "value doesn't match function result type '" +
+ getTypeString(ResType) + "'");
+
Inst = ReturnInst::Create(Context, RV);
return false;
}
More information about the llvm-branch-commits
mailing list