[llvm-commits] [llvm] r47637 - /llvm/trunk/lib/VMCore/Verifier.cpp

Devang Patel dpatel at apple.com
Tue Feb 26 14:55:21 PST 2008


Author: dpatel
Date: Tue Feb 26 16:55:21 2008
New Revision: 47637

URL: http://llvm.org/viewvc/llvm-project?rev=47637&view=rev
Log:
Add assert to check return type.

Modified:
    llvm/trunk/lib/VMCore/Verifier.cpp

Modified: llvm/trunk/lib/VMCore/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=47637&r1=47636&r2=47637&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Verifier.cpp (original)
+++ llvm/trunk/lib/VMCore/Verifier.cpp Tue Feb 26 16:55:21 2008
@@ -585,13 +585,13 @@
     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...





More information about the llvm-commits mailing list