Add assert to check return type.
authorDevang Patel <dpatel@apple.com>
Tue, 26 Feb 2008 22:55:21 +0000 (22:55 +0000)
committerDevang Patel <dpatel@apple.com>
Tue, 26 Feb 2008 22:55:21 +0000 (22:55 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47637 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/Verifier.cpp

index 1a7100e5a4a677c9cc35b80a8e9ee9beb6588b04..e86c89bfa82766e6a794d75ec8c98e5ab9a3064f 100644 (file)
@@ -585,13 +585,13 @@ void Verifier::visitReturnInst(ReturnInst &RI) {
     Assert2(F->getReturnType() == RI.getOperand(0)->getType(),
             "Function return type does not match operand "
             "type of return inst!", &RI, F->getReturnType());
-  else {
-    const StructType *STy = cast<StructType>(F->getReturnType());
+  else if (const StructType *STy = dyn_cast<StructType>(F->getReturnType())) {
     for (unsigned i = 0; i < N; i++)
       Assert2(STy->getElementType(i) == RI.getOperand(i)->getType(),
-            "Function return type does not match operand "
-            "type of return inst!", &RI, F->getReturnType());
-  }
+              "Function return type does not match operand "
+              "type of return inst!", &RI, F->getReturnType());
+  } else
+    Assert1(0, "Invalid return type!", &RI);
 
   // Check to make sure that the return value has necessary properties for
   // terminators...