Skip to content

Commit f287e7d

Browse files
author
Devang Patel
committed
Add assert to check return type.
llvm-svn: 47637
1 parent dea8c07 commit f287e7d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

llvm/lib/VMCore/Verifier.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -585,13 +585,13 @@ void Verifier::visitReturnInst(ReturnInst &RI) {
585585
Assert2(F->getReturnType() == RI.getOperand(0)->getType(),
586586
"Function return type does not match operand "
587587
"type of return inst!", &RI, F->getReturnType());
588-
else {
589-
const StructType *STy = cast<StructType>(F->getReturnType());
588+
else if (const StructType *STy = dyn_cast<StructType>(F->getReturnType())) {
590589
for (unsigned i = 0; i < N; i++)
591590
Assert2(STy->getElementType(i) == RI.getOperand(i)->getType(),
592-
"Function return type does not match operand "
593-
"type of return inst!", &RI, F->getReturnType());
594-
}
591+
"Function return type does not match operand "
592+
"type of return inst!", &RI, F->getReturnType());
593+
} else
594+
Assert1(0, "Invalid return type!", &RI);
595595

596596
// Check to make sure that the return value has necessary properties for
597597
// terminators...

0 commit comments

Comments
 (0)